Adeodatus
Member
Over the spring, I've been coding a use volume and implied vol. indicator (adjustable, start at .50) to paste a buy bubble and an exit.
Its super-fast and will only be visible on optionable stocks. Because of that, I'm not 100% sure the extended hours call is valid.
Any feedback is appreciated ~Adeo
Its super-fast and will only be visible on optionable stocks. Because of that, I'm not 100% sure the extended hours call is valid.
Code:
# Inputs
input bubbleoffset = 3; # Offset for chart bubbles (in ticks)
input maxIV = 0.5; # Maximum implied volatility threshold for buy signals (e.g., 50%)
input price = close; # Price for moving averages
input superfast_length = 9; # Length for fastest MA
input fast_length = 14; # Length for intermediate MA
input slow_length = 21; # Length for slowest MA
input displace = 0; # Displacement for MAs
# Volume Calculations
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolper = buyvol / volume() * 100;
def sellvolper = AbsValue(sellvol) / volume() * 100;
# Moving Average Calculations
def mov_avg9 = ExpAverage(price[-displace], superfast_length);
def mov_avg14 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);
# Moving Average Aliases
def Superfast = mov_avg9;
def Fast = mov_avg14;
def Slow = mov_avg21;
# Buy and Close Buy Signals with Implied Volatility Filter
def buy = mov_avg9 > mov_avg14 and mov_avg14 > mov_avg21 and low > mov_avg9 and Imp_Volatility() < maxIV;
def stopbuy = mov_avg9 <= mov_avg14 or Imp_Volatility() >= maxIV;
def buynow = !buy[1] and buy;
def buysignal = CompoundValue(1, if buynow and !stopbuy then 1 else if buysignal[1] == 1 and stopbuy then 0 else buysignal[1], 0);
def Buy_Signal = buysignal[1] == 0 and buysignal == 1;
def Close_Buy = buysignal[1] == 1 and buysignal == 0;
# Bar Identification for Volume Bubbles
def last = !IsNaN(close) and IsNaN(close[-1]);
def prev = !IsNaN(close[1]) and IsNaN(close[-2]);
# Chart Bubbles
# Buying Volume Bubble (Green)
AddChartBubble(last or prev,
if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset,
"BuyVol: " + buyvol,
Color.GREEN,
if last then yes else no);
# Buy Signal Bubble (Cyan)
AddChartBubble(Buy_Signal,
low - TickSize() * bubbleoffset,
"BUY: " + low + "\nIV: " + Round(Imp_Volatility() * 100, 2) + "%",
Color.CYAN,
no);
# Close Buy Signal Bubble (Red)
AddChartBubble(Close_Buy,
high + TickSize() * bubbleoffset,
"Close Buy: " + high + "\nIV: " + Round(Imp_Volatility() * 100, 2) + "%",
Color.RED,
yes);
# Optional Commented-Out Bubbles for Total and Selling Volume
#AddChartBubble(last or prev, if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset, "TVol: " + volume(), Color.LIGHT_GRAY, if last then yes else no);
#AddChartBubble(last or prev, if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset, "SellVol: " + AbsValue(sellvol), Color.RED, if last then yes else no);
Any feedback is appreciated ~Adeo
Last edited by a moderator: