ziongotoptions
Active member
Hello I modified the option volume script and just replaced the volume parameter for open interest, it works on the daily timeframe , however I am unable to see the open interest on lower timeframes, would anyone be able to take a look through and see if it is possible to display the open interest a lower timeframe?
Code:
input aggregation = aggregationperiod.day;
def pricerange1 = if close(period=aggregation)[1]<=2 then 1 else 0; #.5
def pricerange2 = if close(period=aggregation)[1]>5 and close(period=aggregation)[1]<=150 then 1 else 0; #1
def pricerange3 = if close(period=aggregation)[1]>150 and close(period=aggregation)[1]<=500 then 1 else 0; #2.5
def pricerange4 = if close(period=aggregation)[1]>550 and close(period=aggregation)[1]<=4000 then 1 else 0; #5
def pricerange5 = if getsymbol()== "SPY" or getsymbol()== "QQQ" then 1 else 0;
#def pricerange6 = if close(period=aggregation)[1]>500 then 1 else 0; #25
def series = 1;
def RTHopen = open(period =aggregation);
def CurrentYear =GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
def Day1DOW1 = GetDayOfWeek((CurrentYear * 10000) + (CurrentMonth * 100) + 1); # First DOM is this DOW
def FirstFridayDOM1 = if Day1DOW1 < 6
then 6 - Day1DOW1
else if Day1DOW1 == 6
then 7
else 6;
def SecondFridayDOM = FirstFridayDOM1 + 7;
def ThirdFridayDOM = FirstFridayDOM1 + 14;
def FourthFridayDOM = FirstFridayDOM1 + 21;
def RollDOM = FirstFridayDOM1 + 21; #14; changed to 21 to pick up all Fridays of the current month for weekly options
def ExpMonth1 = if RollDOM > CurrentDOM
then CurrentMonth + series - 1
else CurrentMonth + series;
def ExpMonth2 = if ExpMonth1 > 12 #options month input
then ExpMonth1 - 12
else ExpMonth1;
def ExpYear = if ExpMonth1 > 12 #options year input
then CurrentYear + 1
else CurrentYear;
def Day1DOW = GetDayOfWeek(ExpYear * 10000 + ExpMonth2 * 100 + 1); #first friday expiry calc
def FirstFridayDOM = if Day1DOW < 6
then 6 - Day1DOW
else if Day1DOW == 6
then 7
else 6;
def ExpDOM = if currentDOM < FirstFridayDOM -1 #options code day of month input
then FirstFridayDOM1
else if between(currentDOM, FirstFridayDOM, SecondFridayDOM-1)
then SecondFridayDOM
else if between(currentDOM, SecondFridayDOM, ThirdFridayDOM-1)
then ThirdFridayDOM
else if between(currentDOM, ThirdFridayDOM, FourthFridayDOM-1)
then FourthFridayDOM
else FirstFridayDOM;
#MK BEGIN NEXT WEEKLY OPEX OPTIONS CODE CALL SYSTEM WITH YYMMDD FORMAT FIX --- MountainKing
#MK get correct double digit year for TOS option code format whether single or double digit.
#MK Year Exp Digit Format - MK
def ExpYY = ExpYear - 2000; # convert YYYY to 0-10 number YY or Y
def ExpY1 = if ExpYY > 9 # if year is double digit
then Round(ExpYY / 10,0) # use round to shear off first digit of YY (ex. 19, 1.9, 9)
else 0; # otherwise make first digit zero
def ExpY2 = if ExpYY > 9 # if year is double digit
then Round((ExpYY/10) - ExpY1,1) * 10 # isolate tenths of Y.Y as whole number # isolate tenths of Y.Y as whole number (ex. 1.9, 0.9, 9) -- fixed
else ExpYY; # otherwise return unprocessed single digit year
#MK Month Expiry Digit Format -MK
def ExpM1 = if ExpMonth2 > 9 # if double digit
then Round(ExpMonth2 / 10,0) # get month first digit
else 0; # else return 0
def ExpM2 = if ExpMonth2 > 9 # if double digit
then Round((ExpMonth2/10) - ExpM1,1) * 10 # isolate tenths of M.M as whole number -- fixed
else ExpMonth2; # otherwise return unprocessed single digit monthly
#MK Day Expiry Digit Format -MK
def ExpD1 = if ExpDOM > 9 # if double digit
then absvalue(Rounddown(absvalue(ExpDOM) / 10,0)) # get day first digit
else 0; # else return 0
def ExpD2 = if ExpDOM > 9 # if double digit
then absvalue((Round((ExpDOM/10) - ExpD1,1) * 10)) # isolate tenths of M.M as whole number -- fixed
else absvalue(ExpDOM); # otherwise return unprocessed single digit month
#MK - easier to see current expiry date label
AddLabel(1, GetSymbol() + " Exp:" + Concat((ExpM1),"") + Concat((ExpM2),"") + "-" + Concat((ExpD1),"") + Concat((ExpD2),"") + "-" + Concat((ExpY1),"") + Concat((ExpY2),""), CreateColor(135,135,135));
#def optionSeriesPrefix = Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"");
#NPTrading : manually update option expiry date in format YYMMDD
def strikeSpacing =
#if pricerange6 then 25
if pricerange5 then 1
else if pricerange4 then 5
else if pricerange3 then 2.5
else if pricerange2 then 1
else if pricerange1 then .5
else double.nan;
#{ default ".5", "1", "2.5", "5", "10", "25" }; #default 10 for large price stock
#NPTrading : Strike price determined based on current close price but could be previous day close
def PutStrike = Ceil(close/10)*10;
def CallStrike = Floor(close/10)*10;
### Put Option Volume
#MK retooled with updated options code format inputs
#MK option code test label
addlabel(No, ("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0)));
### putOIs #
def putOptionOI = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionOI1 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionOI2 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionOI3 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionOI4 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionOI5 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionOI6 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionOI7 =if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionOI8 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionOI9 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionOI10 =if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionOI11 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionOI12 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionOI13 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionOI14 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionOI15 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionOI16 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionOI17 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionOI18 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionOI19 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionOI20 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));
###Call Option OI
def callOptionOI = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptionOI1 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1));
def callOptionOI2 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2));
def callOptionOI3 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3));
def callOptionOI4 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4));
def callOptionOI5 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5));
def callOptionOI6 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6));
def callOptionOI7 =if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7));
def callOptionOI8 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8));
def callOptionOI9 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9));
def callOptionOI10 =if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10));
def callOptionOI11 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11));
def callOptionOI12 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12));
def callOptionOI13 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13));
def callOptionOI14 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14));
def callOptionOI15 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15));
def callOptionOI16 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16));
def callOptionOI17 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17));
def callOptionOI18 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18));
def callOptionOI19 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19));
def callOptionOI20 = if IsNaN(open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20))) then 0 else open_interest("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20));
### Put Option ohlc4
def putOptionohlc4 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionohlc41 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionohlc42 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionohlc43 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionohlc44 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionohlc45 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionohlc46 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionohlc47 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionohlc48 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionohlc49 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));
####Call Option ohlc4
def callOptionohlc4 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 0));
def callOptionohlc41 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 1));
def callOptionohlc42 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 2));
def callOptionohlc43 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 3));
def callOptionohlc44 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 4));
def callOptionohlc45 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 5));
def callOptionohlc46 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 6));
def callOptionohlc47 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 7));
def callOptionohlc48 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 8));
def callOptionohlc49 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 9));
def callOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 10));
def callOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 11));
def callOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 12));
def callOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 13));
def callOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 14));
def callOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 15));
def callOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 16));
def callOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 17));
def callOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 18));
def callOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 19));
def callOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 20));
def CallOIdef = if !isNan(close) then
((callOptionOI * callOptionohlc4 * 100) + (callOptionOI1 * callOptionohlc41 * 100) + (callOptionOI2 * callOptionohlc42 * 100) + (callOptionOI3 * callOptionohlc43 * 100) + (callOptionOI4 * callOptionohlc44 * 100) + (callOptionOI5 * callOptionohlc45 * 100) + (callOptionOI6 * callOptionohlc46 * 100) + (callOptionOI7 * callOptionohlc47 * 100) + (callOptionOI8 * callOptionohlc48 * 100) + (callOptionOI9 * callOptionohlc49 * 100) + (callOptionOI10 * callOptionohlc410 * 100) + (callOptionOI11 * callOptionohlc411 * 100) + (callOptionOI12 * callOptionohlc412 * 100) + (callOptionOI13 * callOptionohlc413 * 100) + (callOptionOI14 * callOptionohlc414 * 100) + (callOptionOI15 * callOptionohlc415 * 100) + (callOptionOI16 * callOptionohlc416 * 100) + (callOptionOI17 * callOptionohlc417 * 100) + (callOptionOI18 * callOptionohlc418 * 100) + (callOptionOI19 * callOptionohlc419 * 100) + (callOptionOI20 * callOptionohlc420 * 100)) / 1000
else double.nan;
def PutOIdef = if !isNan(close) then
((putOptionOI * putOptionohlc4 * 100) + (putOptionOI1 * putOptionohlc41 * 100) + (putOptionOI2 * putOptionohlc42 * 100) + (putOptionOI3 * putOptionohlc43 * 100) + (putOptionOI4 * putOptionohlc44 * 100) + (putOptionOI5 * putOptionohlc45 * 100) + (putOptionOI6 * putOptionohlc46 * 100) + (putOptionOI7 * putOptionohlc47 * 100) + (putOptionOI8 * putOptionohlc48 * 100) + (putOptionOI9 * putOptionohlc49 * 100) + (putOptionOI10 * putOptionohlc410 * 100) + (putOptionOI11 * putOptionohlc411 * 100) + (putOptionOI12 * putOptionohlc412 * 100) + (putOptionOI13 * putOptionohlc413 * 100) + (putOptionOI14 * putOptionohlc414 * 100) + (putOptionOI15 * putOptionohlc415 * 100) + (putOptionOI16 * putOptionohlc416 * 100) + (putOptionOI17 * putOptionohlc417 * 100) + (putOptionOI18 * putOptionohlc418 * 100) + (putOptionOI19 * putOptionohlc419 * 100) + (putOptionOI20 * putOptionohlc420 * 100)) / 1000
else double.nan;
def CallOI = if CallOIdef>=0 then CallOIdef else double.nan;
def PutOI = if PutOIdef>=0 then PutOIdef else double.nan; #MK made put volume negative
def OIRatio = (putoi/calloi);
AddLabel(yes, "OI Ratio:" + OIRatio, color = Color.CYAN);