Close open trade after period of time

 

Hey, I am looking for an simple EA, that close all open trades after a period of time (seconds, minutes or hours)

I have found an EA that exactly does it "SimpleTimeBasedSL OrderManager EA v1.1" see attached file, but unfortunatley it closes also the pending orders, but I need an EA that closes only open trades.

Can someone add this feature to the EA or simply code a new one, that only does that?

It would be very appreciated, thank you

 
Jow3:

Hey, I am looking for an simple EA, that close all open trades after a period of time (seconds, minutes or hours)

I have found an EA that exactly does it "SimpleTimeBasedSL OrderManager EA v1.1" see attached file, but unfortunatley it closes also the pending orders, but I need an EA that closes only open trades.

Can someone add this feature to the EA or simply code a new one, that only does that?

It would be very appreciated, thank you

Please read documentation for OnTimer.

 
Arthur Albano:

Please read documentation for OnTimer.

not a good idea to manage open positions using timer event.

loop through open positions, and check each position open time vs current time, and if position is open more than X minutes, close it. (leads to constant trade durations)
or close all positions on a specific time (like 23:00:00 or whatever), again checking the time/duration conditions are better be done in OnTick()
 
Code2219 or probably 2319:
not a good idea to manage open positions using timer event.

loop through open positions, and check each position open time vs current time, and if position is open more than X minutes, close it. (leads to constant trade durations)
or close all positions on a specific time (like 23:00:00 or whatever), again checking the time/duration conditions are better be done in OnTick()
I close mine both using ontick and ontimer.