Options Vol/Open Interest For ThinkOrSwim

Code:
declare lower;


input aggregation = aggregationperiod.day;
input ShowAllLabels = no;
input Showput  = no;
input Showput1 = no;
input Showput2 = no;
input Showput3 = no;
input Showput4 = no;
input Showput5 = no;
input Showput6 = no;
input Showput7 = no;
input Showput8 = no;
input Showput9 = no;
input Showput10 = no;
input Showput11 = no;
input Showput12 = no;
input Showput13 = no;
input Showput14 = no;
input Showput15 = no;
input Showput16 = no;
input Showput17 = no;
input Showput18 = no;
input Showput19 = no;
input Showput20 = no;

input  Showcall = no;
input  Showcall1 = no;
input  Showcall2 = no;
input  Showcall3 = no;
input  Showcall4 = no;
input  Showcall5 = no;
input  Showcall6 = no;
input  Showcall7 = no;
input  Showcall8 = no;
input  Showcall9 = no;
input  Showcall10 = no;
input  Showcall11 = no;
input  Showcall12 = no;
input  Showcall13 = no;
input  Showcall14 = no;
input  Showcall15 = no;
input  Showcall16 = no;
input  Showcall17 = no;
input  Showcall18 = no;
input  Showcall19 = no;
input  Showcall20 = no;


def pricerange1 = if close(period=aggregation, symbol = "SPX")[1]<=2  then 1 else 0; #.5
def pricerange2 = if close(period=aggregation, symbol = "SPX")[1]>5 and close(period=aggregation)[1]<=150 then 1 else 0; #1
def pricerange3 = if close(period=aggregation, symbol = "SPX")[1]>150 and close(period=aggregation)[1]<=500 then 1  else  0; #2.5
def pricerange4 = if close(period=aggregation, symbol = "SPX")[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, symbol = "SPX");
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, "SPX" + " 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 5
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(symbol = "SPX")/10)*10;
def CallStrike = Floor(close(symbol = "SPX")/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)));


### putvols #
def putOptionVolume = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionVolume1 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionVolume2 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionVolume3 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionVolume4 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionVolume5 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionVolume6 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionVolume7 =if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionVolume8 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionVolume9 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionVolume10 =if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionVolume11 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionVolume12 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionVolume13 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionVolume14 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionVolume15 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionVolume16 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionVolume17 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionVolume18 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionVolume19 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionVolume20 = if IsNaN(volume("." +  "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else volume("." +  "SPXW" + 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("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptionVolume1 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1));
def callOptionVolume2 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2));
def callOptionVolume3 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3));
def callOptionVolume4 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4));
def callOptionVolume5 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5));
def callOptionVolume6 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6));
def callOptionVolume7 =if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7));
def callOptionVolume8 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8));
def callOptionVolume9 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9));
def callOptionVolume10 =if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10));
def callOptionVolume11 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11));
def callOptionVolume12 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12));
def callOptionVolume13 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13));
def callOptionVolume14 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14));
def callOptionVolume15 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15));
def callOptionVolume16 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16));
def callOptionVolume17 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17));
def callOptionVolume18 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18));
def callOptionVolume19 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19));
def callOptionVolume20 = if IsNaN(volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20))) then 0 else volume("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20));


### putOIs #
def putOptionOI =  if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionOI1 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionOI2 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionOI3 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionOI4 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionOI5 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionOI6 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionOI7 =if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionOI8 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionOI9 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionOI10 =if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionOI11 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionOI12 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionOI13 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionOI14 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionOI15 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionOI16 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionOI17 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionOI18 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionOI19 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionOI20 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else open_interest("." + "SPXW" + 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("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptionOI1 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1));
def callOptionOI2 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2));
def callOptionOI3 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3));
def callOptionOI4 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4));
def callOptionOI5 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5));
def callOptionOI6 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6));
def callOptionOI7 =if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7));
def callOptionOI8 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8));
def callOptionOI9 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9));
def callOptionOI10 =if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10));
def callOptionOI11 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11));
def callOptionOI12 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12));
def callOptionOI13 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13));
def callOptionOI14 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14));
def callOptionOI15 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15));
def callOptionOI16 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16));
def callOptionOI17 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17));
def callOptionOI18 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18));
def callOptionOI19 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19))) then 0 else open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19));
def callOptionOI20 = if IsNaN(open_interest("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20))) then 0 else open_interest("." + "SPXW" + 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("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionohlc41 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionohlc42 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionohlc43 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else ohlc4("." + “SPXW” + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionohlc44 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionohlc45 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionohlc46 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionohlc47 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionohlc48 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionohlc49 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionohlc410 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionohlc411 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionohlc412 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionohlc413 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionohlc414 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionohlc415 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionohlc416 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionohlc417 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionohlc418 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else ohlc4("." + “SPXW” + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionohlc419 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionohlc420 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else ohlc4("." + "SPXW" + 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("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 0))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 0));
def callOptionohlc41 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 1))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 1));
def callOptionohlc42 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 2))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 2));
def callOptionohlc43 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 3))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 3));
def callOptionohlc44 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 4))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 4));
def callOptionohlc45 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 5))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 5));
def callOptionohlc46 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 6))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 6));
def callOptionohlc47 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 7))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 7));
def callOptionohlc48 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 8))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 8));
def callOptionohlc49 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 9))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 9));
def callOptionohlc410 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 10))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 10));
def callOptionohlc411 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 11))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 11));
def callOptionohlc412 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 12))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 12));
def callOptionohlc413 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 13))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 13));
def callOptionohlc414 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 14))) then 0 else ohlc4("." + “SPXW” + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 14));
def callOptionohlc415 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 15))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 15));
def callOptionohlc416 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 16))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 16));
def callOptionohlc417 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 17))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 17));
def callOptionohlc418 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 18))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 18));
def callOptionohlc419 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 19))) then 0 else ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 19));
def callOptionohlc420 = if IsNaN(ohlc4("." + "SPXW" + Concat((ExpY1),"") + Concat((ExpY2),"") + Concat((ExpM1),"") + Concat((ExpM2),"") + Concat((ExpD1),"") + Concat((ExpD2),"") + "C" + AsPrice(callStrike + strikeSpacing * 20))) then 0 else ohlc4("." + "SPXW" + 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;

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 Callvol = if Callvoldef>=0 then Callvoldef else double.nan;
def Putvol = if Putvoldef>=0 then Putvoldef else double.nan; #MK made put volume negative
def putratio = putvol/putoi;
def callratio = callvol/calloi;
def MS = (putratio/callratio);
def OIRatio = (putoi/calloi);
def VolRatio = (putvol/callvol);

#NPTrading : Rounding to whole number
#AddLabel(yes, "Total OI :" + (AsPrice(Round(calloi*1000,0))+ AsPrice(Round(putoi*1000, 0))) + " | " + AsPercent(((calloi+putoi)-(calloi[1]+putoi[1]))/(calloi[1]+putoi[1])),Color.GRAY) ;
#AddLabel(yes, "Total Vol :" + (AsPrice(Round(callvol*1000,0))+ AsPrice(Round(putvol*1000, 0))) + " | " + AsPercent(((callvol+putvol)-(callvol[1]+putvol[1]))/(callvol[1]+putvol[1])),Color.GRAY) ;
#AddLabel(yes, "Call OI :" + AsPrice(Round(calloi*1000,0)) + " | " + AsPercent((calloi-calloi[1])/calloi[1]),CreateColor(0,120,0));
#AddLabel(yes, "Put OI: " + AsPrice(Round(putoi*1000, 0)) + " | " + AsPercent((putoi-putoi[1])/calloi[1]), CreateColor(120,0,0));
#AddLabel(yes, "Call Volume :" + AsPrice(Round(Callvol*1000,0)) + " | " + AsPercent((callvol-callvol[1])/callvol[1]), CreateColor(0,120,0));
#AddLabel(yes, "Put Volume: " + AsPrice(Round(Putvol*1000, 0)) + " | " + AsPercent((putvol-putvol[1])/putvol[1]), CreateColor(120,0,0)) ;
AddLabel(yes, "MS:" + MS, color = Color.CYAN);
AddLabel(yes, "OI Ratio:" + OIRatio, color = Color.CYAN);
AddLabel(yes, "Vol Ratio:" + Volratio, color = Color.CYAN);


####Show Individual Put Volume Labels
AddLabel(Showput    or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 0) + ":  " + putOptionVolume +  " | " + putoptionoi +  " | " + Aspercent((putoptionoi-putoptionoi[1])/putoptionoi[1]));
AddLabel(Showput1   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 1) + ":  " + putOptionVolume1 +  " | " + putoptionoi1  +  " | " + Aspercent((putoptionoi1-putoptionoi1[1])/putoptionoi1[1]));
AddLabel(Showput2   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 2) + ":  " + putOptionVolume2 +  " | " + putoptionoi2  +  " | " + Aspercent((putoptionoi2-putoptionoi2[1])/putoptionoi2[1]));
AddLabel(Showput3   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 3) + ":  " + putOptionVolume3 +  " | " + putoptionoi3  +  " | " + Aspercent((putoptionoi3-putoptionoi3[1])/putoptionoi3[1]));
AddLabel(Showput4   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 4) + ":  " + putOptionVolume4 +  " | " + putoptionoi4  +  " | " + Aspercent((putoptionoi4-putoptionoi4[1])/putoptionoi4[1]));
AddLabel(Showput5   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 5) + ":  " + putOptionVolume5 +  " | " + putoptionoi5  +  " | " + Aspercent((putoptionoi5-putoptionoi5[1])/putoptionoi5[1]));
AddLabel(Showput6   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 6) + ":  " + putOptionVolume6 +  " | " + putoptionoi6  +  " | " + Aspercent((putoptionoi6-putoptionoi6[1])/putoptionoi6[1]));
AddLabel(Showput7   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 7) + ":  " + putOptionVolume7 +  " | " + putoptionoi7  +  " | " + Aspercent((putoptionoi7-putoptionoi7[1])/putoptionoi7[1]));
AddLabel(Showput8   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 8) + ":  " + putOptionVolume8 +  " | " + putoptionoi8  +  " | " + Aspercent((putoptionoi8-putoptionoi8[1])/putoptionoi8[1]));
AddLabel(Showput9   or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 9) + ":  " + putOptionVolume9 +  " | " + putoptionoi9  +  " | " + Aspercent((putoptionoi9-putoptionoi9[1])/putoptionoi9[1]));
AddLabel(Showput10  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 10) + ":  " + putOptionVolume10 +  " | " + putoptionoi10  +  " | " + Aspercent((putoptionoi10-putoptionoi10[1])/putoptionoi10[1]));
AddLabel(Showput11  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 11) + ":  " + putOptionVolume11 +  " | " + putoptionoi11  +  " | " + Aspercent((putoptionoi11-putoptionoi11[1])/putoptionoi11[1]));
AddLabel(Showput12  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 12) + ":  " + putOptionVolume12 +  " | " + putoptionoi12  +  " | " + Aspercent((putoptionoi12-putoptionoi12[1])/putoptionoi12[1]));
AddLabel(Showput13  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 13) + ":  " + putOptionVolume13 +  " | " + putoptionoi13  +  " | " + Aspercent((putoptionoi13-putoptionoi13[1])/putoptionoi13[1]));
AddLabel(Showput14  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 14) + ":  " + putOptionVolume14 +  " | " + putoptionoi14  +  " | " + Aspercent((putoptionoi14-putoptionoi14[1])/putoptionoi14[1]));
AddLabel(Showput15  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 15) + ":  " + putOptionVolume15 +  " | " + putoptionoi15  +  " | " + Aspercent((putoptionoi15-putoptionoi15[1])/putoptionoi15[1]));
AddLabel(Showput16  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 16) + ":  " + putOptionVolume16 +  " | " + putoptionoi16  +  " | " + Aspercent((putoptionoi16-putoptionoi16[1])/putoptionoi16[1]));
AddLabel(Showput17  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 17) + ":  " + putOptionVolume17 +  " | " + putoptionoi17  +  " | " + Aspercent((putoptionoi17-putoptionoi17[1])/putoptionoi17[1]));
AddLabel(Showput18  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 18) + ":  " + putOptionVolume18 +  " | " + putoptionoi18  +  " | " + Aspercent((putoptionoi18-putoptionoi18[1])/putoptionoi18[1]));
AddLabel(Showput19  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 19) + ":  " + putOptionVolume19 +  " | " + putoptionoi19  +  " | " + Aspercent((putoptionoi19-putoptionoi19[1])/putoptionoi19[1]));
AddLabel(Showput20  or ShowAllLabels, "P" + AsPrice(PutStrike  - strikeSpacing * 20) + ":  " + putOptionVolume20 +  " | " + putoptionoi20  +  " | " + Aspercent((putoptionoi20-putoptionoi20[1])/putoptionoi20[1]));


