• Get $40 off VIP by signing up for a free account! Sign Up

the time period for when a vertical line is plotted with reference to another ticker.

ben

New member
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.

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:
Solution
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...
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.

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);
Because of missing bars on /VX compared to those on /ES, then you need to cover that situation with

Code:
def TickerPriceH = if isnan(high(Ticker)) then tickerpriceH[1] else high(Ticker);

def TickerPriceL = if isnan(low(Ticker)) then tickerpriceL[1] else low(Ticker);

def TickerPriceC = if isnan(close(Ticker)) then tickerpriceC[1] else close(Ticker);

Capture.jpg
Ruby:
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 = if isnan(high(Ticker)) then tickerpriceH[1] else high(Ticker);
def TickerPriceL = if isnan(low(Ticker)) then tickerpriceL[1] else low(Ticker);
def TickerPriceC = if isnan(close(Ticker)) then tickerpriceC[1] else 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);
 
  • Like
Reactions: ben
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
397 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top