I have these variables that I want to be able to choose from in a drop down input under option for Line1 and Line2. These should be selectable using yet another drop down input with options = ['none', '==', '<', '>', '<=', '>=', '!=' , 'crossover', 'crossunder'])
named Operator1.
sm1res = input.timeframe(title='Time for open', defval='30')
sm1 = request.security(syminfo.tickerid, sm1res, open, lookahead=barmerge.lookahead_on)
sm2res = input.timeframe(title='Time for open', defval='60')
sm2 = request.security(syminfo.tickerid, sm2res, open, lookahead=barmerge.lookahead_on)
sm3res = input.timeframe(title='Time for open', defval='240')
sm3 = request.security(syminfo.tickerid, sm3res, open, lookahead=barmerge.lookahead_on)
to1res = input.timeframe(title='Time for previous open 1', defval='30')
to1 = request.security(syminfo.tickerid, to1res, open[1], lookahead=barmerge.lookahead_on)
to2res = input.timeframe(title='Time for previous open 2', defval='60')
to2 = request.security(syminfo.tickerid, to2res, open[1], lookahead=barmerge.lookahead_on)
to3res = input.timeframe(title='Time for previous open 3', defval='240')
to3 = request.security(syminfo.tickerid, to3res, open[1], lookahead=barmerge.lookahead_on)
th1res = input.timeframe(title='Time for previous high 1', defval='30')
th1 = request.security(syminfo.tickerid, th1res, high[1], lookahead=barmerge.lookahead_on)
th2res = input.timeframe(title='Time for previous high 2', defval='60')
th2 = request.security(syminfo.tickerid, th2res, high[1], lookahead=barmerge.lookahead_on)
th3res = input.timeframe(title='Time for previous high 3', defval='240')
th3 = request.security(syminfo.tickerid, th3res, high[1], lookahead=barmerge.lookahead_on)
tl1res = input.timeframe(title='Time for previous low 1', defval='30')
tl1 = request.security(syminfo.tickerid, tl1res, low[1], lookahead=barmerge.lookahead_on)
tl2res = input.timeframe(title='Time for previous low 2', defval='60')
tl2 = request.security(syminfo.tickerid, tl2res, low[1], lookahead=barmerge.lookahead_on)
tl3res = input.timeframe(title='Time for previous low 3', defval='240')
tl3 = request.security(syminfo.tickerid, tl3res, low[1], lookahead=barmerge.lookahead_on)
Line1 = input.string(defval = "sm1", title = 'Line1', inline = 'Operator1', group = 'Strategy1', options=["sm1", "sm2", "sm3", "to1", "to2", "to3", "th1", "th2", "th3", "tl1", "tl2", "tl3"])
Operator1 = input.string(defval = 'none', title = 'Operator1', inline = 'Operator1', group = 'Strategy1', options = ['none', '==', '<', '>', '<=', '>=', '!=', 'crossover', 'crossunder'])
Line2 = input.string(defval = none, title = 'Line2', inline = 'Operator1', group = 'Strategy1', options=["sm1", "sm2", "sm3", "to1", "to2", "to3", "th1", "th2", "th3", "tl1", "tl2", "tl3"])
Then I have a buy variable but can't get it to work with different attempts of code, sometimes it says it should be series string, bool, const string, Syntax error at input ':' and a lot of other errors.
BUY = line1 : Operator1 : line2 ? : na
Then comes my order placement:
if BUY
if Type == _S_
strategy.close('S')
else
strategy.entry('K', strategy.long)
if SELL
if Type == _L_
strategy.close('K')
else
strategy.entry('S', strategy.short)
Grateful for help so that parts of the errors are with correct code instead and suggestions for improvements welcome. I'm not very good at programming, so please explain in a simple way if you have time.
I've tried reading the manual and looking for different allowed types that go together. I have also tried Pinecoders and the chat. I'm afraid request.security doesn't allow options.