Manual Trade Maximum Deviation (error 180)

 

I am experiencing a lot of Error 180s which I have not be able to prevent even when using Trade Context flagging and . I have been told to use Maximum Deviation but I can only find this on the form for placing a manual trade. Can anyone tell me how Metratrader assigns a value to Maximum Deviation so that I can use this in my EA.

I have tried

Slip = MarketInfo(Symbol(),MODE_SPREAD)*Point;

but this does not work.

 

Hello BigAl

have you reviewed these links? If followed, is very unlikely that any TradeOperations issues will follow. However, if they do - why not contact your Broker - that's what they are there for, yes?

Requirements and Limitations in Making Trades https://book.mql4.com/appendix/limits
Order Characteristics and Rules for Making Trades https://book.mql4.com/trading/orders

 
fbj wrote >>

Hello BigAl

have you reviewed these links? If followed, is very unlikely that any TradeOperations issues will follow. However, if they do - why not contact your Broker - that's what they are there for, yes?

Requirements and Limitations in Making Trades https://book.mql4.com/appendix/limits
Order Characteristics and Rules for Making Trades https://book.mql4.com/trading/orders

Yes I have reviewed these. My problem is not consistent -

Lets say I want to place 5 trades with 5 different take profits. I use trade context flags to ensure that I am not placing orders too quickly then attempt to place the trades with TPs t 10, 20, 30, 40, 50 pips. Sometimes the trades are all placed and sometimes one or two give error 180.

Or

Lets say I want to close the same 5 trades sometimes they all close sometimes some do not close.

Sample of simplified code : (not prepared to give full code of my EA)

for (i = 1; i < 6; i++)

{

if (TradeBusy() < 0)

{

Print(Symbol(), " Trade busy when attempting to open Sell trade");

return(0);

}

RefreshRates();

Slip = MarketInfo(Symbol(),MODE_SPREAD)*Point;

TP = Bid – (i * 10)* Point;

Result = OrderSend(Symbol(), OP_SELL, 0.1, Bid, Slip, 0, TP, NULL, 0, 0, Red);

{

Print("Error ", GetLastError() " Opening Sell On ", Symbol());

}

TradeNotBusy();

}

 
BigAl:

Slip = MarketInfo(Symbol(),MODE_SPREAD)*Point;

[...]

Result = OrderSend(Symbol(), OP_SELL, 0.1, Bid, Slip, 0, TP, NULL, 0, 0, Red);

AFAIK, permitted slippage should be an integer number of pips (e.g. 20). The parameter is certainly an int, not a double. You seem to be passing a value such as 0.00025 - which will presumably get rounded down to zero.

 
jjc wrote >>

AFAIK, permitted slippage should be an integer number of pips (e.g. 20). The parameter is certainly an int, not a double. You seem to be passing a value such as 0.00025 - which will presumably get rounded down to zero.

Oops. Why did I do that!!!! and by the way the error code was 138 not 180.

Thanks

Reason: