# Options Vol/Open Interest For ThinkOrSwim

@Tiredoflosing

# Show SELL and BUY Volume and percentage.
# Nomak 02/21/2020

declare upper;
input timeframe = AggregationPeriod.DAY;

def Vol = volume(period = timeframe);
def at_High = high(period = timeframe);
def at_Open = open(period = timeframe);
def at_Close = close(period = timeframe);
def at_Low = low(period = timeframe);
def Vol1 = volume(period = timeframe);
def at_High1 = high(period = timeframe);
def at_Open1 = open(period = timeframe);
def at_Close1 = close(period = timeframe);
def at_Low1 = low(period = timeframe);

# Buy_Volume forumla is volume * (close_price minus low_price) / (High_price minus low_price)
def Buy_Volume = roundup(Vol * (at_close - at_low) / (at_High - at_Low));

#Sell_Volume forumla is volume * (High_price minus Close_price) / (High_price minus Low_price)
def Sell_Volume = rounddown(Vol1 * (at_High1 - at_Close1) / (at_High1 - at_low1));
def Sell_percent = roundup((Sell_Volume / Vol1) * 100);

Addlabel(yes, "SellVol " + Sell_Volume, Color.Red);
Addlabel(yes, "Sell % " + Sell_percent, Color.Red);

My take: ITM/ATM call/put volume is useless, because it doesn't really tell us anything that we souldn't already know. We KNOW that there is going to be X amount of volume at those strikes. The real place de resistance will be the OTM call/put volume, because as the delta and the gamma of those change, it will effect how dealers have to hedge. For example, if there is LOTS of hedging (or short bets) on OTM puts on SPY and price goes up/IV goes down that will cause dealer hedging to buy the underlying in SPY...

Moreover, OTM puts ARE the biggest option flow.
Joe, I figured out how to plot Gamma Exposure levels on the upper chart, but there still is no good option chain scanner that catches all the Gamma and the OI for each strike. If you know of one, I'd love to hack it apart. Problem with Thinkscript is the Recursion and Fold functions chew up garbage collection in Java and max out even the best processors.

Saw someone on twitter had made an indicator that plots option open interest per strike at their respective price levels on the chart (here are 2 pics of what I assume are 2 different versions) I was wondering if anyone here has the code for this? If anyone knows how to make this that would also be greatly appreciated.

Last edited:
I think its nothing but Volume Profile with different approach ... to get the job done plot volume profile on daily chart and compare, I think you would find the same values .....
they import higher aggregation period to daily to plot it .... so the interest range is spread out ... and showing all highest / lowest (accordingly) volume traded in that price range as interest ....
It's likely a volume or data profile, but those are tricky to format, and worse yet, the option chain data is difficult to collect. Knowing the twitter user would be nice. The OI is a daily stat, so its the same regardless of aggregation period.

Thats awesome! so can that be translated to look like this? Screenshot here only way I know to add. https://prnt.sc/tsuwg3
I've tinkered and played with the concat and asprice and still can't get this to plot with Fold.

Joe, I figured out how to plot Gamma Exposure levels on the upper chart, but there still is no good option chain scanner that catches all the Gamma and the OI for each strike. If you know of one, I'd love to hack it apart. Problem with Thinkscript is the Recursion and Fold functions chew up garbage collection in Java and max out even the best processors.
are u looking for something like this?

This works:
def c1_OI_d = close(".SPX211119C4680");

but this does not return any value:, any ideas why is not working?
def c1_OI_d = open_interest(".SPX211119C4680");

.

Last edited:
does anyone know of a way to plot if an option call or put is being sold or purchased on TOS?
For example
Puts traded at Bid = Green

Calls traded at bid = Red

Currently, it's only plotting based on Calls or puts but that's not very helpful since we need to know which side is the transaction on.
The OP states that "The volume data is not raw order data" so it is no other details are available.

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

plot data = if IsPut() then gamma() * -100 * open_interest() else gamma() * 100 * open_interest();
assignbackgroundcolor(if AbsValue(data) > 2000 then createcolor(250,150,100) else color.black);
data.assignvaluecolor(if AbsValue(data) > 2000 then color.black else color.current);``````

does anyone know of a way to plot if an option call or put is being sold or purchased on TOS?
For example
Puts traded at Bid = Green

Calls traded at bid = Red

Currently, it's only plotting based on Calls or puts but that's not very helpful since we need to know which side is the transaction on.

Last edited:
does anyone know of a way to plot if an option call or put is being sold or purchased on TOS?
For example
Puts traded at Bid = Green

Calls traded at bid = Red

Currently, it's only plotting based on Calls or puts but that's not very helpful since we need to know which side is the transaction on.

Sadly, TOS does not differentiate or split the buy/sell quote in two by transaction. You get the whole bid/ask quote and the volume of the transaction, but not how many were at bought/sold at bid nor at ask. There might be other platforms that do this, but TOS does not.

Sorry, I'm not sure. I use this script for volume buy-sell these days
where do i input that, in edit studies? as an idicator on my chart?

where do i input that, in edit studies? as an idicator on my chart?
Yes .

Hi all, I did try to automate the selection of the options expiration date for weekly contracts using the concat function. After I did it, it was working! But now that it's a new week, it's not working anymore. So it was automatically choosing the right date but only during that week, not in subsequent weeks. Hoping that the problem is simple and someone with a better understanding of the logic can point out how to fix it. It would be a nice QOL and convenience feature if this can be fixed, because I was enjoying being able to use it the other week without having to manually input the contract date. Here is the code I have (please note that some of the stuff in the original study was pruned out, but the same solution for this code would fully apply for the original version of the study):

Code:
``````# Option Volume/Open Interest Indicator
# NPTrading : modified script provided by DeusMecanicus in Post #21
# NPTrading : AsPrice function used to support stock price in 4 digits
# NPTrading : Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") is the option expiry date in format YYMMDD.  This Expiry date can be determined automatically (for monthly and weekly options both )but as of now it is manual modification.
# NPTrading : Strike price determined based on current close price but could be previous day close
# NPTrading : Script is work in progress, shared as requested for other to use and modify as per their need

declare lower;

def pricerange1 = if close(period=aggregationperiod.day)[1]<=2 then 1 else 0; #.5
def pricerange2 = if close(period=aggregationperiod.day)[1]>2 and close(period=aggregationperiod.day)[1]<=10 then 1 else 0; #1
def pricerange3 = if close(period=aggregationperiod.day)[1]>10 and close(period=aggregationperiod.day)[1]<=25 then 1 else 0; #2.5
def pricerange4 = if close(period=aggregationperiod.day)[1]>25 and close(period=aggregationperiod.day)[1]<=50 then 1 else 0; #5
def pricerange5 = if close(period=aggregationperiod.day)[1]>50 and close(period=aggregationperiod.day)[1]<=500 then 1 else 0; #10
def pricerange6 = if close(period=aggregationperiod.day)[1]>500 then 1 else 0; #25

def series = 1;

def RTHopen = open(period = AggregationPeriod.Day);
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
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 = if currentDOM < FirstFridayDOM -1
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;

#def optionSeriesPrefix = Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),""); #NPTrading : manually update option expiry date in format YYMMDD

def strikeSpacing =
if pricerange6 then 25
else if pricerange5 then 10
else if pricerange4 then 5
else if pricerange3 then 2.5
else if pricerange2 then 1
else if pricerange1 then .5
else double.nan;
#{ default ".5", "1", "2.5", "5", "10", "25" }; #default 10 for large price stock

#NPTrading : Strike price determined based on current close price but could be previous day close
def PutStrike = Floor(close/10)*10;
def CallStrike = Floor(close/10)*10;

AddLabel(1, GetSymbol() + " Exp:" + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),""), CreateColor(135,135,135));

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

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

### Put Option ohlc4
def putOptionohlc4   = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionohlc41  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionohlc42  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionohlc43  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionohlc44  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionohlc45  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionohlc46  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionohlc47  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionohlc48  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionohlc49  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));

####Call Option ohlc4
def callOptionohlc4   = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptionohlc41  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1));
def callOptionohlc42  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2));
def callOptionohlc43  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3));
def callOptionohlc44  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4));
def callOptionohlc45  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5));
def callOptionohlc46  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6));
def callOptionohlc47  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7));
def callOptionohlc48  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8));
def callOptionohlc49  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9));
def callOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10));
def callOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11));
def callOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12));
def callOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13));
def callOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14));
def callOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15));
def callOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16));
def callOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17));
def callOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18));
def callOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19));
def callOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20));

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

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

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

plot Callvol = if Callvoldef>0 then Callvoldef else double.nan;
plot Putvol = if Putvoldef>0 then Putvoldef else double.nan;

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

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

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

DefineGlobalColor("CallVolCloud",Color.CYAN);
DefineGlobalColor("PutVolCloud",Color.Light_Red);

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

