why the orderModify( ) return value 130 ? please help me debug the code
first off - you might like to look at below/editor help, as OrderTakeProfit() should be used ( trades current profit via OrderProfit() could be any double value, yes? )
| double OrderProfit ( | ) |
Returns profit for the currently selected order.
| double OrderTakeProfit ( | ) |
Note: The order must be previously selected by the OrderSelect() function.
Suggest:
OrderModify() is used many times in this article: https://www.mql5.com/en/articles/1491 How to Cut an EA Code for an Easier Life and Fewer Errors
also:
for some further background reading which shows/talks about OrderModify() try https://www.mql5.com/en/articles/1473 How to Make the Detection and Recovery of Errors in an Expert Advisor Code Easier
when an order sell Gbpusd :op = 2.0024 sl = 2.0054 profit = 1.9807 ask = 1.9959, I modify sl to 1.9979 by OrderModify().
but,to my suprise, the function return the value of error 130 ( non-valid stoploss).
the following is my code :
bool bSuccess = false ;
double _OrderStopLoss = OrderStopLoss() ;
double _Op = OrderOpenPrice() ;
if(OrderSelect(_Ticket1, SELECT_BY_TICKET, MODE_TRADES))
{
if( OrderType() == OP_BUY )
{
if( (Bid- _Op > 30 * Point) && (Bid - _OrderStopLoss > 25*Point) )
{
bSuccess = OrderModify(_Ticket1, _Op, Bid- 20 * Point,OrderProfit(),OrderExpiration(), Green ) ;
OrderPrint() ;
}
}
else
{
if( ( _Op - Ask > 30 * Point ) && ( _OrderStopLoss - Ask > 25*Point) )
{
bSuccess = OrderModify( _Ticket1,_Op, Ask + 20 * Point,OrderProfit(), OrderExpiration(), Green ) ;
OrderPrint() ;
}
}
if( !bSuccess ) Print(" Modify this order failed for error #", GetLastError());
}
else Print("ERROR!!!!!") ;
can someone help me to debug the code .
thank you in advance !