MQL4 Book  Appendixes  Requirements and Limitations in Making Trades

Requirements and Limitations in Making Trades


Tables below show calculation values that limit the conduction of trades when opening, closing, placing, deleting or modifying orders.

To get the minimum distance to StopLevel and freezing distance FreezeLevel the MarketInfo() function should be called.


Requirements.

Correct prices used when performing trade operations.
Order Type
Open Price
Close Price
Open Price of a Pending Order
Transforming a Pending Order into aMarket Order
Buy
Ask
Bid


Sell
Bid
Ask


BuyLimit


Below the current Ask price
Ask price reaches open price
SellLimit


Above the current Bid price
Bid price reaches open price
BuyStop


Above the current Ask price
Ask price reaches open price
SellStop


Below the current Bid price
Bid price reaches open price

The possibility of deleting a pending order is regulated by the FreezeLevel parameter.


StopLevel Minimum Distance Limitation.

A trade operation will not be performed if any of the following conditions is disrupted.

Order Type
Open Price StopLoss (SL) TakeProfit (TP)
Buy
Modification is prohibited
Bid-SL StopLevel TP-Bid StopLevel
Sell
Modification is prohibited SL-Ask StopLevel Ask-TP StopLevel
BuyLimit
Ask-OpenPriceStopLevel OpenPrice-SL StopLevel TP-OpenPrice StopLevel
SellLimit
OpenPrice-Bid StopLevel SL-OpenPrice StopLevel OpenPrice-TP StopLevel
BuyStop
OpenPrice-Ask StopLevel OpenPrice-SL StopLevel TP-OpenPrice StopLevel
SellStop
Bid-OpenPrice StopLevel SL-OpenPrice StopLevel OpenPrice-TP StopLevel

FreezeLevel Limitation (Freezing Distance).

Market orders can not be closed if the StopLoss and TakeProfit values violate the FreezLevel parameter requirements.
StopLoss or TakeProfit orders can not be modified if StopLoss or TakeProfit values violate the StopLevel parameter requirements.
Pending orders can not be deleted or modified if the declared open price violates the FreezeLevel parameter requirements.

Order Type
Open Price StopLoss (SL) TakeProfit (TP)
Buy
Modification is prohibited Bid-SL > FreezeLevel TP-Bid > FreezeLevel
Sell
Modification is prohibited SL-Ask > FreezeLevel Ask-TP > FreezeLevel
BuyLimit
Ask-OpenPrice > FreezeLevel Regulated by the StopLevel parameter
Regulated by the StopLevel parameter
SellLimit
OpenPrice-Bid > FreezeLevel Regulated by the StopLevel parameter Regulated by the StopLevel parameter
BuyStop
OpenPrice-Ask > FreezeLevel Regulated by the StopLevel parameter Regulated by the StopLevel parameter
SellStop
Bid-OpenPrice > FreezeLevel Regulated by the StopLevel parameter Regulated by the StopLevel parameter