#Show Individual Call Volume Labels
AddLabel(Showcall   or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 0) + ":  " + callOptionVolume +  " | " + calloptionoi  +  " | " + Aspercent((calloptionoi-calloptionoi[1])/calloptionoi[1]),Color.CYAN);
AddLabel(Showcall1  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 1) + ":  " + callOptionVolume1 +  " | " + calloptionoi1  +  " | " + Aspercent((calloptionoi1-calloptionoi1[1])/calloptionoi1[1]),Color.CYAN);
AddLabel(Showcall2  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 2) + ":  " + callOptionVolume2 +  " | " + calloptionoi2  +  " | " + Aspercent((calloptionoi2-calloptionoi2[1])/calloptionoi2[1]),Color.CYAN);
AddLabel(Showcall3  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 3) + ":  " + callOptionVolume3 +  " | " + calloptionoi3  +  " | " + Aspercent((calloptionoi3-calloptionoi3[1])/calloptionoi3[1]),Color.CYAN);
AddLabel(Showcall4  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 4) + ":  " + callOptionVolume4 +  " | " + calloptionoi4  +  " | " + Aspercent((calloptionoi4-calloptionoi4[1])/calloptionoi4[1]),Color.CYAN);
AddLabel(Showcall5  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 5) + ":  " + callOptionVolume5 +  " | " + calloptionoi5  +  " | " + Aspercent((calloptionoi5-calloptionoi5[1])/calloptionoi5[1]),Color.CYAN);
AddLabel(Showcall6  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 6) + ":  " + callOptionVolume6 +  " | " + calloptionoi6  +  " | " + Aspercent((calloptionoi6-calloptionoi6[1])/calloptionoi6[1]),Color.CYAN);
AddLabel(Showcall7  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 7) + ":  " + callOptionVolume7 +  " | " + calloptionoi7  +  " | " + Aspercent((calloptionoi7-calloptionoi7[1])/calloptionoi7[1]),Color.CYAN);
AddLabel(Showcall8  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 8) + ":  " + callOptionVolume8 +  " | " + calloptionoi8  +  " | " + Aspercent((calloptionoi8-calloptionoi8[1])/calloptionoi8[1]),Color.CYAN);
AddLabel(Showcall9  or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 9) + ":  " + callOptionVolume9 +  " | " + calloptionoi9  +  " | " + Aspercent((calloptionoi9-calloptionoi9[1])/calloptionoi9[1]),Color.CYAN);
AddLabel(Showcall10 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 10) + ":  " + callOptionVolume10 +  " | " + calloptionoi10  +  " | " + Aspercent((calloptionoi10-calloptionoi10[1])/calloptionoi10[1]),Color.CYAN);
AddLabel(Showcall11 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 11) + ":  " + callOptionVolume11 +  " | " + calloptionoi11  +  " | " + Aspercent((calloptionoi11-calloptionoi11[1])/calloptionoi11[1]),Color.CYAN);
AddLabel(Showcall12 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 12) + ":  " + callOptionVolume12 +  " | " + calloptionoi12  +  " | " + Aspercent((calloptionoi12-calloptionoi12[1])/calloptionoi12[1]),Color.CYAN);
AddLabel(Showcall13 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 13) + ":  " + callOptionVolume13 +  " | " + calloptionoi13  +  " | " + Aspercent((calloptionoi13-calloptionoi13[1])/calloptionoi13[1]),Color.CYAN);
AddLabel(Showcall14 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 14) + ":  " + callOptionVolume14 +  " | " + calloptionoi14  +  " | " + Aspercent((calloptionoi14-calloptionoi14[1])/calloptionoi14[1]),Color.CYAN);
AddLabel(Showcall15 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 15) + ":  " + callOptionVolume15 +  " | " + calloptionoi15  +  " | " + Aspercent((calloptionoi15-calloptionoi15[1])/calloptionoi15[1]),Color.CYAN);
AddLabel(Showcall16 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 16) + ":  " + callOptionVolume16 +  " | " + calloptionoi16  +  " | " + Aspercent((calloptionoi16-calloptionoi16[1])/calloptionoi16[1]),Color.CYAN);
AddLabel(Showcall17 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 17) + ":  " + callOptionVolume17 +  " | " + calloptionoi17  +  " | " + Aspercent((calloptionoi17-calloptionoi17[1])/calloptionoi17[1]),Color.CYAN);
AddLabel(Showcall18 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 18) + ":  " + callOptionVolume18 +  " | " + calloptionoi18  +  " | " + Aspercent((calloptionoi18-calloptionoi18[1])/calloptionoi18[1]),Color.CYAN);
AddLabel(Showcall19 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 19) + ":  " + callOptionVolume19 +  " | " + calloptionoi19  +  " | " + Aspercent((calloptionoi19-calloptionoi19[1])/calloptionoi19[1]),Color.CYAN);
AddLabel(Showcall20 or ShowAllLabels, "C" + AsPrice(CallStrike + strikeSpacing * 20) + ":  " + callOptionVolume20 +  " | " + calloptionoi20  +  " | " + Aspercent((calloptionoi20-calloptionoi20[1])/calloptionoi20[1]),Color.CYAN);
Does anyone know how to adjust the options volume to display options premium instead? For example instead of 1000 contracts traded at a certain time, I want to know the value of those contracts. So in essence the dollar calculation of the volume.
@s1111 @SCALPER @halcyonguy
 
Last edited:
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.
OMG!!!! What you just said about GEX relative to price was the part I was missing. I have been back testing all morning. I can't figure out the TOS script but that is OK since I have it all in excel. You can actually do a lot more in excel with it anyways. I tested FOMC days and CPI report number days and OMG!!!! Before the numbers come out I am able to know the direction. This is crazy. Thank you....not sure if you know it or not but you just changed my life!!!!
 
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?
Yes. There is one that shows 2 calls and 2 puts levels on the candle chart with bubbles showing Price of the options and OI. I will have to share it when I get home but if you search something like “options on chart” you should find it.
 
OMG!!!! What you just said about GEX relative to price was the part I was missing. I have been back testing all morning. I can't figure out the TOS script but that is OK since I have it all in excel. You can actually do a lot more in excel with it anyways. I tested FOMC days and CPI report number days and OMG!!!! Before the numbers come out I am able to know the direction. This is crazy. Thank you....not sure if you know it or not but you just changed my life!!!!
can u share how u are doing it? & what gex formula are u using?
 
OMG!!!! What you just said about GEX relative to price was the part I was missing. I have been back testing all morning. I can't figure out the TOS script but that is OK since I have it all in excel. You can actually do a lot more in excel with it anyways. I tested FOMC days and CPI report number days and OMG!!!! Before the numbers come out I am able to know the direction. This is crazy. Thank you....not sure if you know it or not but you just changed my life!!!!
could you possibly share this information. I need help
 
