Hello! Need help with code to let me sell or exitshort (if on market) after x amount of bars.
Thanks!
Hello, you need the TRADEINDEX instruction which save the BARINDEX number when the trade were launched.
For example, if you want to exit a trade that have at least 5 bars elapsed since it were launched:
if onmarket and BARINDEX-TRADEINDEX(1)>5 then
SELL AT MARKET
EXITSHORT AT MARKET
endif