I am stuck and not sure what I am doing wrong.
My EA is reporting a OrderModify error 1 on almost every tick.
I am trying to get the EA to modify an order when the "entry" variable changes from the OrderOpenPrice(), which was originally opened using "entry".
The EA is working correctly and will modify the order to the correct point, however, it is trying to modify it even when the entry variable is == to itself, or OrderOpenPrice().
In the past to check values I have placed a Print (entry); and Print (OrderOpenPrice()); directly after if (entry != OrderOpenPrice()) { and it is still trying to execute my ordermodify statement even when both of these are == to eachother.
What am I doing wrong?
Thank you
Here is the code I have pertaining to this issue.
I found the answer to my mistake, when comparing doubles it is best to use < & > rather than !=.
The guys over at MQL4 forums helped me out with this problem.
Thanks
My EA is reporting a OrderModify error 1 on almost every tick.
I am trying to get the EA to modify an order when the "entry" variable changes from the OrderOpenPrice(), which was originally opened using "entry".
The EA is working correctly and will modify the order to the correct point, however, it is trying to modify it even when the entry variable is == to itself, or OrderOpenPrice().
In the past to check values I have placed a Print (entry); and Print (OrderOpenPrice()); directly after if (entry != OrderOpenPrice()) { and it is still trying to execute my ordermodify statement even when both of these are == to eachother.
What am I doing wrong?
Thank you
Here is the code I have pertaining to this issue.
Inserted Code
int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); if (OrderSymbol()==Symbol()&& OrderType()== OP_SELLSTOP && RiskManagement==true) { if (entry != OrderOpenPrice()) { OrderModify(OrderTicket(),entry,stoploss,takeprofit,0,0); } } if (OrderSymbol()==Symbol()&& OrderType()== OP_SELLSTOP && RiskManagement==false) { if (entry != OrderOpenPrice()) { OrderModify(OrderTicket(),entry,entry+(StopLossPips*Point),entry-(TakeProfitPips*Point),0,0); }
I found the answer to my mistake, when comparing doubles it is best to use < & > rather than !=.
The guys over at MQL4 forums helped me out with this problem.
Thanks