Ratio Open Interest to Volume Percentage Change Column for ThinkorSwim

Volume is 2 times great than the Open Interest -- OI

THIS ONLY WORKS CORRECTLY AS A OPTION CHAIN COLUMN

Appreciation goes a long way... if you like my work or you found this post useful be sure to hit the like button to keep me motivated

yWmxqUQ.png


Code:
####Please Keep Code Intact if you share#######
##volume is 2 times greater than the OI COLUMN
##NOTE: IT ONLY WORKS AS A OPTION CHAIN COLUMN
def x2 = (volume > open_interest*2);
def x = (volume / open_interest)*100;
AddLabel(yes,  + Round(x , 0) + "%",color.black);
assignBackgroundColor (if x2 then color.orange  else color.black);
#######################################
#######By XeoNoX via usethinkscript.com#######
#######################################
I love this, thanks. Is there a way to use the IF function to eliminate lines that have N/A in the volume? It generates an erroneously high number.
 
OMG!!!! What you just said about GEX relative to price was the part I was missing. I have been back testing all morning. I can't figure out the TOS script but that is OK since I have it all in excel. You can actually do a lot more in excel with it anyways. I tested FOMC days and CPI report number days and OMG!!!! Before the numbers come out I am able to know the direction. This is crazy. Thank you....not sure if you know it or not but you just changed my life!!!!
Hi Bro, Can you please share your excel sheet? Thanks!

ATkJjlY.png


Lots of interest at $86 and $87 levels
Bro, Can you please share TOS script shown on screen shot?
 