#Diff Cloud ?

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

# individual Cloud ?

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

###################################
#Description:  Identify bars with high volume relative to the tick_count.  Such bars could indicate a block trade, or a possible change in trend.
#Author: Dilbert
#Requested By:
# Ver     Date     Auth      Change
# V1      090717   Dilbert   1st code cut
# Trading Notes:  Identify bars with high volume relative to the tick_count.  Such bars could indicate a block trade, or a possible change in trend.

#PUT RATIO
input AvgType = AverageType.EXPONENTIAL;
input MaLength = 20;
def V = Putvol;
def TC = Puttick;
def TradeSize = V / TC;

input displace = 0;
input SdLength = 20;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = TradeSize[-displace], length = SdLength);

def MA = MovingAverage(AvgType,  TradeSize, MaLength);
plot Dot = if TradeSize > Ma + (sDev * Num_Dev_up) then Putvol else Double.NaN;
Dot.SetPaintingStrategy(PaintingStrategy.Points);
Dot.SetLineWeight(5);
Dot.AssignValueColor(color.red);

#CALL RATIO
input AvgType1 = AverageType.EXPONENTIAL;
input MaLength1 = 20;
def V1 = Callvol;
def TC1 = Calltick;
def TradeSize1 = V1 / TC1;

input displace1 = 0;
input SdLength1 = 20;
input Num_Dev_up1 = 2.0;
input averageType1 = AverageType.SIMPLE;

def sDev1 = StDev(data = TradeSize1[-displace1], length = SdLength1);

def MA1 = MovingAverage(AvgType1,  TradeSize1, MaLength1);
plot Dot1 = if TradeSize1 > Ma1 + (sDev1 * Num_Dev_up1) then Callvol else Double.NaN;
Dot1.AssignValueColor(color.cyan);
Dot1.SetPaintingStrategy(PaintingStrategy.Points);
Dot1.SetLineWeight(5);``````

I can't figure out why it worked during a previous week but stopped working this week. I guess that I messed up the logic of the date math in a way that would cause that.

Hi all, I did try to automate the selection of the options expiration date for weekly contracts using the concat function. After I did it, it was working! But now that it's a new week, it's not working anymore. So it was automatically choosing the right date but only during that week, not in subsequent weeks. Hoping that the problem is simple and someone with a better understanding of the logic can point out how to fix it. It would be a nice QOL and convenience feature if this can be fixed, because I was enjoying being able to use it the other week without having to manually input the contract date. Here is the code I have (please note that some of the stuff in the original study was pruned out, but the same solution for this code would fully apply for the original version of the study):

Code:
``````# Option Volume/Open Interest Indicator
# NPTrading : modified script provided by DeusMecanicus in Post #21
# NPTrading : AsPrice function used to support stock price in 4 digits
# NPTrading : Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") is the option expiry date in format YYMMDD.  This Expiry date can be determined automatically (for monthly and weekly options both )but as of now it is manual modification.
# NPTrading : Strike price determined based on current close price but could be previous day close
# NPTrading : Script is work in progress, shared as requested for other to use and modify as per their need

declare lower;

def pricerange1 = if close(period=aggregationperiod.day)[1]<=2 then 1 else 0; #.5
def pricerange2 = if close(period=aggregationperiod.day)[1]>2 and close(period=aggregationperiod.day)[1]<=10 then 1 else 0; #1
def pricerange3 = if close(period=aggregationperiod.day)[1]>10 and close(period=aggregationperiod.day)[1]<=25 then 1 else 0; #2.5
def pricerange4 = if close(period=aggregationperiod.day)[1]>25 and close(period=aggregationperiod.day)[1]<=50 then 1 else 0; #5
def pricerange5 = if close(period=aggregationperiod.day)[1]>50 and close(period=aggregationperiod.day)[1]<=500 then 1 else 0; #10
def pricerange6 = if close(period=aggregationperiod.day)[1]>500 then 1 else 0; #25

def series = 1;

def RTHopen = open(period = AggregationPeriod.Day);
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
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 = if currentDOM < FirstFridayDOM -1
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;

#def optionSeriesPrefix = Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),""); #NPTrading : manually update option expiry date in format YYMMDD

def strikeSpacing =
if pricerange6 then 25
else if pricerange5 then 10
else if pricerange4 then 5
else if pricerange3 then 2.5
else if pricerange2 then 1
else if pricerange1 then .5
else double.nan;
#{ default ".5", "1", "2.5", "5", "10", "25" }; #default 10 for large price stock

