Closing a position once it's n candles old?
-
This is easy provided you only have one position open but I can't figure how to close only one position when there are several open.
The 'close position' block allows you to close a trade after n minutes, so I tried converting the candle to minutes. Problem is that all open positions are closed on the following monday after the weekend because time goes on even when the market is closed.
When I use a 'for each position' loop block to close trades after n bars, all trades are closed that were opened in the past n bars, not just the trades that are n bars old or more.
Thanks
-
@tonyramirez The second option should work. Can you please share your project?
-
@l-andorrà said in Closing a position once it's n candles old?:
@tonyramirez The second option should work. Can you please share your project?
Thanks for the offer!
I finally figured out that after a 'for each position' block you need to use the other pink blocks to perform actions like 'close position' rather than the generic blocks.
-
@tonyramirez Good for you. Congrats!

-
Please will you explain how to do this "When I use a 'for each position' loop block to close trades after n bars". I can't see how to do this. Thank you.
-
@Tulefi He means creating a loop searching for that info in the past candles.