Close all trades when oldest trade is x minutes old
-
Hi everyone
Total newbie here, would appreciate any implementation tips!
I have an EA that opens trades and I am trying to create a separate fxdreema EA to close these baskets of trades when the oldest trade in the basket is x minutes old.
So for example there are 2 trades open, one is 59 mins old, the other is 1 minute old. As soon as the first trade reaches 60 mins the EA closes both trades.
I think I need the for loop to check the oldest trade, but then do I just need a close all block?
I am having difficulty defining a condition that compares the age of the oldest trade to whether it is older than x number of minutes.
And do I need a block for no trades?
-
Current progress:
https://fxdreema.com/shared/zh9bvm8Td
For some reason when I create a loop to find the oldest trade and restrict it to 1 iteration (so the output should be the very oldest), it brings up a trade from 2 days ago, rather than the oldest trade (that is 3 days old). It works if I specify the pair that has the oldest trade in it, but I just need the oldest trade from all the open trades. Anyone have any ideas? This is what it looks like so far

-
This is bizarre, everything else works:
- newest to oldest (correct)
- profitable first (correct)
- profitable last (correct)
- oldest to newest (incorrect)
It seems to ignore all the trades on the 'oldest' day UNLESS I specify the symbol. But if I use 'any symbol' it ignores the older trades still?
-
@learningfx You do not need a blue block above pink.
-
OK I worked around it in the end by ensuring symbol was specified. Then the loop would identify the oldest trade and close it (close trade, filter by age), with another close trade box to close the rest in the basket.
-
@learningfx said in Close all trades when oldest trade is x minutes old:
It seems to ignore all the trades on the 'oldest' day UNLESS I specify the symbol. But if I use 'any symbol' it ignores the older trades still?
Appears that I have still much to learn! I assumed 'any symbol' would loop through all open trade symbols, but the symbols MUST be specified. So I have a constant that holds all regular Forex symbols and I specify this constant in the loop. Mystery solved.
-
@learningfx That is weird because 'any symbol' should search for all open trade no matter what symbol is it from. Are you maybe combining forex charts with non forex? Nox forex charts NEED to be defined in the pip size rules because they are not there by default.