I’m currently working on a coding strategy and I want the automation to close the trade on the 21st candle (after 20 candles).
Can someone please assist me with codes for closing both long and or short trades after 20 candles. (whichever trade is open at the time long or short, not simultaneous)
Welcome to the forums. I have moved your topic to the ProOrder forum as that is the correct place for strategy questions. You posted in the ProBuilder forum which is for indicator questions. Please try to post in the correct forum with any future topics to ensure you are posting in the best place to find your answers. 🙂
The index of the candle that you last entered a trade on is stored as TRADEINDEX and the current candle is BARINDEX. So if BARINDEX minus TRADEINDEX = 20 then 20 candles have passed.
In ProOrder it is not possible to have a short and a long position open in a strategy simultaneously.