Options Vol/Open Interest For ThinkOrSwim

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);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Im looking for thinkscirpt where I can have OI levels appear on the chart is there such a script that i can use or build off of?
open_interest ( String symbol, Any period, String priceType);

AddChartBubble ( boolean time condition, double price location, Any text, CustomColor color, boolean up);

Easy
 
I made a few updates this morning to the code I posted yesterday. It should clear up some confusion.
The Input PutStrike is your starting point for puts from the option chain. From there it will gather the strike points below it (consider starting a few strikes in the money and then it will gather those and then go to OTM strikes).
The Input Callstrike will be the starting point for calls. From the starting point it will gather the volume from the strikes above it.
The strike spacing will determine what other strikes you are pulling from to gather the volume at that strike price.

I also borrowed some code from Dilbert_BlockTrade_V1 to compare volume of those strikes to tick count, as indicated by the dot.
This is just a small glimpse of the option chain but I really want something that I can visualize in real time instead of watching the Options Time and Sales. Does anyone have any better methods of pulling data from the Option Chain?
Hello
DeusMecanicus, Is there any way to use this on a weekly chart? Thanks!
 
Last edited by a moderator:
is there an indicator that plots high open interest and high volume strikes as support and resistance levels?

Thanks
 
Last edited by a moderator:
Joe, I figured out how to plot Gamma Exposure levels on the upper chart, but there still is no good option chain scanner that catches all the Gamma and the OI for each strike. If you know of one, I'd love to hack it apart. Problem with Thinkscript is the Recursion and Fold functions chew up garbage collection in Java and max out even the best processors.
griftingthrulife...can you share how you are plotting gamma exposure levels on upper chart? Im calculating them in the option chain and then exporting it into Excel every day and monitoring the levels that way during live trading.
 
Last edited by a moderator:
@axlerod Additionally, here is a screen shot of what my plot looks like. Just realize the graph is just showing how many puts vs how many calls were purchased for a single day and not in any way a short interest indicator. So the big green humps just highlight that for THAT day a bunch of people traded puts relative to calls.

Capture.png


That's basically Peloton right this minute. You can see a ton of people were buying puts around 19-21 May possibly highlighting an upcoming short squeeze. Although, if you go look up the actual short ratio, it was declining significantly at that time. Take it as you will.
@Zardoz0609 Great study EVER¡¡¡¡¡

Will start to work with it and study the info for combining with my options strategy to see if i have and edge. But very very useful info 🧐🙌
 
griftingthrulife...can you share how you are plotting gamma exposure levels on upper chart? Im calculating them in the option chain and then exporting it into Excel every day and monitoring the levels that way during live trading.
My code is proprietary with a partner and we have agreed not to share pictures of it on social media. I can tell you this, it's a pain in the ***. But it's worth it to calculate gamma and then figure out how to plot it relative to price. Think "GEX" and SpotGamma. You can also do this in a spreadsheet, we just decided to skip that part and put 2 years into figuring out the code for TOS.
 
seems like you guys might like this... https://www.quanttradingapp.com/discord_pub/thinkscript_open_interest
if u cant see the study you can join his discord for free and get the study for free. It plots the highest OI levels on the chart like pricelines
and works for 9 major stocks and QQQ and SPY. You have to download a new one each day

#
# Plot Hightest OI Levels on Chart
# Only Valid For: Monday, May 02, 2022
#
# Script Generated: 2022-05-02 08:00:13 AM
# Free Tickers Included: AAPL,AMZN,DIA,DIS,FB,GLD,GOOGL,IWM,NFLX,QQQ,SPY,TSLA,NVDA,AMD
# Total Tickers: 14
#
# Credit: Quant Trading App (c) 2021-2022
# Discord: https://quanttradingdiscord.com
#

