I don't think this is an aggregation question, but it relates to the time period for when a vertical line is plotted with reference to another ticker.
Simple idea, I want a vertical line to plot on an /ES or /NQ chart when a StochasticFullDiff signal fires for /VX.
Been striking out the past two nights trying to figure out why when I have this code loaded on a /VX chart it plots the signals (vertical lines) during all 23 hours of trading; however, when I open this study on /ES or /NQ this study only plots mostly during RTHs, during other times of the day the signals flips but it as if, for some reason the signals don't fire all the time when it's not during RTHs.
I even removed the reference portion of the default StochasticFullDiff script in order to remove any possible issues with referencing /VX as the ticker. Resulted in the same problem with /VX plotting 23 hours and only plotting /ES or /NQ sparingly outside of RTHs.
Starting to think my problem lies in the AddVerticalLine code.
Simple idea, I want a vertical line to plot on an /ES or /NQ chart when a StochasticFullDiff signal fires for /VX.
Been striking out the past two nights trying to figure out why when I have this code loaded on a /VX chart it plots the signals (vertical lines) during all 23 hours of trading; however, when I open this study on /ES or /NQ this study only plots mostly during RTHs, during other times of the day the signals flips but it as if, for some reason the signals don't fire all the time when it's not during RTHs.
I even removed the reference portion of the default StochasticFullDiff script in order to remove any possible issues with referencing /VX as the ticker. Resulted in the same problem with /VX plotting 23 hours and only plotting /ES or /NQ sparingly outside of RTHs.
Starting to think my problem lies in the AddVerticalLine code.
Code:
declare lower;
#Stochastic Full Differential Histogram with Custom painted bars.
input kPeriod = 10;
input dPeriod = 10;
input SlowingPeriod = 3;
input averageType = AverageType.SIMPLE;
input StochBars = yes;
input StochBarMultiplier = 0.25;#Used to better equalize stoch and squeeze histogram outputs in other scripts. Since the sizing varies depending on ticker.
input showBreakoutSignals = yes;
def priceH = high;
def priceL = low;
def priceC = close;
#Variables to Remove Stochastic Reference
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageType, FastK, SlowingPeriod);
def FullD = MovingAverage(averageType, FullK, DPeriod);
plot StochasticHistogram = if StochBars then (StochBarMultiplier * FullK) - (StochBarMultiplier * FullD) else Double.NaN;
plot ZeroLine = 0;
plot UpSignal = if StochasticHistogram crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if StochasticHistogram crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
StochasticHistogram.SetDefaultColor(GetColor(5));
StochasticHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
StochasticHistogram.SetLineWeight(5);
StochasticHistogram.DefineColor("Up", Color.UPTICK);
StochasticHistogram.DefineColor("Down", Color.DOWNTICK);
StochasticHistogram.AssignValueColor(if StochasticHistogram > StochasticHistogram[1] then StochasticHistogram.Color("Up") else if StochasticHistogram < StochasticHistogram[1] then StochasticHistogram.Color("Down") else GetColor(1));
ZeroLine.SetDefaultColor(GetColor(8));
StochasticHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
StochasticHistogram.SetLineWeight(5);
StochasticHistogram.DefineColor("Positive and Up", Color.GREEN);
StochasticHistogram.DefineColor("Positive and Down", GetColor(4));
StochasticHistogram.DefineColor("Negative and Down", Color.RED);
StochasticHistogram.DefineColor("Negative and Up", Color.YELLOW);
StochasticHistogram.AssignValueColor(if StochasticHistogram >= 0 then if StochasticHistogram > StochasticHistogram[1] then StochasticHistogram.Color("Positive and Up") else StochasticHistogram.Color("Positive and Down") else if StochasticHistogram < StochasticHistogram[1] then StochasticHistogram.Color("Negative and Down") else StochasticHistogram.Color("Negative and Up"));
DefineGlobalColor("Positive and UP“, Color.GREEN);
DefineGlobalColor("Positive and Down", GetColor(4));
DefineGlobalColor("Negative and Down", Color.RED);
DefineGlobalColor("Negative and Up", GetColor(4));
#Stochastic Histogram FLIP for /VX
#Displays as Vertical Line on Chart
#Stochastic Reference Removal
input Ticker = {default "/VX", "/VX/VVIX", "/6J//VX"};
def TickerPriceH = high(Ticker);
def TickerPriceL = low(Ticker);
def TickerPriceC = close(Ticker);
def Tickerlowest_k = Lowest(TickerpriceL, KPeriod);
def Tickerc1 = TickerpriceC - Tickerlowest_k;
def Tickerc2 = Highest(TickerpriceH, KPeriod) - Tickerlowest_k;
def TickerFastK = if Tickerc2 != 0 then Tickerc1 / Tickerc2 * 100 else 0;
def TickerZeroLine = 0;
def TickerFullK = MovingAverage(averageType, TickerFastK, SlowingPeriod);
def TickerFullD = MovingAverage(averageType, TickerFullK, DPeriod);
def TickerStochasticHistogram = TickerFullK - TickerFullD;
def TickerUpSignal = if TickerStochasticHistogram crosses above TickerZeroLine then TickerZeroLine else Double.NaN;
def TickerDownSignal = if TickerStochasticHistogram crosses below TickerZeroLine then TickerZeroLine else Double.NaN;
#/VX vertical line on indicator
AddVerticalLine(TickerStochasticHistogram crosses below TickerZeroLine, "BUY", Color.GREEN, Curve.FIRM);
AddVerticalLine(TickerStochasticHistogram crosses above TickerZeroLine, "SELL", Color.RED, Curve.FIRM);
Last edited: