Hello!
In an EA, I modify the SL and then I want to return the new stop loss as the following:
current_SL = OrderStopLoss();
But I got the original SL (before modification) into the current_SL
How can return the new OrderStopLoss() into the current_SL
Thanks.
PS: I defined the current_SL as double
double current_SL = 0;
How do you change the SL of an open/pending order?
Hello!
In an EA, I modify the SL and then I want to return the new stop loss as the following:
current_SL = OrderStopLoss();
But I got the original SL (before modification) into the current_SL
How can return the new OrderStopLoss() into the current_SL
Thanks.
PS: I defined the current_SL as double
double current_SL = 0;
Select the order after modifying the order to update OrderStopLoss()
Select the order after modifying the order to update OrderStopLoss()
Hello and thanks for your reply.
What do you mean by "Select the order after modifying the order"?
You asked how to get the new SL. What part of "Select the order after modifying the order" was unclear?
Hello!
I don't understand how should I select the order?! There is only one order.
OrderSelect - Trade Functions - MQL4 Reference
and don't forget OrderModify()
https://docs.mql4.com/trading/ordermodify
- docs.mql4.com
Guys,
Many thanks for your time and hints.
I didn't succeed. Would you be kind and help me, I am not good in this.
Here is a part of the code:
bool BE = False; double Old_ClosePrice=0; int start() { for (int lpos0 = 0; lpos0 < OrdersTotal(); lpos0++) { Result = OrderSelect(lpos0, SELECT_BY_POS, MODE_TRADES); if (OrderStopLoss() < OrderOpenPrice()) { Result = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, CLR_NONE); BE = True; Old_ClosePrice = iClose(OrderSymbol(), 0, 0); } } }
I want to return close price (in this case) to the "Old_ClosePrice" and change the BE from false to true. However "Old_ClosePrice" returns zero and BE returns false!
Please advise.
Many thanks.
Guys,
Many thanks for your time and hints.
I didn't succeed. Would you be kind and help me, I am not good in this.
Here is a part of the code:
I want to return close price (in this case) to the "Old_ClosePrice" and change the BE from false to true.
Please advise.
Many thanks.
That code will never work, but you are getting close
Before using any Order... function like OrderModify() you must activate OrderSelect()
Give it another try. As starting point use the code example from the link to OrderModify() documentation page.
Hint: You need to create a FOR loop for checking all trades open by means of OrderSelect()
That code will never work, but you are getting close
Before using any Order... function like OrderModify() you must activate OrderSelect()
Give it another try. As starting point use the code example from the link to OrderModify() documentation page.
Hint: You need to create a FOR loop for checking all trades open by means of OrderSelect()
Hello again, thanks for your reply.
As I mentioned, this a part of the code and except those two problems, it works fine.
I update the code in the above post (my bad).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
In an EA, I modify the SL and then I want to return the new stop loss as the following:
current_SL = OrderStopLoss();
But I got the original SL (before modification) into the current_SL
How can return the new OrderStopLoss() into the current_SL
Thanks.
PS: I defined the current_SL as double
double current_SL = 0;