hi , could not find this script , can you please share if you have the code.
https://usethinkscript.com/threads/options-vol-open-interest-for-thinkorswim.313/page-5#post-46520
The script is in the link that you included in your post.
Here is it again:
Ruby:
####Please Keep Code Intact if you share#######
##volume is 2 times greater than the OI COLUMN
##NOTE: IT ONLY WORKS AS A OPTION CHAIN COLUMN
def x2 = (volume > open_interest*2);
def x = (volume / open_interest)*100;
AddLabel(yes,  + Round(x , 0) + "%",color.black);
assignBackgroundColor (if x2 then color.orange  else color.black);
#######################################
#######By XeoNoX via usethinkscript.com#######
#######################################
 
This code, i believe, is coded for monthly & quarterly options. It is posted here for experimental purposes.

Code:
# Option Prices At Close with Open Interest Intraday Charts Only
# Mobius
# V01.03.2017

declare hide_on_daily;

input series = 1;
input show_All_labels = yes;

Assert(series > 0, "'series' must be positive: " + series);

def c = close;
def interest_rate = GetInterestRate();
def yield = GetYield() * 4;
def iv;
if GetAggregationPeriod() < AggregationPeriod.DAY {
    iv = imp_volatility(period = AggregationPeriod.DAY);
} else {
    iv = imp_volatility();
}

def CurrentYear = GetYear();
def CurrentMonth = GetMonth();
def CurrentDOM = GetDayOfMonth(GetYYYYMMDD());
def Day1DOW1 = GetDayOfWeek(CurrentYear * 10000 + CurrentMonth * 100 + 1);
def FirstFridayDOM1 = if Day1DOW1 < 6
                      then 6 - Day1DOW1
                      else if Day1DOW1 == 6
                           then 7
                           else 6;

def RollDOM = FirstFridayDOM1 + 14;
def ExpMonth1 = if RollDOM > CurrentDOM
                then CurrentMonth + series - 1
                else CurrentMonth + series;
def ExpMonth2 = if ExpMonth1 > 12
                then ExpMonth1 - 12
                else ExpMonth1;
def ExpYear = if ExpMonth1 > 12
              then CurrentYear + 1
              else CurrentYear;
def Day1DOW = GetDayOfWeek(ExpYear * 10000 + ExpMonth2 * 100 + 1);
def FirstFridayDOM = if Day1DOW < 6
                     then 6 - Day1DOW
                     else if Day1DOW == 6
                          then 7
                          else 6;
def ExpDOM = FirstFridayDOM + 14;
def N3rdF = DaysTillDate(ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM);
def OptionDateString = ExpYear * 10000 + ExpMonth2 * 100 + ExpDOM + 1;
Addlabel(1, "Options Expy. Date: " + ExpMonth2 + "/" + ExpDOM + "/" + AsPrice(ExpYear), color.white);

# Strike Plots
plot Strike = HighestAll(if IsNaN(c[-1])
                         then Round(c, 0)
                         else Double.NaN);
Strike.SetDefaultColor(Color.CYAN);
plot OTM_1_Strike = HighestAll(if IsNaN(c[-1])
                               then Round(c, 0) - 1
                               else Double.NaN);
OTM_1_Strike.SetDefaultColor(Color.CYAN);
plot OTM_2_Strike = HighestAll(if IsNaN(c[-1])
                               then Round(c, 0) - 2
                               else Double.NaN);

OTM_2_Strike.SetDefaultColor(Color.CYAN);
plot ITM_1_Strike = HighestAll(if IsNaN(c[-1])
                               then Round(c, 0) + 1
                               else Double.NaN);

ITM_1_Strike.SetDefaultColor(Color.CYAN);
plot ITM_2_Strike = HighestAll(if IsNaN(c[-1])
                               then Round(c, 0) + 2
                               else Double.NaN);

ITM_2_Strike.SetDefaultColor(Color.CYAN);

# At The Money
def ATMTheoC = OptionPrice(Strike, 0, N3rdF, c, iv, 0, yield, interest_rate);
def ATM_CALL = if IsNaN(ATMTheoC)
               then ATM_CALL[1]
               else ATMTheoC;

def ATM_OI_C = open_interest(GetATMOption(GetUnderlyingSymbol(), OptionDateString, OptionClass.CALL), period = AggregationPeriod.DAY);

def ATMOIC = if IsNaN(ATM_OI_C)
             then ATMOIC[1]
             else ATM_OI_C;

def ATMTheoP = OptionPrice(Strike, 1, N3rdF, c, iv, 0, yield, interest_rate);
def ATM_PUT = if IsNaN(ATMTheoP)
              then ATM_PUT[1]
              else ATMTheoP;

def ATM_OI_P = open_interest(GetATMOption(GetUnderlyingSymbol(), OptionDateString, OptionClass.PUT), period = AggregationPeriod.DAY);

def ATMOIP = if IsNaN(ATM_OI_P)
             then ATMOIP[1]
             else ATM_OI_P;

def bubbleLocation = IsNaN(c[2]) and !IsNaN(c[3]);
AddChartBubble(bubbleLocation, Strike, "CALL = " +
               AsDollars(ATM_CALL) +

            "  OI = " +

               ATMOIC +

              "\nPUT    = " + AsDollars(ATM_PUT) +

            "  OI = " + ATMOIP,

               Color.CYAN,

               if c > Strike

               then 0

               else 1);

# $1.00 Out Of The Money

def OTM_1_TheoC = OptionPrice(OTM_1_Strike, 0, N3rdF, c, iv, 0, yield, interest_rate);

def OTM_1_CALL = if IsNaN(OTM_1_TheoC)
                 then OTM_1_CALL[1]
                 else OTM_1_TheoC;

def OTM_OI_C = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "C" + OTM_1_Strike, period = AggregationPeriod.DAY);

def OTMOIC = if IsNaN(OTM_OI_C)
             then OTMOIC[1]
             else OTM_OI_C;

def OTM_1_TheoP = OptionPrice(OTM_1_Strike, 1, N3rdF, c, iv, 0, yield, interest_rate);

def OTM_1_PUT = if IsNaN(OTM_1_TheoP)
                then OTM_1_PUT[1]
                else OTM_1_TheoP;

def OTM_OI_P = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "P" + OTM_1_Strike, period = AggregationPeriod.DAY);

def OTMOIP = if IsNaN(OTM_OI_P)
             then OTMOIP[1]
             else OTM_OI_P;

AddChartBubble(bubbleLocation, OTM_1_Strike, "CALL = " +

               AsDollars(OTM_1_CALL) +
           "   OI = " + OTMOIC +
              "\nPUT    = " + AsDollars(OTM_1_PUT) +
           "   OI = " + OTMOIP,
               Color.CYAN,
               if c > OTM_1_Strike
               then 0
               else 1);

# $2.00 Out Of The Money

def OTM_2_TheoC = OptionPrice(OTM_2_Strike, 0, N3rdF, c, iv, 0, yield, interest_rate);

def OTM_2_CALL = if IsNaN(OTM_2_TheoC)
                 then OTM_2_CALL[1]
                 else OTM_2_TheoC;

def OTM2_OI_C = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "C" + OTM_2_Strike, period = AggregationPeriod.DAY);

def OTMOIC2 = if IsNaN(OTM2_OI_C)
             then OTMOIC2[1]
             else OTM2_OI_C;

def OTM_2_TheoP = OptionPrice(OTM_2_Strike, 1, N3rdF, c, iv, 0, yield, interest_rate);

def OTM_2_PUT = if IsNaN(OTM_2_TheoP)
                then OTM_2_PUT[1]
                else OTM_2_TheoP;

def OTM2_OI_P = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "P" + OTM_2_Strike, period = AggregationPeriod.DAY);

def OTMOIP2 = if IsNaN(OTM2_OI_P)
             then OTMOIP2[1]
             else OTM2_OI_P;

AddChartBubble(bubbleLocation, OTM_2_Strike, "CALL = " +

               AsDollars(OTM_2_CALL) +

           "   OI = " + OTMOIC2 +

              "\nPUT    = " + AsDollars(OTM_2_PUT) +

           "   OI = " + OTMOIP2,

               Color.CYAN,

               if c > OTM_2_Strike

               then 0

               else 1);

# $1.00 In The Money
def ITM_1_TheoC = OptionPrice(ITM_1_Strike, 0, N3rdF, c, iv, 0, yield, interest_rate);

def ITM_1_CALL = if IsNaN(ITM_1_TheoC)
                 then ITM_1_CALL[1]
                 else ITM_1_TheoC;

def ITM_OI_C = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "C" + ITM_1_Strike, period = AggregationPeriod.DAY);

def ITMOIC = if IsNaN(ITM_OI_C)
             then ITMOIC[1]
             else ITM_OI_C;

def ITM_1_TheoP = OptionPrice(ITM_1_Strike, 1, N3rdF, c, iv, 0, yield, interest_rate);

def ITM_1_PUT = if IsNaN(ITM_1_TheoP)
                then ITM_1_PUT[1]
                else ITM_1_TheoP;

