There are diffrent ways to do this but it depends, if you always have 4 open orders or if this is different
one way, you can check if the last cloed order reach the TP and then you can close all other one
an other way, if you always have 4 open orders, you can check how many open order you have and is this below 4 you can close the rest
in genreal, on OrderClose() you have to use bid and ask, bcs the OrderClosePrice is for the OrderHistory()
Wrong.
-
For non-FIFO (US brokers,) (or the EA only opens one order per symbol,) you
can simply count down in a position loop, and you won't miss
orders. Get in the habit of always counting down.
Loops and Closing or Deleting Orders - MQL4 and MetaTrader 4 - MQL4 programming forum
For FIFO (US brokers,) and you (potentially) process multiple orders per symbol, you must count up and on a successful operation, reprocess all positions (set index to -1 before continuing.) -
and check OrderSelect in case earlier positions were deleted.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use the Predefined Variables (Bid/Ask) or OrderClosePrice() instead, on the next order/server call.
RefreshRates - Timeseries and Indicators Access - MQL4 Reference RefreshRates updates:
RefreshRates - Timeseries and Indicators Access - MQL4 Reference
Predefined Variables - MQL4 Reference
Also updates: Hour, Minute, and Seconds
Minute() returns wrong values - or am I wrong? - MQL4 and MetaTrader 4 - MQL4 programming forum
And updates: OrderClosePrice() on the next order select call.
I want to know how to close the orders of same currency pair.
For example, There are three open orders.
1. EU buy order with TP/SL
2.GU sell order with TP/SL
3. EU sell order with TP/SL
4. UJ sell order with TP/SL
Once the #1 reach to TP, how can I close #3 also at the same time?
#3 does not still reach to TP/SL but I want to close together.
How can I code it?
Not all brokers modify comments with TP. brokers can change comments, including complete replacement.
Thank you for your comments.
I want to close the same current pair at the same time. If one order is closed with TP or SL, at the same time, same currency pair should be closed even it is loss.
I may check with using "for int " to find the same currency which is already ordered and close together. I will try..
for(int i=OrdersTotal()-1;i>=0;i--)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to know how to close the orders of same currency pair.
For example, There are three open orders.
1. EU buy order with TP/SL
2.GU sell order with TP/SL
3. EU sell order with TP/SL
4. UJ sell order with TP/SL
Once the #1 reach to TP, how can I close #3 also at the same time?
#3 does not still reach to TP/SL but I want to close together.
How can I code it?