def aggregationPeriod = AggregationPeriod.DAY;def LastPrice = close(priceType = PriceType.LAST);def total_call_premium;def total_put_premium;
plot oi_call_1;plot oi_call_2;plot oi_call_3;plot oi_call_4;plot oi_call_5;plot oi_put_1;plot oi_put_2;plot oi_put_3;plot oi_put_4;plot oi_put_5;
if (GetSymbol() == "AAPL") {total_call_premium = 182739.19;total_put_premium = 1305603.67;oi_call_1 = 175;oi_call_2 = 170;oi_call_3 = 165;oi_call_4 = 180;oi_call_5 = 172.5;oi_put_1 = 160;oi_put_2 = 150;oi_put_3 = 180;oi_put_4 = 148;oi_put_5 = 155;}else if (GetSymbol() == "AMZN") {total_call_premium = 554707.84;total_put_premium = 5697674.43;oi_call_1 = 3500;oi_call_2 = 2900;oi_call_3 = 2800;oi_call_4 = 3000;oi_call_5 = 2700;oi_put_1 = 2300;oi_put_2 = 2500;oi_put_3 = 2100;oi_put_4 = 2000;oi_put_5 = 2400;}else if (GetSymbol() == "DIA") {total_call_premium = 23927.94;total_put_premium = 133498.2;oi_call_1 = 346;oi_call_2 = 344;oi_call_3 = 350;oi_call_4 = 348;oi_call_5 = 345;oi_put_1 = 325;oi_put_2 = 340;oi_put_3 = 341;oi_put_4 = 320;oi_put_5 = 336;}else if (GetSymbol() == "DIS") {total_call_premium = 17163.63;total_put_premium = 275540.91;oi_call_1 = 130;oi_call_2 = 120;oi_call_3 = 125;oi_call_4 = 126;oi_call_5 = 128;oi_put_1 = 130;oi_put_2 = 100;oi_put_3 = 120;oi_put_4 = 115;oi_put_5 = 125;}else if (GetSymbol() == "FB") {total_call_premium = 287312.73;total_put_premium = 365193.45;oi_call_1 = 220;oi_call_2 = 210;oi_call_3 = 200;oi_call_4 = 225;oi_call_5 = 250;oi_put_1 = 200;oi_put_2 = 150;oi_put_3 = 180;oi_put_4 = 100;oi_put_5 = 190;}else if (GetSymbol() == "GLD") {total_call_premium = 28801.7;total_put_premium = 58202.07;oi_call_1 = 177.5;oi_call_2 = 187;oi_call_3 = 177;oi_call_4 = 190;oi_call_5 = 180;oi_put_1 = 170;oi_put_2 = 175;oi_put_3 = 177;oi_put_4 = 178;oi_put_5 = 140;}else if (GetSymbol() == "GOOGL") {total_call_premium = 92488.95;total_put_premium = 1016902.5;oi_call_1 = 2700;oi_call_2 = 2500;oi_call_3 = 2800;oi_call_4 = 2350;oi_call_5 = 2600;oi_put_1 = 2350;oi_put_2 = 2100;oi_put_3 = 1900;oi_put_4 = 2300;oi_put_5 = 2000;}else if (GetSymbol() == "IWM") {total_call_premium = 59275.56;total_put_premium = 693686;oi_call_1 = 198;oi_call_2 = 200;oi_call_3 = 210;oi_call_4 = 215;oi_call_5 = 195;oi_put_1 = 165;oi_put_2 = 185;oi_put_3 = 187.5;oi_put_4 = 198;oi_put_5 = 175;}else if (GetSymbol() == "NFLX") {total_call_premium = 49425.49;total_put_premium = 631624.13;oi_call_1 = 240;oi_call_2 = 225;oi_call_3 = 250;oi_call_4 = 350;oi_call_5 = 260;oi_put_1 = 120;oi_put_2 = 190;oi_put_3 = 200;oi_put_4 = 180;oi_put_5 = 205;}else if (GetSymbol() == "QQQ") {total_call_premium = 264047.79;total_put_premium = 3254457.41;oi_call_1 = 340;oi_call_2 = 328;oi_call_3 = 325;oi_call_4 = 330;oi_call_5 = 365;oi_put_1 = 310;oi_put_2 = 300;oi_put_3 = 315;oi_put_4 = 305;oi_put_5 = 325;}else if (GetSymbol() == "SPY") {total_call_premium = 260339.5;total_put_premium = 5489504.58;oi_call_1 = 450;oi_call_2 = 445;oi_call_3 = 440;oi_call_4 = 420;oi_call_5 = 435;oi_put_1 = 415;oi_put_2 = 400;oi_put_3 = 385;oi_put_4 = 420;oi_put_5 = 380;}else if (GetSymbol() == "TSLA") {total_call_premium = 861299.95;total_put_premium = 3868044.99;oi_call_1 = 1000;oi_call_2 = 1100;oi_call_3 = 1200;oi_call_4 = 950;oi_call_5 = 1050;oi_put_1 = 800;oi_put_2 = 900;oi_put_3 = 700;oi_put_4 = 850;oi_put_5 = 750;}else if (GetSymbol() == "NVDA") {total_call_premium = 142389.07;total_put_premium = 1050267.13;oi_call_1 = 200;oi_call_2 = 210;oi_call_3 = 220;oi_call_4 = 250;oi_call_5 = 240;oi_put_1 = 190;oi_put_2 = 200;oi_put_3 = 180;oi_put_4 = 195;oi_put_5 = 155;}else if (GetSymbol() == "AMD") {total_call_premium = 121653.49;total_put_premium = 639358.85;oi_call_1 = 100;oi_call_2 = 109;oi_call_3 = 90;oi_call_4 = 95;oi_call_5 = 105;oi_put_1 = 85;oi_put_2 = 59;oi_put_3 = 80;oi_put_4 = 75;oi_put_5 = 100;}else {oi_call_1 = Double.NaN;oi_call_2 = Double.NaN;oi_call_3 = Double.NaN;oi_call_4 = Double.NaN;oi_call_5 = Double.NaN;oi_put_1 = Double.NaN;oi_put_2 = Double.NaN;oi_put_3 = Double.NaN;oi_put_4 = Double.NaN;oi_put_5 = Double.NaN;total_call_premium = 0;total_put_premium = 0;};oi_call_1.SetDefaultColor(CreateColor(0,236,59));oi_call_2.SetDefaultColor(CreateColor(0,197,49));oi_call_3.SetDefaultColor(CreateColor(0,158,39));oi_call_4.SetDefaultColor(CreateColor(0,119,29));oi_call_5.SetDefaultColor(CreateColor(0,79,20));oi_call_1.SetLineWeight(5);oi_call_2.SetLineWeight(4);oi_call_3.SetLineWeight(3);oi_call_4.SetLineWeight(2);oi_call_5.SetLineWeight(1);oi_put_1.SetDefaultColor(CreateColor(255,17,17));oi_put_2.SetDefaultColor(CreateColor(255,56,56));oi_put_3.SetDefaultColor(CreateColor(213,0,0));oi_put_4.SetDefaultColor(CreateColor(173,0,0));oi_put_5.SetDefaultColor(CreateColor(134,0,0));oi_put_1.SetLineWeight(5);oi_put_2.SetLineWeight(4);oi_put_3.SetLineWeight(3);oi_put_4.SetLineWeight(2);oi_put_5.SetLineWeight(1);addLabel (total_call_premium, "Calls: $"+ total_call_premium +" | Puts: $"+ total_put_premium, color.LIGHT_GRAY);
 
Similar idea as key levels by SpotGamma. Our coder was working on something like this I think. The levels look good. I'll check it out. It pretty much reads the map day to day and tells you what to keep a watch for level wise. That's as good as a roadmap I think as anyone can have.

As for the other example, the volume profile, I have been toying with the idea of funneling Gamma/Volume into a volume or data profile and weighting it for volume depending where it is in the gamma hedge regime. Nice examples here.
 
seems like you guys might like this... https://www.quanttradingapp.com/discord_pub/thinkscript_open_interest
if u cant see the study you can join his discord for free and get the study for free. It plots the highest OI levels on the chart like pricelines
and works for 9 major stocks and QQQ and SPY. You have to download a new one each day

#
# Plot Hightest OI Levels on Chart
# Only Valid For: Monday, May 02, 2022
#
# Script Generated: 2022-05-02 08:00:13 AM
# Free Tickers Included: AAPL,AMZN,DIA,DIS,FB,GLD,GOOGL,IWM,NFLX,QQQ,SPY,TSLA,NVDA,AMD
# Total Tickers: 14
#
# Credit: Quant Trading App (c) 2021-2022
# Discord: https://quanttradingdiscord.com
#

def aggregationPeriod = AggregationPeriod.DAY;def LastPrice = close(priceType = PriceType.LAST);def total_call_premium;def total_put_premium;
plot oi_call_1;plot oi_call_2;plot oi_call_3;plot oi_call_4;plot oi_call_5;plot oi_put_1;plot oi_put_2;plot oi_put_3;plot oi_put_4;plot oi_put_5;
if (GetSymbol() == "AAPL") {total_call_premium = 182739.19;total_put_premium = 1305603.67;oi_call_1 = 175;oi_call_2 = 170;oi_call_3 = 165;oi_call_4 = 180;oi_call_5 = 172.5;oi_put_1 = 160;oi_put_2 = 150;oi_put_3 = 180;oi_put_4 = 148;oi_put_5 = 155;}else if (GetSymbol() == "AMZN") {total_call_premium = 554707.84;total_put_premium = 5697674.43;oi_call_1 = 3500;oi_call_2 = 2900;oi_call_3 = 2800;oi_call_4 = 3000;oi_call_5 = 2700;oi_put_1 = 2300;oi_put_2 = 2500;oi_put_3 = 2100;oi_put_4 = 2000;oi_put_5 = 2400;}else if (GetSymbol() == "DIA") {total_call_premium = 23927.94;total_put_premium = 133498.2;oi_call_1 = 346;oi_call_2 = 344;oi_call_3 = 350;oi_call_4 = 348;oi_call_5 = 345;oi_put_1 = 325;oi_put_2 = 340;oi_put_3 = 341;oi_put_4 = 320;oi_put_5 = 336;}else if (GetSymbol() == "DIS") {total_call_premium = 17163.63;total_put_premium = 275540.91;oi_call_1 = 130;oi_call_2 = 120;oi_call_3 = 125;oi_call_4 = 126;oi_call_5 = 128;oi_put_1 = 130;oi_put_2 = 100;oi_put_3 = 120;oi_put_4 = 115;oi_put_5 = 125;}else if (GetSymbol() == "FB") {total_call_premium = 287312.73;total_put_premium = 365193.45;oi_call_1 = 220;oi_call_2 = 210;oi_call_3 = 200;oi_call_4 = 225;oi_call_5 = 250;oi_put_1 = 200;oi_put_2 = 150;oi_put_3 = 180;oi_put_4 = 100;oi_put_5 = 190;}else if (GetSymbol() == "GLD") {total_call_premium = 28801.7;total_put_premium = 58202.07;oi_call_1 = 177.5;oi_call_2 = 187;oi_call_3 = 177;oi_call_4 = 190;oi_call_5 = 180;oi_put_1 = 170;oi_put_2 = 175;oi_put_3 = 177;oi_put_4 = 178;oi_put_5 = 140;}else if (GetSymbol() == "GOOGL") {total_call_premium = 92488.95;total_put_premium = 1016902.5;oi_call_1 = 2700;oi_call_2 = 2500;oi_call_3 = 2800;oi_call_4 = 2350;oi_call_5 = 2600;oi_put_1 = 2350;oi_put_2 = 2100;oi_put_3 = 1900;oi_put_4 = 2300;oi_put_5 = 2000;}else if (GetSymbol() == "IWM") {total_call_premium = 59275.56;total_put_premium = 693686;oi_call_1 = 198;oi_call_2 = 200;oi_call_3 = 210;oi_call_4 = 215;oi_call_5 = 195;oi_put_1 = 165;oi_put_2 = 185;oi_put_3 = 187.5;oi_put_4 = 198;oi_put_5 = 175;}else if (GetSymbol() == "NFLX") {total_call_premium = 49425.49;total_put_premium = 631624.13;oi_call_1 = 240;oi_call_2 = 225;oi_call_3 = 250;oi_call_4 = 350;oi_call_5 = 260;oi_put_1 = 120;oi_put_2 = 190;oi_put_3 = 200;oi_put_4 = 180;oi_put_5 = 205;}else if (GetSymbol() == "QQQ") {total_call_premium = 264047.79;total_put_premium = 3254457.41;oi_call_1 = 340;oi_call_2 = 328;oi_call_3 = 325;oi_call_4 = 330;oi_call_5 = 365;oi_put_1 = 310;oi_put_2 = 300;oi_put_3 = 315;oi_put_4 = 305;oi_put_5 = 325;}else if (GetSymbol() == "SPY") {total_call_premium = 260339.5;total_put_premium = 5489504.58;oi_call_1 = 450;oi_call_2 = 445;oi_call_3 = 440;oi_call_4 = 420;oi_call_5 = 435;oi_put_1 = 415;oi_put_2 = 400;oi_put_3 = 385;oi_put_4 = 420;oi_put_5 = 380;}else if (GetSymbol() == "TSLA") {total_call_premium = 861299.95;total_put_premium = 3868044.99;oi_call_1 = 1000;oi_call_2 = 1100;oi_call_3 = 1200;oi_call_4 = 950;oi_call_5 = 1050;oi_put_1 = 800;oi_put_2 = 900;oi_put_3 = 700;oi_put_4 = 850;oi_put_5 = 750;}else if (GetSymbol() == "NVDA") {total_call_premium = 142389.07;total_put_premium = 1050267.13;oi_call_1 = 200;oi_call_2 = 210;oi_call_3 = 220;oi_call_4 = 250;oi_call_5 = 240;oi_put_1 = 190;oi_put_2 = 200;oi_put_3 = 180;oi_put_4 = 195;oi_put_5 = 155;}else if (GetSymbol() == "AMD") {total_call_premium = 121653.49;total_put_premium = 639358.85;oi_call_1 = 100;oi_call_2 = 109;oi_call_3 = 90;oi_call_4 = 95;oi_call_5 = 105;oi_put_1 = 85;oi_put_2 = 59;oi_put_3 = 80;oi_put_4 = 75;oi_put_5 = 100;}else {oi_call_1 = Double.NaN;oi_call_2 = Double.NaN;oi_call_3 = Double.NaN;oi_call_4 = Double.NaN;oi_call_5 = Double.NaN;oi_put_1 = Double.NaN;oi_put_2 = Double.NaN;oi_put_3 = Double.NaN;oi_put_4 = Double.NaN;oi_put_5 = Double.NaN;total_call_premium = 0;total_put_premium = 0;};oi_call_1.SetDefaultColor(CreateColor(0,236,59));oi_call_2.SetDefaultColor(CreateColor(0,197,49));oi_call_3.SetDefaultColor(CreateColor(0,158,39));oi_call_4.SetDefaultColor(CreateColor(0,119,29));oi_call_5.SetDefaultColor(CreateColor(0,79,20));oi_call_1.SetLineWeight(5);oi_call_2.SetLineWeight(4);oi_call_3.SetLineWeight(3);oi_call_4.SetLineWeight(2);oi_call_5.SetLineWeight(1);oi_put_1.SetDefaultColor(CreateColor(255,17,17));oi_put_2.SetDefaultColor(CreateColor(255,56,56));oi_put_3.SetDefaultColor(CreateColor(213,0,0));oi_put_4.SetDefaultColor(CreateColor(173,0,0));oi_put_5.SetDefaultColor(CreateColor(134,0,0));oi_put_1.SetLineWeight(5);oi_put_2.SetLineWeight(4);oi_put_3.SetLineWeight(3);oi_put_4.SetLineWeight(2);oi_put_5.SetLineWeight(1);addLabel (total_call_premium, "Calls: $"+ total_call_premium +" | Puts: $"+ total_put_premium, color.LIGHT_GRAY);
Yes, I am a subscriber to his discord. I do use that study but it is not the same as GEX levels. Thanks for sharing tho.
 
Yes, I am a subscriber to his discord. I do use that study but it is not the same as GEX levels. Thanks for sharing tho.

They are completely different from a formula standpoint. However, they re very closely related due to Delta Neutral Dynamic Hedging practiced by the market makers. That makes GEX one of the most important factors in price action besides volume. I coded and mapped the Gex formulas onto TOS charts. We don't share it though, its proprietary after 2.5 years R&D.
 
S/O @halcyonguy for helping me resolve one of the issues with the option expiration being set for Wednesdays not Fridays. I also modified the script for strike width and rounddown for Expd1 feel free to change it back to the old options if you like!

Code:
# Option Volume/Open Interest Indicator
# NPTrading : modified script provided by DeusMecanicus in Post #21
# NPTrading : AsPrice function used to support stock price in 4 digits
# NPTrading : Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") is the option expiry date in format YYMMDD. This Expiry date can be determined automatically (for monthly and weekly options both )but as of now it is manual modification.
# NPTrading : Strike price determined based on current close price but could be previous day close
# NPTrading : Script is work in progress, shared as requested for other to use and modify as per their need
# NPTrading : please read comments in the script
# MountainKing/MK : fixed option code expiry date incompatibility and it seems to be working fine now. Zeros will now appear in single digits of YYMMDD date, and i tried to account for all years/months/day outcomes. Please check for errors due to a lot of copy/paste i may have left a few c's as p's or callstrike as putstrike etc. Tickcount does not seem to be working at this time.



