Gamma levels
Options gamma: the zero gamma level and the two major levels held as lines across the chart, and the gamma of the strike the price is in, in the readout. Nothing is invented where the chart has no gamma.
//@xfscript 1
indicator("Gamma Levels")
let zero_color: color = input.color("#F59E0B", "zeroColor", "Zero gamma")
let pos_color: color = input.color("#22C55E", "posColor", "Positive")
let neg_color: color = input.color("#EF4444", "negColor", "Negative")
let has_gamma: bool = gex.supported() && gex.available()
var zero_level: float = nan
var call_wall: float = nan
var put_wall: float = nan
var net_gamma: float = nan
zero_level := nz(zero_level[1], nan)
call_wall := nz(call_wall[1], nan)
put_wall := nz(put_wall[1], nan)
net_gamma := nz(net_gamma[1], nan)
if has_gamma {
zero_level := gex.zero_gamma()
call_wall := gex.major_pos_vol()
put_wall := gex.major_neg_vol()
net_gamma := gex.net_vol()
}
plot.hline(zero_level, zero_color, 2, "dashed", "Zero gamma")
plot.hline(call_wall, pos_color, 1, "solid", "Major positive")
plot.hline(put_wall, neg_color, 1, "solid", "Major negative")
plot.marker(has_gamma, close, zero_color, "circle", "above", 6, 4)
if gex.supported() {
plot.label(str.concat("NET GAMMA ", format.compact(net_gamma), " AT PRICE ", format.compact(gex.vol_at(close))), "#E5E7EB")
} else {
plot.label("GAMMA OFF ON THIS CHART", "#6B7280")
}