def ITM_OI_P = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "P" + ITM_1_Strike, period = AggregationPeriod.DAY);

def ITMOIP = if IsNaN(ITM_OI_P)
             then ITMOIP[1]
             else ITM_OI_P;

AddChartBubble(bubbleLocation, ITM_1_Strike, "CALL = " +

               AsDollars(ITM_1_CALL) +

            "  OI = " + ITMOIC +

              "\nPUT    = " + AsDollars(ITM_1_PUT) +

            "  OI = " + ITMOIP,

               Color.CYAN,

               if Strike > ITM_1_Strike

               then 0

               else 1);

# $2.00 In The Money
def ITM_2_TheoC = OptionPrice(ITM_2_Strike, 0, N3rdF, c, iv, 0, yield, interest_rate);

def ITM_2_CALL = if IsNaN(ITM_2_TheoC)
                 then ITM_2_CALL[1]
                 else ITM_2_TheoC;

def ITM2_OI_C = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "C" + ITM_2_Strike, period = AggregationPeriod.DAY);

def ITMOIC2 = if IsNaN(ITM2_OI_C)
             then ITMOIC2[1]
             else ITM2_OI_C;

def ITM_2_TheoP = OptionPrice(ITM_2_Strike, 1, N3rdF, c, iv, 0, yield, interest_rate);

def ITM_2_PUT = if IsNaN(ITM_2_TheoP)
                then ITM_2_PUT[1]
                else ITM_2_TheoP;

def ITM2_OI_P = open_interest("." + GetUnderlyingSymbol() + (Expyear-2000) + (if Expmonth2 < 10 then 0 else double.nan) + (ExpMonth2) + (N3rdF) + "P" + ITM_2_Strike, period = AggregationPeriod.DAY);

def ITMOIP2 = if IsNaN(ITM2_OI_P)
             then ITMOIP2[1]
             else ITM2_OI_P;

AddChartBubble(bubbleLocation, ITM_2_Strike, "CALL = " +

               AsDollars(ITM_2_CALL) +

            "  OI = " + ITMOIC2 +

              "\nPUT    = " + AsDollars(ITM_2_PUT) +

            "  OI = " + ITMOIP2,

               Color.CYAN,

               if Strike > ITM_2_Strike

               then 0

               else 1);
# End Code Option Prices and Open interest


Today I try on DUOL, the blue bubble it shows Call= $5.13, OI=166 (It means there is 166 open interest at price $5.13 ) but when I flip to trade option tab, nothing matching the data. the closes is $4.40 with 166 open interest, ) also why not display $15.90 with 286 open interest?(since 286 open interest are the largest number?
 

Attachments

  • Screenshot 2023-09-02 174534.DUOL.OPTION.png
    Screenshot 2023-09-02 174534.DUOL.OPTION.png
    166.8 KB · Views: 423
  • Screenshot 2023-09-02 174733.DUOL.2.png
    Screenshot 2023-09-02 174733.DUOL.2.png
    998.2 KB · Views: 417
Last edited by a moderator:
Ratio Open Interest to Volume Percentage Change Column for ThinkorSwim

Volume is 2 times great than the Open Interest -- OI

THIS ONLY WORKS CORRECTLY AS A OPTION CHAIN COLUMN

Appreciation goes a long way... if you like my work or you found this post useful be sure to hit the like button to keep me motivated

View attachment 8900

Code:
####Please Keep Code Intact if you share#######
##volume is 2 times greater than the OI COLUMN
##NOTE: IT ONLY WORKS AS A OPTION CHAIN COLUMN
def x2 = (volume > open_interest*2);
def x = (volume / open_interest)*100;
AddLabel(yes,  + Round(x , 0) + "%",color.black);
assignBackgroundColor (if x2 then color.orange  else color.black);
#######################################
#######By XeoNoX via usethinkscript.com#######
#######################################
@XeoNoX what is this actually telling you and how are you using this in your trading? From looking at it I'm assuming you see where the most OI is per contract🤷🏿‍♂️
 
Today I try on DUOL, the blue bubble it shows Call= $5.13, OI=166 (It means there is 166 open interest at price $5.13 ) but when I flip to trade option tab, nothing matching the data. the closes is $4.40 with 166 open interest, ) also why not display $15.90 with 286 open interest?(since 286 open interest are the largest number?
did you managed to make this indicator work properly? thanks
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
296 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