declare lower;


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]<=20 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 close(period=aggregation)[1]>1000 and close(period=aggregation)[1]<=high(period = AggregationPeriod.YEAR) then 1 else 0; #10
#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
#else if pricerange5 then 10
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 = Floor(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(yes, ("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0)));


### putvols #
def putOptionVolume = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionVolume1 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionVolume2 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionVolume3 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionVolume4 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionVolume5 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionVolume6 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionVolume7 =if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionVolume8 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionVolume9 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionVolume10 =if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionVolume11 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionVolume12 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionVolume13 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionVolume14 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionVolume15 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionVolume16 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionVolume17 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionVolume18 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionVolume19 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionVolume20 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));

###Call Option Volume
def callOptionVolume = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 0))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 0));
def callOptionVolume1 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 1))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 1));
def callOptionVolume2 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 2))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 2));
def callOptionVolume3 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 3))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 3));
def callOptionVolume4 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 4))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 4));
def callOptionVolume5 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 5))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 5));
def callOptionVolume6 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 6))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 6));
def callOptionVolume7 =if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 7))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 7));
def callOptionVolume8 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 8))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 8));
def callOptionVolume9 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 9))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 9));
def callOptionVolume10 =if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 10))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 10));
def callOptionVolume11 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 11))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 11));
def callOptionVolume12 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 12))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 12));
def callOptionVolume13 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 13))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 13));
def callOptionVolume14 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 14))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 14));
def callOptionVolume15 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 15))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 15));
def callOptionVolume16 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 16))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 16));
def callOptionVolume17 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 17))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 17));
def callOptionVolume18 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 18))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 18));
def callOptionVolume19 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 19))) then 0 else volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 19));
def callOptionVolume20 = if IsNaN(volume("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike - strikeSpacing * 20))) then 0 else volume("." + 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));


### Put Option tick_count
def putOptiontick_count = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptiontick_count1 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptiontick_count2 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptiontick_count3 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptiontick_count4 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptiontick_count5 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptiontick_count6 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptiontick_count7 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptiontick_count8 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptiontick_count9 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptiontick_count10 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptiontick_count11 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptiontick_count12 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptiontick_count13 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptiontick_count14 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptiontick_count15 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptiontick_count16 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptiontick_count17 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptiontick_count18 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptiontick_count19 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptiontick_count20 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));



####Call Option tick_count
def callOptiontick_count = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else tick_count("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptiontick_count1 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 1))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 1));
def callOptiontick_count2 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 2))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 2));
def callOptiontick_count3 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 3))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 3));
def callOptiontick_count4 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 4))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 4));
def callOptiontick_count5 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 5))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 5));
def callOptiontick_count6 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 6))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 6));
def callOptiontick_count7 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 7))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 7));
def callOptiontick_count8 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 8))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 8));
def callOptiontick_count9 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 9))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 9));
def callOptiontick_count10 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 10))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 10));
def callOptiontick_count11 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 11))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 11));
def callOptiontick_count12 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 12))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 12));
def callOptiontick_count13 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 13))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 13));
def callOptiontick_count14 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 14))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 14));
def callOptiontick_count15 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 15))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 15));
def callOptiontick_count16 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 16))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 16));
def callOptiontick_count17 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 17))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 17));
def callOptiontick_count18 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 18))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 18));
def callOptiontick_count19 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 19))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 19));
def callOptiontick_count20 = if IsNaN(tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 20))) then 0 else tick_count("." + GetSymbol() + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike - strikeSpacing * 20));


def Callvoldef = if !isNan(close) then
((callOptionVolume * callOptionohlc4 * 100) + (callOptionVolume1 * callOptionohlc41 * 100) + (callOptionVolume2 * callOptionohlc42 * 100) + (callOptionVolume3 * callOptionohlc43 * 100) + (callOptionVolume4 * callOptionohlc44 * 100) + (callOptionVolume5 * callOptionohlc45 * 100) + (callOptionVolume6 * callOptionohlc46 * 100) + (callOptionVolume7 * callOptionohlc47 * 100) + (callOptionVolume8 * callOptionohlc48 * 100) + (callOptionVolume9 * callOptionohlc49 * 100) + (callOptionVolume10 * callOptionohlc410 * 100) + (callOptionVolume11 * callOptionohlc411 * 100) + (callOptionVolume12 * callOptionohlc412 * 100) + (callOptionVolume13 * callOptionohlc413 * 100) + (callOptionVolume14 * callOptionohlc414 * 100) + (callOptionVolume15 * callOptionohlc415 * 100) + (callOptionVolume16 * callOptionohlc416 * 100) + (callOptionVolume17 * callOptionohlc417 * 100) + (callOptionVolume18 * callOptionohlc418 * 100) + (callOptionVolume19 * callOptionohlc419 * 100) + (callOptionVolume20 * callOptionohlc420 * 100)) / 1000
else double.nan;
def Putvoldef = if !isNan(close) then
((putOptionVolume * putOptionohlc4 * 100) + (putOptionVolume1 * putOptionohlc41 * 100) + (putOptionVolume2 * putOptionohlc42 * 100) + (putOptionVolume3 * putOptionohlc43 * 100) + (putOptionVolume4 * putOptionohlc44 * 100) + (putOptionVolume5 * putOptionohlc45 * 100) + (putOptionVolume6 * putOptionohlc46 * 100) + (putOptionVolume7 * putOptionohlc47 * 100) + (putOptionVolume8 * putOptionohlc48 * 100) + (putOptionVolume9 * putOptionohlc49 * 100) + (putOptionVolume10 * putOptionohlc410 * 100) + (putOptionVolume11 * putOptionohlc411 * 100) + (putOptionVolume12 * putOptionohlc412 * 100) + (putOptionVolume13 * putOptionohlc413 * 100) + (putOptionVolume14 * putOptionohlc414 * 100) + (putOptionVolume15 * putOptionohlc415 * 100) + (putOptionVolume16 * putOptionohlc416 * 100) + (putOptionVolume17 * putOptionohlc417 * 100) + (putOptionVolume18 * putOptionohlc418 * 100) + (putOptionVolume19 * putOptionohlc419 * 100) + (putOptionVolume20 * putOptionohlc420 * 100)) / 1000
else double.nan;

