close all trade after 50 minute but the first!

 

hi, I wanted to close all trades after 50 minutes after the first trade?


i have this script but i need to close all trade, not one, and to close all trade but from the first! example: first trade start at 15.00h (lot 0.01), second trade start at 15.20 (lot 0.02), at 15.50h close all !!!???


int start()
{
int maxDuration = 50 * 60;
for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
OrderSelect(pos, SELECT_BY_POS) // Only my orders w/
&& OrderSymbol()== "EURUSD"){ // and period and symbol
int duration = TimeCurrent() - OrderOpenTime();
if (duration >= maxDuration)
OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(),
3*Point);
} return(0);
}


 
kji:

hi, I wanted to close all trades after 50 minutes after the first trade?


i have this script but i need to close all trade, not one, and to close all trade but from the first! example: first trade start at 15.00h (lot 0.01), second trade start at 15.20 (lot 0.02), at 15.50h close all !!!???

<CODE REMOVED>

Please read some other posts before posting . . .

Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

 
kji:

hi, I wanted to close all trades after 50 minutes after the first trade?


i have this script but i need to close all trade, not one, and to close all trade but from the first! example: first trade start at 15.00h (lot 0.01), second trade start at 15.20 (lot 0.02), at 15.50h close all !!!???

First you need to find the oldest . . . in your loop remember the ticket number of the oldest trade you find . . . then outside the loop get the OrderOpenTime() for the ticket you have remembered, if it's older than 50 mins close all the open orders.
Reason: