# GEX Horizontal Axis V2B Jan 17, 2023
# Twitter @2187Nick
# 1-18-24 @brooklyngfellaz Added expiration date label, Base strike label (changes color, above base strike uptick, below downtick), a current price label just to be able to get a quick view of current price and lastly changed the color of base strike so it would stand out.
declare lower;
declare once_per_bar;
def day = 0;
input symbol = "SPY";
input strikeSpacing = 1.0;
input strikes = 10;
input shift_left = 1;
input spacing = 1;
input threshold = 20;
def lastbar = if IsNaN(close[-1]) and !IsNaN(close)
then BarNumber()
else lastbar[1];
input ManuallySetExpiration = {default "false", "true"};
input Expiration_YYMMDD = 240117;
def DateString_auto = GetYYYYMMDD() - 20000000;
def DateString = if ManuallySetExpiration then Expiration_YYMMDD else DateString_auto;
def agg = AggregationPeriod.Day;
def seconds_left = SecondsTillTime(1615);
def hours_left = seconds_left / 3600;
def days_left = if hours_left <= 0 then 0 else hours_left / 24;
def Vol = imp_volatility(getSymbol());
#addlabel(yes, "Vol: " + Vol, color.white);
def S = close();
#def S = close(period = agg);
#addlabel(yes, "S_close: " + S, color.white);
def t = ((DateString - DateString_auto) + days_left) / 365;
#addlabel(yes, "t: " + t);
#def t = 1/365;
def Sqr_Vol_2 = Sqr(Vol).5 t;
def Vol_Sqrt_t = Vol * Sqrt(t);
def Sqrt_2pi = 2.5066;
def Vol_Sqrt_t_S = S * Vol_Sqrt_t;
DefineGlobalColor("CallColor", Color.GREEN);
DefineGlobalColor("PutColor", Color.downtick);
#AddLabel(yes, "Expiration: " + AsPrice(DateString) , color.uptick);
AddLabel(yes, "Gamma Exposure (GEX): " + AsPrice(DateString), color.cyan);
#AddLabel(yes, "GEX", color.uptick);
#AddLabel(yes, AsPrice(DateString) + "C", GlobalColor("CallColor"));
#AddLabel(yes, AsPrice(DateString) + "P", GlobalColor("PutColor"));
# Open Price
def todayOpen = open(symbol = getSymbol(), period = "DAY");
def yesterdayOpen = open(symbol = getSymbol(), period = "DAY")[1];
def lastPrice = if !IsNaN(close(symbol = getSymbol()))
then close(symbol = getSymbol())
else close(symbol = getSymbol(), period = "DAY", PriceType.LAST);
def openPrice = if !IsNaN(todayOpen) then todayOpen
else if !IsNaN(yesterdayOpen) then yesterdayOpen
else lastPrice;
#def openlevel = open(period = agg);
#addlabel(yes, "open: " + openPrice, color.uptick);
def rounding_factor = if strikeSpacing > 1 and strikeSpacing < 25 then -1 else if strikeSpacing > 24 then -2 else 0;
def floor_or_ceiling = Round(openPrice, rounding_factor);
def base_strike = floor_or_ceiling;
#addlabel(yes, "centerStrike: " + base_strike);
#AddLabel(yes, "Base Strike: " + AsPrice(base_strike), if close > base_strike then Color.uptick else Color.downtick);
def SPY = Close ("SPY");
#AddLabel(Yes, "Current Price: " + AsPrice(close), if close > base_strike then Color.uptick else Color.downtick);
#def closeplot = if !IsNaN(close) and IsNaN(close[-1]) then close else closeplot[1];
Script GEX {
input strike = 0;
input dateString = 0;
input Vol = 0;
input t = 0;
input S = 0;
input todayoryday = 0;
input Sqr_Vol_2 = 0;
input Vol_Sqrt_t = 0;
input Vol_Sqrt_t_S = 0;
def gamma = (Exp(-.5*(Sqr((Log(S / strike) + Sqr_Vol_2) / Vol_Sqrt_t) )) /2.5066) / Vol_Sqrt_t_S;
plot strikeGEX = if IsNaN((open_interest("."+ getSymbol() + AsPrice(dateString) + "C" + AsPrice(strike),AggregationPeriod.DAY)[todayoryday] - open_interest("."+ getSymbol() + AsPrice(dateString) + "P" + AsPrice(strike),AggregationPeriod.DAY)[todayoryday]) * gamma)
then 0 else Round((open_interest("."+ getSymbol() + AsPrice(dateString) + "C" + AsPrice(strike),AggregationPeriod.DAY)[todayoryday] - open_interest("."+ getSymbol() + AsPrice(dateString) + "P" + AsPrice(strike),AggregationPeriod.DAY)[todayoryday]) * gamma*S/10000,0);
}
def strike_base = base_strike;
def strike_plus1 = base_strike + strikeSpacing;
def strike_plus2 = base_strike + strikeSpacing * 2;
def strike_plus3 = base_strike + strikeSpacing * 3;
def strike_plus4 = base_strike + strikeSpacing * 4;
def strike_plus5 = base_strike + strikeSpacing * 5;
def strike_plus6 = base_strike + strikeSpacing * 6;
def strike_plus7 = base_strike + strikeSpacing * 7;
def strike_plus8 = base_strike + strikeSpacing * 8;
def strike_plus9 = base_strike + strikeSpacing * 9;
def strike_plus10 = base_strike + strikeSpacing * 10;
def strike_minus1 = base_strike - strikeSpacing;
def strike_minus2 = base_strike - strikeSpacing * 2;
def strike_minus3 = base_strike - strikeSpacing * 3;
def strike_minus4 = base_strike - strikeSpacing * 4;
def strike_minus5 = base_strike - strikeSpacing * 5;
def strike_minus6 = base_strike - strikeSpacing * 6;
def strike_minus7 = base_strike - strikeSpacing * 7;
def strike_minus8 = base_strike - strikeSpacing * 8;
def strike_minus9 = base_strike - strikeSpacing * 9;
def strike_minus10 = base_strike - strikeSpacing * 10;
### GEX
def strike_base_gex = GEX(strike_base, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
#addlabel(yes, "strike_base_gex : " + strike_base_gex , color.yellow);
def strike_plus1_gex = GEX(strike_plus1, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus2_gex = GEX(strike_plus2, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus3_gex = GEX(strike_plus3, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus4_gex = GEX(strike_plus4, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus5_gex = GEX(strike_plus5, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus6_gex = GEX(strike_plus6, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus7_gex = GEX(strike_plus7, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus8_gex = GEX(strike_plus8, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus9_gex = GEX(strike_plus9, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_plus10_gex = GEX(strike_plus10, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus1_gex = GEX(strike_minus1, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus2_gex = GEX(strike_minus2, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus3_gex = GEX(strike_minus3, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus4_gex = GEX(strike_minus4, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus5_gex = GEX(strike_minus5, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus6_gex = GEX(strike_minus6, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus7_gex = GEX(strike_minus7, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus8_gex = GEX(strike_minus8, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus9_gex = GEX(strike_minus9, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
def strike_minus10_gex = GEX(strike_minus10, dateString, Vol, t, S, day, Sqr_Vol_2, Vol_Sqrt_t, Vol_Sqrt_t_S).strikeGEX;
plot base = if BarNumber() == HighestAll(lastbar - (shift_left*10)) then strike_base_gex[shift_left*-10] else Double.Nan;
base.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base.setLineWeight(5);
base.AssignValueColor(if strike_base_gex[shift_left*-10] > 0 then (Createcolor(240,230,107)) else (Createcolor(240,230,107)));
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*10)) then yes else no, 0, base_strike, (Createcolor(240,230,107)), if strike_base_gex[shift_left*-10] > 0 then no else yes);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*10)) then yes else no, strike_base_gex[shift_left*-10], strike_base_gex[shift_left*-10], if strike_base_gex[shift_left*-10] > 0 then(Createcolor(240,230,107)) else (Createcolor(240,230,107)), if strike_base_gex > 0 then yes else no);
plot base_plus1 = if BarNumber() == HighestAll(lastbar - (shift_left*9)) then strike_plus1_gex[shift_left*-9] else Double.Nan;
base_plus1.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus1.setLineWeight(5);
base_plus1.AssignValueColor(if strike_plus1_gex[shift_left*-9] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*9)) and AbsValue(strike_plus1_gex[shift_left*-9]) > threshold then yes else no, strike_plus1_gex[shift_left*-9], strike_plus1_gex[shift_left*-9], if strike_plus1_gex[shift_left*-9] > 0 then Color.uptick else Color.downtick, if strike_plus1_gex[shift_left*-9] > 0 then yes else no);
plot base_plus2 = if BarNumber() == HighestAll(lastbar - (shift_left*8)) then strike_plus2_gex[shift_left*-8] else Double.Nan;
base_plus2.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus2.setLineWeight(5);
base_plus2.AssignValueColor(if strike_plus2_gex[shift_left*-8] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar- (shift_left*8)) and AbsValue(strike_plus2_gex[shift_left*-8]) > threshold then yes else no, strike_plus2_gex[shift_left*-8], strike_plus2_gex[shift_left*-8], if strike_plus2_gex[shift_left*-8] > 0 then Color.uptick else Color.downtick, if strike_plus2_gex[shift_left*-8] > 0 then yes else no);
# For Testing
# time condition(barNumber == barNumber - 8)
#AddChartBubble(time condition, price location, text in bubble, color, up)
#AddChartBubble(yes, BarNumber(), strike_plus2_gex[-8], color.white);
#addlabel(yes, "strike_plus2_gex: " + strike_plus2_gex);
plot base_plus3 = if BarNumber() == HighestAll(lastbar - (shift_left*7)) then strike_plus3_gex[shift_left*-7] else Double.Nan;
base_plus3.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus3.setLineWeight(5);
base_plus3.AssignValueColor(if strike_plus3_gex[shift_left*-7] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*7)) and AbsValue(strike_plus3_gex[shift_left*-7]) > threshold then yes else no, strike_plus3_gex[shift_left*-7], strike_plus3_gex[shift_left*-7], if strike_plus3_gex[shift_left*-7] > 0 then Color.uptick else Color.downtick, if strike_plus3_gex[shift_left*-7] > 0 then yes else no);
plot base_plus4 = if BarNumber() == HighestAll(lastbar - (shift_left*6)) then strike_plus4_gex[shift_left*-6] else Double.Nan;
base_plus4.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus4.setLineWeight(5);
base_plus4.AssignValueColor(if strike_plus4_gex[shift_left*-6] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*6)) and AbsValue(strike_plus4_gex[shift_left*-6]) > threshold then yes else no, strike_plus4_gex[shift_left*-6], strike_plus4_gex[shift_left*-6], if strike_plus4_gex[shift_left*-6] > 0 then Color.uptick else Color.downtick, if strike_plus4_gex[shift_left*-6] > 0 then yes else no);
plot base_plus5 = if BarNumber() == HighestAll(lastbar - (shift_left*5)) then strike_plus5_gex[shift_left*-5] else Double.Nan;
base_plus5.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus5.setLineWeight(5);
base_plus5.AssignValueColor(if strike_plus5_gex[shift_left*-5] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*5)) then yes else no, 0, strike_plus5, color.gray, if strike_plus5_gex[shift_left*-5] > 0 then no else yes);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*5)) and AbsValue(strike_plus5_gex[shift_left*-5]) > threshold then yes else no, strike_plus5_gex[shift_left*-5], strike_plus5_gex[shift_left*-5], if strike_plus5_gex[shift_left*-5] > 0 then Color.uptick else Color.downtick, if strike_plus5_gex[shift_left*-5] > 0 then yes else no);
plot base_plus6 = if BarNumber() == HighestAll(lastbar - (shift_left*4)) then strike_plus6_gex[shift_left*-4] else Double.Nan;
base_plus6.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus6.setLineWeight(5);
base_plus6.AssignValueColor(if strike_plus6_gex[shift_left*-4] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*4)) and AbsValue(strike_plus6_gex[shift_left*-4]) > threshold then yes else no, strike_plus6_gex[shift_left*-4], strike_plus6_gex[shift_left*-4], if strike_plus6_gex[shift_left*-4] > 0 then Color.uptick else Color.downtick, if strike_plus6_gex[shift_left*-4] > 0 then yes else no);
plot base_plus7 = if BarNumber() == HighestAll(lastbar - (shift_left*3)) then strike_plus7_gex[shift_left*-3] else Double.Nan;
base_plus7.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus7.setLineWeight(5);
base_plus7.AssignValueColor(if strike_plus7_gex[shift_left*-3] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*3)) and AbsValue(strike_plus7_gex[shift_left*-3]) > threshold then yes else no, strike_plus7_gex[shift_left*-3], strike_plus7_gex[shift_left*-3], if strike_plus7_gex[shift_left*-3] > 0 then Color.uptick else Color.downtick, if strike_plus7_gex[shift_left*-3] > 0 then yes else no);
plot base_plus8 = if BarNumber() == HighestAll(lastbar - (shift_left*2)) then strike_plus8_gex[shift_left*-2] else Double.Nan;
base_plus8.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus8.setLineWeight(5);
base_plus8.AssignValueColor(if strike_plus8_gex[shift_left*-2] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*2)) and AbsValue(strike_plus8_gex[shift_left*-2]) > threshold then yes else no, strike_plus8_gex[shift_left*-2], strike_plus8_gex[shift_left*-2], if strike_plus8_gex[shift_left*-2] > 0 then Color.uptick else Color.downtick, if strike_plus8_gex[shift_left*-2] > 0 then yes else no);
plot base_plus9 = if BarNumber() == HighestAll(lastbar - (shift_left)) then strike_plus9_gex[shift_left*-1] else Double.Nan;
base_plus9.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus9.setLineWeight(5);
base_plus9.AssignValueColor(if strike_plus9_gex[shift_left*-1] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left)) and AbsValue(strike_plus9_gex[shift_left*-1]) > threshold then yes else no, strike_plus9_gex[shift_left*-1], strike_plus9_gex[shift_left*-1], if strike_plus9_gex[shift_left*-1] > 0 then Color.uptick else Color.downtick, if strike_plus9_gex[shift_left*-1] > 0 then yes else no);
plot base_plus10 = if BarNumber() == HighestAll(lastbar - (shift_left-1)) then strike_plus10_gex[shift_left-1] else Double.Nan;
base_plus10.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_plus10.setLineWeight(5);
base_plus10.AssignValueColor(if strike_plus10_gex[shift_left-1] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left-1)) and AbsValue(strike_plus10_gex[shift_left-1]) > threshold then yes else no, strike_plus10_gex[shift_left-1], strike_plus10_gex[shift_left-1], if strike_plus10_gex[shift_left-1] > 0 then Color.uptick else Color.downtick, if strike_plus10_gex[shift_left-1] > 0 then yes else no);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left-1)) then yes else no, 0, strike_plus10, color.gray, if strike_plus10_gex[shift_left-1] > 0 then no else yes);
plot base_minus1 = if BarNumber() == HighestAll(lastbar - (shift_left*11)) then strike_minus1_gex[shift_left*-11] else Double.Nan;
base_minus1.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus1.setLineWeight(5);
base_minus1.AssignValueColor(if strike_minus1_gex[shift_left*-11] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*11)) and AbsValue(strike_minus1_gex[shift_left*-11]) > threshold then yes else no, strike_minus1_gex[shift_left*-11], strike_minus1_gex[shift_left*-11], if strike_minus1_gex[shift_left*-11] > 0 then Color.uptick else Color.downtick, if strike_minus1_gex[shift_left*-11] > 0 then yes else no);
plot base_minus2 = if BarNumber() == HighestAll(lastbar - (shift_left*12)) then strike_minus2_gex[shift_left*-12] else Double.Nan;
base_minus2.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus2.setLineWeight(5);
base_minus2.AssignValueColor(if strike_minus2_gex[shift_left*-12] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*12)) and AbsValue(strike_minus2_gex[shift_left*-12]) > threshold then yes else no, strike_minus2_gex[shift_left*-12], strike_minus2_gex[shift_left*-12], if strike_minus2_gex[shift_left*-12] > 0 then Color.uptick else Color.downtick, if strike_minus2_gex[shift_left*-12] > 0 then yes else no);
plot base_minus3 = if BarNumber() == HighestAll(lastbar - (shift_left*13)) then strike_minus3_gex[shift_left*-13] else Double.Nan;
base_minus3.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus3.setLineWeight(5);
base_minus3.AssignValueColor(if strike_minus3_gex[shift_left*-13] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*13)) and AbsValue(strike_minus3_gex[shift_left*-13]) > threshold then yes else no, strike_minus3_gex[shift_left*-13], strike_minus3_gex[shift_left*-13], if strike_minus3_gex[shift_left*-13] > 0 then Color.uptick else Color.downtick, if strike_minus3_gex[shift_left*-13] > 0 then yes else no);
plot base_minus4 = if BarNumber() == HighestAll(lastbar - (shift_left*14)) then strike_minus4_gex[shift_left*-14] else Double.Nan;
base_minus4.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus4.setLineWeight(5);
base_minus4.AssignValueColor(if strike_minus4_gex[shift_left*-14] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*14)) and AbsValue(strike_minus4_gex[shift_left*-14]) > threshold then yes else no, strike_minus4_gex[shift_left*-14], strike_minus4_gex[shift_left*-14], if strike_minus4_gex[shift_left*-14] > 0 then Color.uptick else Color.downtick, if strike_minus4_gex[shift_left*-14] > 0 then yes else no);
plot base_minus5 = if BarNumber() >= HighestAll(lastbar - (shift_left*15)) and BarNumber() <= HighestAll(lastbar - (shift_left*15)) then strike_minus5_gex[shift_left*-15] else Double.Nan;
base_minus5.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus5.setLineWeight(5);
base_minus5.AssignValueColor(if strike_minus5_gex[shift_left*-15] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*15)) then yes else no, 0, strike_minus5, color.gray, if strike_minus5_gex[shift_left*-15] > 0 then no else yes);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*15)) and AbsValue(strike_minus5_gex[shift_left*-15]) > threshold then yes else no, strike_minus5_gex[shift_left*-15], strike_minus5_gex[shift_left*-15], if strike_minus5_gex[shift_left*-15] > 0 then Color.uptick else Color.downtick, if strike_minus5_gex[shift_left*-15] > 0 then yes else no);
plot base_minus6 = if BarNumber() == HighestAll(lastbar - (shift_left*16)) then strike_minus6_gex[shift_left*-16] else Double.Nan;
base_minus6.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus6.setLineWeight(5);
base_minus6.AssignValueColor(if strike_minus6_gex[shift_left*-16] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*16)) and AbsValue(strike_minus6_gex[shift_left*-16]) > threshold then yes else no, strike_minus6_gex[shift_left*-16], strike_minus6_gex[shift_left*-16], if strike_minus6_gex[shift_left*-16] > 0 then Color.uptick else Color.downtick, if strike_minus6_gex[shift_left*-16] > 0 then yes else no);
plot base_minus7 = if BarNumber() >= HighestAll(lastbar - (shift_left*17)) and BarNumber() <= HighestAll(lastbar - (shift_left*17)) then strike_minus7_gex[shift_left*-17] else Double.Nan;
base_minus7.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus7.setLineWeight(5);
base_minus7.AssignValueColor(if strike_minus7_gex[shift_left*-17] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() >= HighestAll(lastbar - (shift_left*17)) and BarNumber() <= HighestAll(lastbar - (shift_left*17))and AbsValue(strike_minus7_gex[shift_left*-17]) > threshold then yes else no, strike_minus7_gex[shift_left*-17], strike_minus7_gex[shift_left*-17], if strike_minus7_gex[shift_left*-17] > 0 then Color.uptick else Color.downtick, if strike_minus7_gex[shift_left*-17] > 0 then yes else no);
plot base_minus8 = if BarNumber() == HighestAll(lastbar - (shift_left*18)) then strike_minus8_gex[shift_left*-18] else Double.Nan;
base_minus8.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus8.setLineWeight(5);
base_minus8.AssignValueColor(if strike_minus8_gex[shift_left*-18] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() >= HighestAll(lastbar - (shift_left*18)) and BarNumber() <= HighestAll(lastbar - (shift_left*18))and AbsValue(strike_minus8_gex[shift_left*-18]) > threshold then yes else no, strike_minus8_gex[shift_left*-18], strike_minus8_gex[shift_left*-18], if strike_minus8_gex[shift_left*-18] > 0 then Color.uptick else Color.downtick, if strike_minus8_gex[shift_left*-18] > 0 then yes else no);
plot base_minus9 = if BarNumber() == HighestAll(lastbar - (shift_left*19)) then strike_minus9_gex[shift_left*-19] else Double.Nan;
base_minus9.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus9.setLineWeight(5);
base_minus9.AssignValueColor(if strike_minus9_gex[shift_left*-19] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*19)) and AbsValue(strike_minus9_gex[shift_left*-19]) > threshold then yes else no, strike_minus9_gex[shift_left*-19], strike_minus9_gex[shift_left*-19], if strike_minus9_gex[shift_left*-19] > 0 then Color.uptick else Color.downtick, if strike_minus9_gex[shift_left*-19] > 0 then yes else no);
plot base_minus10 = if BarNumber() == HighestAll(lastbar - (shift_left*20)) then strike_minus10_gex[shift_left*-20] else Double.Nan;
base_minus10.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
base_minus10.setLineWeight(5);
base_minus10.AssignValueColor(if strike_minus10_gex[shift_left*-20] > 0 then Color.uptick else Color.downtick);
AddChartBubble(if BarNumber() == HighestAll(lastbar - (shift_left*20)) and AbsValue(strike_minus10_gex[shift_left*-20]) > threshold then yes else no, strike_minus10_gex[shift_left*-20], strike_minus10_gex[shift_left*-20], if strike_minus10_gex[shift_left*-20] > 0 then Color.uptick else Color.downtick, if strike_minus10_gex[shift_left*-20] > 0 then yes else no);
AddChartBubble(if BarNumber() >= HighestAll(lastbar - (shift_left*20)) and BarNumber() <= HighestAll(lastbar - (shift_left*20)) then yes else no, 0, strike_minus10, color.gray, if strike_minus10 > 0 then yes else no);
#######
plot zeroline = 0;
zeroline.SetDEfaultColor(color.dark_gray);
def base_gex_net = if IsNan(strike_base_gex) then 0 else if AbsValue(strike_base_gex) > threshold then strike_base_gex else 0;
def plus1_gex_net = if IsNan(strike_plus1_gex) then 0 else if AbsValue(strike_plus1_gex) > threshold then strike_plus1_gex else 0;
def plus2_gex_net = if IsNan(strike_plus2_gex) then 0 else if AbsValue(strike_plus2_gex) > threshold then strike_plus2_gex else 0;
def plus3_gex_net = if IsNan(strike_plus3_gex) then 0 else if AbsValue(strike_plus3_gex) > threshold then strike_plus3_gex else 0;
def plus4_gex_net = if IsNan(strike_plus4_gex) then 0 else if AbsValue(strike_plus4_gex) > threshold then strike_plus4_gex else 0;
def plus5_gex_net = if IsNan(strike_plus5_gex) then 0 else if AbsValue(strike_plus5_gex) > threshold then strike_plus5_gex else 0;
def plus6_gex_net = if IsNan(strike_plus6_gex) then 0 else if AbsValue(strike_plus6_gex) > threshold then strike_plus6_gex else 0;
def plus7_gex_net = if IsNan(strike_plus7_gex) then 0 else if AbsValue(strike_plus7_gex) > threshold then strike_plus7_gex else 0;
def plus8_gex_net = if IsNan(strike_plus8_gex) then 0 else if AbsValue(strike_plus8_gex) > threshold then strike_plus8_gex else 0;
def plus9_gex_net = if IsNan(strike_plus9_gex) then 0 else if AbsValue(strike_plus9_gex) > threshold then strike_plus9_gex else 0;
def plus10_gex_net = if IsNan(strike_plus10_gex) then 0 else if AbsValue(strike_plus10_gex) > threshold then strike_plus10_gex else 0;
def minus1_gex_net = if IsNan(strike_minus1_gex) then 0 else if AbsValue(strike_minus1_gex) > threshold then strike_minus1_gex else 0;
def minus2_gex_net = if IsNan(strike_minus2_gex) then 0 else if AbsValue(strike_minus2_gex) > threshold then strike_minus2_gex else 0;
def minus3_gex_net = if IsNan(strike_minus3_gex) then 0 else if AbsValue(strike_minus3_gex) > threshold then strike_minus3_gex else 0;
def minus4_gex_net = if IsNan(strike_minus4_gex) then 0 else if AbsValue(strike_minus4_gex) > threshold then strike_minus4_gex else 0;
def minus5_gex_net = if IsNan(strike_minus5_gex) then 0 else if AbsValue(strike_minus5_gex) > threshold then strike_minus5_gex else 0;
def minus6_gex_net = if IsNan(strike_minus6_gex) then 0 else if AbsValue(strike_minus6_gex) > threshold then strike_minus6_gex else 0;
def minus7_gex_net = if IsNan(strike_minus7_gex) then 0 else if AbsValue(strike_minus7_gex) > threshold then strike_minus7_gex else 0;
def minus8_gex_net = if IsNan(strike_minus8_gex) then 0 else if AbsValue(strike_minus8_gex) > threshold then strike_minus8_gex else 0;
def minus9_gex_net = if IsNan(strike_minus9_gex) then 0 else if AbsValue(strike_minus9_gex) > threshold then strike_minus9_gex else 0;
def minus10_gex_net = if IsNan(strike_minus10_gex) then 0 else if AbsValue(strike_minus10_gex) > threshold then strike_minus10_gex else 0;
def nettotalGEX_today = base_gex_net + plus1_gex_net + plus2_gex_net + plus3_gex_net + plus4_gex_net + plus5_gex_net + plus6_gex_net + plus7_gex_net + plus8_gex_net + plus9_gex_net + plus10_gex_net + minus1_gex_net + minus2_gex_net + minus3_gex_net + minus4_gex_net + minus5_gex_net + minus6_gex_net + minus7_gex_net + minus8_gex_net + minus9_gex_net + minus10_gex_net;
AddLabel(yes, "Net GEX: " + nettotalGEX_today *100, if nettotalGEX_today > 1 then color.uptick else color.downtick);