plot Callvol = if Callvoldef>=0 then Callvoldef else double.nan;
plot Putvol = if Putvoldef>=0 then - Putvoldef else double.nan; #MK made put volume negative

#NPTrading : Rounding to whole number
AddLabel(yes, "Call Volume :" + AsPrice(Round(Callvol*1000,0)), CreateColor(0,120,0));
AddLabel(yes, "Put Volume: " + AsPrice(Round(Putvol*1000, 0)), CreateColor(120,0,0));

#plot Calltick = callOptiontick_count + callOptiontick_count1 + callOptiontick_count2 + callOptiontick_count3 + callOptiontick_count4 + callOptiontick_count5 + callOptiontick_count6 + callOptiontick_count7 + callOptiontick_count8 + callOptiontick_count9 + callOptiontick_count10 + callOptiontick_count11 + callOptiontick_count12 + callOptiontick_count13 + callOptiontick_count14 + callOptiontick_count15 + callOptiontick_count16 + callOptiontick_count17 + callOptiontick_count18 + callOptiontick_count19 + callOptiontick_count20;
#plot Puttick = putOptiontick_count + putOptiontick_count1 + putOptiontick_count2 + putOptiontick_count3 + putOptiontick_count4 + putOptiontick_count5 + putOptiontick_count6 + putOptiontick_count7 + putOptiontick_count8 + putOptiontick_count9 + putOptiontick_count10 + putOptiontick_count11 + putOptiontick_count12 + putOptiontick_count13 + putOptiontick_count14 + putOptiontick_count15 + putOptiontick_count16 + putOptiontick_count17 + putOptiontick_count18 + putOptiontick_count19 + putOptiontick_count20;

#AddLabel(yes, "CallTick :" + Calltick, Color.PLUM);
#AddLabel(yes, "PutTick: " + Puttick, Color.YELLOW);

DefineGlobalColor("CallVolCloud",Color.dark_green);
DefineGlobalColor("PutVolCloud",Color.dark_Red);

