I know this question has been asked many times, but some have got work around to this.
I am facing issue when I want to get the current price of the index and add 2 strike above or 2 strike below options value in the table to show the user which Call or Put is active, depending on the current price.
real_atm = int(( math.round ( close / strike ) ) * strike)
next_exp_date(OType) =>
strk = OType == "C" ? real_atm - (strike * 2) : real_atm + (strike * 2)
strikep = spot + _year + _month + _day + OType + str.tostring(strk)
[op_open,op_close,op_high,op_low,opPr_Low] = request.security(strikep,timeframe.period,[open,close,high,low,low[1]])
[op_open,op_close,op_high,op_low,opPr_Low,str.tostring(strk) + _day + OType]
stikeprice = request.security(syminfo.tickerid, timeframe.period , next_exp_date(expday) )
close = request.security(stikeprice , timeframe.period , close )
this is what I want to achieve, any help will be appreciated.
Thanks in advanced.
1