#NPTrading : Strike price determined based on current close price but could be previous day close
def PutStrike = Floor(close/10)*10;
def CallStrike = Floor(close/10)*10;

AddLabel(1, GetSymbol() + " Exp:" + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),""), CreateColor(135,135,135));

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

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

### Put Option ohlc4
def putOptionohlc4   = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 0));
def putOptionohlc41  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 1));
def putOptionohlc42  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 2));
def putOptionohlc43  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 3));
def putOptionohlc44  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 4));
def putOptionohlc45  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 5));
def putOptionohlc46  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 6));
def putOptionohlc47  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 7));
def putOptionohlc48  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 8));
def putOptionohlc49  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 9));
def putOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 10));
def putOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 11));
def putOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 12));
def putOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 13));
def putOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 14));
def putOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 15));
def putOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 16));
def putOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 17));
def putOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 18));
def putOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 19));
def putOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "P" + AsPrice(PutStrike - strikeSpacing * 20));

####Call Option ohlc4
def callOptionohlc4   = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 0));
def callOptionohlc41  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 1));
def callOptionohlc42  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 2));
def callOptionohlc43  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 3));
def callOptionohlc44  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 4));
def callOptionohlc45  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 5));
def callOptionohlc46  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 6));
def callOptionohlc47  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 7));
def callOptionohlc48  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 8));
def callOptionohlc49  = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 9));
def callOptionohlc410 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 10));
def callOptionohlc411 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 11));
def callOptionohlc412 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 12));
def callOptionohlc413 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 13));
def callOptionohlc414 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 14));
def callOptionohlc415 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 15));
def callOptionohlc416 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 16));
def callOptionohlc417 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 17));
def callOptionohlc418 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 18));
def callOptionohlc419 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 19));
def callOptionohlc420 = if IsNaN(ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20))) then 0 else ohlc4("." + GetSymbol() + Concat((ExpYear-2000),"") + Concat((ExpMonth2),"") + Concat((ExpDOM),"") + "C" + AsPrice(CallStrike + strikeSpacing * 20));

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

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

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

plot Callvol = if Callvoldef>0 then Callvoldef else double.nan;
plot Putvol = if Putvoldef>0 then Putvoldef else double.nan;

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

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

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

DefineGlobalColor("CallVolCloud",Color.CYAN);
DefineGlobalColor("PutVolCloud",Color.Light_Red);

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

#Diff Cloud ?

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

# individual Cloud ?

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

###################################
#Description:  Identify bars with high volume relative to the tick_count.  Such bars could indicate a block trade, or a possible change in trend.
#Author: Dilbert
#Requested By:
# Ver     Date     Auth      Change
# V1      090717   Dilbert   1st code cut
# Trading Notes:  Identify bars with high volume relative to the tick_count.  Such bars could indicate a block trade, or a possible change in trend.

#PUT RATIO
input AvgType = AverageType.EXPONENTIAL;
input MaLength = 20;
def V = Putvol;
def TC = Puttick;
def TradeSize = V / TC;

input displace = 0;
input SdLength = 20;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = TradeSize[-displace], length = SdLength);

def MA = MovingAverage(AvgType,  TradeSize, MaLength);
plot Dot = if TradeSize > Ma + (sDev * Num_Dev_up) then Putvol else Double.NaN;
Dot.SetPaintingStrategy(PaintingStrategy.Points);
Dot.SetLineWeight(5);
Dot.AssignValueColor(color.red);

#CALL RATIO
input AvgType1 = AverageType.EXPONENTIAL;
input MaLength1 = 20;
def V1 = Callvol;
def TC1 = Calltick;
def TradeSize1 = V1 / TC1;

input displace1 = 0;
input SdLength1 = 20;
input Num_Dev_up1 = 2.0;
input averageType1 = AverageType.SIMPLE;

def sDev1 = StDev(data = TradeSize1[-displace1], length = SdLength1);

def MA1 = MovingAverage(AvgType1,  TradeSize1, MaLength1);
plot Dot1 = if TradeSize1 > Ma1 + (sDev1 * Num_Dev_up1) then Callvol else Double.NaN;
Dot1.AssignValueColor(color.cyan);
Dot1.SetPaintingStrategy(PaintingStrategy.Points);
Dot1.SetLineWeight(5);``````

I can't figure out why it worked during a previous week but stopped working this week. I guess that I messed up the logic of the date math in a way that would cause that.
You have to change expire date to every Friday . Put December 3rd , it will work.

87k+ Posts
334 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?