Putvol.SetPaintingStrategy(PaintingStrategy.LINE);
Callvol.SetPaintingStrategy(PaintingStrategy.LINE);
Putvol.SetDefaultColor(GlobalColor("PutVolCloud"));
Callvol.SetDefaultColor(GlobalColor("CallVolCloud"));


plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.yellow);


#Diff Cloud ?
#addCloud(Callvol, putvol, GlobalColor("CallVolCloud"), GlobalColor("PutVolCloud"));
#AddCloud(Callvol, Putvol, GlobalColor("CallVolCloud"), GlobalColor("PutVolCloud"));



#individual Cloud ?
AddCloud(Callvol, ZeroLine, GlobalColor("CallVolCloud"), GlobalColor("PutVolCloud"));
AddCloud(Zeroline, putvol, GlobalColor("PutVolCloud"), GlobalColor("CallVolCloud"));


#hull moving averages of putvol and callvol
plot putavg = hullmovingavg(putvol);
putavg.setdefaultcolor(color.orange);
putavg.setstyle(curve.medium_DASH);
plot callavg = hullmovingavg(callvol);
callavg.setdefaultcolor(color.light_green);
callavg.setstyle(curve.medium_DASH);

#MK -- nice little color gradient average
plot avg = average(callvol + putvol);
def colornormlength = 14;
avg.setlineweight(3);
avg.definecolor("Default", Color.yellow);
avg.definecolor("Highest", Color.GREEN);
avg.DefineColor("Lowest", Color.RED);
avg.AssignNormGradientColor(colorNormLength,avg.Color("Lowest"), avg.Color("Highest"));

AddCloud(avg, ZeroLine, color.green, color.red);


#NPTrading : Using PaintingStrategy.LINE_VS_SQUARES for visiblitity
#Puttick.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
#Calltick.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
#Puttick.SetDefaultColor(Color.YELLOW);
#Calltick.SetDefaultColor(Color.PLUM);
#Puttick.Hide(); # added by me
#Calltick.Hide(); # added by me

#NPTrading : ??
#AddCloud(Calltick, Puttick, Color.plum, Color.light_RED);

#NPTrading : ??
#AddCloud(Calltick, ZeroLine, Color.CYAN, Color.RED);
#AddCloud(Puttick, ZeroLine, Color.RED, Color.CYAN);

I'm wondering if this script's labels could be coded to display which option contract has the highest Open-Interest?
 
I had this code downloaded for GEX

Code:
# Gamma Exposure at each strike is calculated by the formula option gamma * open interest * 100 (calls, x-100 for puts)

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();
assignbackgroundcolor(if AbsValue(data) > 2000 then createcolor(250,150,100) else color.black);
data.assignvaluecolor(if AbsValue(data) > 2000 then color.black else color.current);
for some reason this code gives me NaN and no values at all? does this code still works for you?
 
I had this code downloaded for GEX

Code:
# Gamma Exposure at each strike is calculated by the formula option gamma * open interest * 100 (calls, x-100 for puts)

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();
assignbackgroundcolor(if AbsValue(data) > 2000 then createcolor(250,150,100) else color.black);
data.assignvaluecolor(if AbsValue(data) > 2000 then color.black else color.current);
This works very well on the SPX. >2000 will show you where the institutions are trading. But when you go over to SPY you need >100000 to narrow down the max pain or >200000. Can anyone make this code so you could have 3 levels in one column. Say >2000 <100000 and <100000 >200000 and <200000. Right now I have it loaded in 3 columns colored yellow, orange and red. And that works but would be nice to clean up the options chain. I dont trade the SPY but I use the data to figure out what options to sell on the SPX. Maybe @BenTen or @MerryDay ? Any way to do that?

# Gamma Exposure at each strike is calculated by the formula option gamma * open interest * 100 (calls, x-100 for puts)

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();
assignbackgroundcolor(if AbsValue(data) > 2000 then createcolor(255,255,0) else color.black);
data.assignvaluecolor(if AbsValue(data) > 2000 then color.black else color.current);
 
is there an indicator that plots high open interest and high volume strikes as support and resistance levels?

Thanks
Yes "Quant Open Interest" (someone posted it in this forum however... you will need to visit the Quant trading app (discord) every morning as it is updated daily but also shows labels for Total Put Premium: $XX,XXX,XXX Total Call Premium: $X,XXX,XXX - it is only used for the 14 tickers they include on the free version AAPL TSLA SPY etc.)
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
454 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top