exit trade on next candle close
-
Hi, I want to make a system that enter positions on pending stop orders above/below each candle. Once a position is opened, i want the ea to exit the position on the very next candle close.
I am trying to make a variable that changes digit once a position has been opened. The new number assigned to the variable will allow the "close position" block to run. I have set the close position block to once per bar. What I am looking for is something like "once for every candle close", not once per bar, as this block also can run in the middle of a candle.
Does anyone know how I can make it so that the EA closes the open position on next closed candle?
https://fxdreema.com/shared/ZV5FidTjc

-
@piptheripper said in exit trade on next candle close:
on the very next candle close
What do you exactly mean by 'on the very next candle close'? The clsong of the same candle in which the trade waas open or the closing of the immediate candle AFTER the the one the trade was open?
-
@l-andorrà trade has to be closed on the close of the candle that activated the pending order. Thanks!
-
I figured out a way, I share it here in case anyone in the future needs something similar: https://fxdreema.com/shared/qgX8pwIbe
I created a variable called "bar counter"
on init i set the bar counter to 5 (just needs to be a number higher than 2 in this case)
once per candle i add 1 to bar counter
once per position i set bar counter to 1
when bar counter is 2 -> close trade -
@piptheripper Interesting solution. Thank you for sharing.