I've composed a simple script and want to insert a couple of conditions to close the trade. Either it hits the stop loss / take profit or after 30mins the trade is closed.
I have done the the stop loss / take profit part, I need assistance with closing the trade after 30mins?
strategy("S1", overlay=true)
source = close
length = input(20, minval=1)
mult = input(1.0, minval=0.001, maxval=50)
basis = sma(source, length)
sl_inp = input(100, title='Stop Loss in Ticks')
tp_inp = input(200, title='Take Profit in Ticks')
strategy.entry("buy", true, 1, when = crossover(close[0],basis))
strategy.exit("buy", loss=sl_inp, profit=tp_inp)