Volatility Box Indicator for ThinkorSwim

Hey fellas,

This is very interesting and I thought I'd throw my 2cents in for the benefit of the group. Awhile back the group that designed the original volatility box indicator also created a free script called SupplyDemandEdge...which is supposed to work well with the Volatility Box. It seems to be a nice enhancement. It is simply long/short $ADSPD signals and long/short $TICK signals. I have included the script below.

Anyone, is there a way to keep the signal arrows from laying over the top of one another? I seem to remember a script from a long time ago that had one down arrow just above the candle (lets say red) and another down arrow (white) just above the red candle.

Note: The youtube vid that shows them designing this script is here. At about 14:30 they test it.

Code:
# Supply_Demand_Edge .... an enhancement to the Volatility Box
#TOS Indicators
#Home of the Volatility Box


# modified by @RickKennedy to include signals from previous days

declare upper;
declare hide_on_daily;

input showTicks = yes;
input showAD = yes;
input ShowTodayOnly = no;

def regularSession = secondsFromTime(0930) > 0 && secondsTillTime(1600) > 0;
def hod = if regularSession then if (high > hod[1]) then high else hod[1] else high;
def lod = if regularSession then if (low < lod[1]) then low else lod[1] else low;
def highAD = if regularSession then if (high(symbol="$ADSPD") > highAD[1]) then high(symbol="$ADSPD") else highAD[1] else high(symbol="$ADSPD");
def lowAD = if regularSession then if (low(symbol="$ADSPD") < lowAD[1]) then low(symbol="$ADSPD") else lowAD[1] else low(symbol="$ADSPD");
def highTick = if regularSession then if (high(symbol="$TICK") > highTick[1]) then high(symbol="$TICK") else highTick[1] else high(symbol="$TICK");
def lowTick = if regularSession then if (low(symbol="$TICK") < lowTick[1]) then low(symbol="$TICK") else lowTick[1] else low(symbol="$TICK");

def currentHighAD = high(symbol="$ADSPD");
def currentLowAD = low(symbol="$ADSPD");
def currentHighTick = high(symbol="$TICK");
def currentLowTick = low(symbol="$TICK");

plot ADShortSignal = showAD && high == hod && currentHighAD < highAD;
ADShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ADShortSignal.SetDefaultColor(Color.WHITE);
ADShortSignal.SetLineWeight(1);

plot ADLongSignal = showAD && low == lod && currentLowAD > LowAD;
ADLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ADLongSignal.SetDefaultColor(Color.WHITE);
ADLongSignal.SetLineWeight(1);

plot TickShortSignal = showTicks && high == hod && currentHighTick < highTick;
TickShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TickShortSignal.SetDefaultColor(Color.RED);
TickShortSignal.SetLineWeight(2);

plot TickLongSignal = showTicks && low == lod && currentLowTick > lowTick;
TickLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TickLongSignal.SetDefaultColor(Color.LIGHT_GREEN);
TickLongSignal.SetLineWeight(2);

#end Supply_Demand_Edge
 
Last edited:

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

So I have a little more information on the origin of the volatility box offered by TOS indicators, and how it works. Perhaps this could be useful for those with the knowledge to replicate a like-for-like version of the indicator that the guys at TOS indicators are selling for a marked up price.

The nuts and bolts of this indicator lies within its use of the statistical volatility analysis data pulled from Autochartist, this is used to plot the levels, as far as I can see, there are different levels of probability which could be used for more aggressive and/or conservative levels. In order for these levels to be highly accurate, the indicator and the data feeding into the indicator would need to be updated weekly. All of this data can be pulled via the Autochartist API or via their regularly updated CSV files listed with each instrument within their web app.

The one caveat here is that, an Autochartist subscription is required. As far as I am aware, this is relatively cheap, and can be obtained via a few providers listed at the bottom of the page here. I saw that chartviper offer access to the Autochartist web platform for a monthly subscription of $29/pm. I have a feeling the TOS Indicator guys may have subscriptions with services that offer both stock and future asset classes, I guess it would depend on what you would need.

If you're curious about the Autochartist platform, these videos may also be interesting to take a look at, it seems like a powerful tool for pulling highly probable data.

After a little more digging, it looks as if the origin of this indicator was actually made popular by some older FX traders back in 2010. I also found a few more examples of the indicator here. Raghee Horner also uses this same logic to create a very similar indicator that she calls HPMR. I was also able to find a guide that details some of the calculations for how this is data is parsed which may be helpful when recreating the indicator.

I guess the real value/ask here is if someone is able to create a way to either translate the data from Autochartist into a ThinkScript indicator (updated weekly), or at least provide a few simple algorithms that parse the data so that others could do it themselves. Doing so would basically mean that we have the volatility box for a fraction of the price.

@horserider @BenTen
 
So I have a little more information on the origin of the volatility box offered by TOS indicators, and how it works. Perhaps this could be useful for those with the knowledge to replicate a like-for-like version of the indicator that the guys at TOS indicators are selling for a marked up price.

The nuts and bolts of this indicator lies within its use of the statistical volatility analysis data pulled from Autochartist, this is used to plot the levels, as far as I can see, there are different levels of probability which could be used for more aggressive and/or conservative levels. In order for these levels to be highly accurate, the indicator and the data feeding into the indicator would need to be updated weekly. All of this data can be pulled via the Autochartist API or via their regularly updated CSV files listed with each instrument within their web app.

The one caveat here is that, an Autochartist subscription is required. As far as I am aware, this is relatively cheap, and can be obtained via a few providers listed at the bottom of the page here. I saw that chartviper offer access to the Autochartist web platform for a monthly subscription of $29/pm. I have a feeling the TOS Indicator guys may have subscriptions with services that offer both stock and future asset classes, I guess it would depend on what you would need.

If you're curious about the Autochartist platform, these videos may also be interesting to take a look at, it seems like a powerful tool for pulling highly probable data.

After a little more digging, it looks as if the origin of this indicator was actually made popular by some older FX traders back in 2010. I also found a few more examples of the indicator here. Raghee Horner also uses this same logic to create a very similar indicator that she calls HPMR. I was also able to find a guide that details some of the calculations for how this is data is parsed which may be helpful when recreating the indicator.

I guess the real value/ask here is if someone is able to create a way to either translate the data from Autochartist into a ThinkScript indicator (updated weekly), or at least provide a few simple algorithms that parse the data so that others could do it themselves. Doing so would basically mean that we have the volatility box for a fraction of the price.

@horserider @BenTen

@james-smith If someone can get the Options volatility spreads to show as lines daily / weekly / monthly I think that would fit the bill. Pretty sure that's all the spreads are for autochartist anyway after comparing the product with the TOS Options chain tab.
 
So, it's not that reliable of an indicator if it keeps changing. Does anyone have a great indicator that is highly accurate for swing trading? It's hard to search for best indicators lol. I'm looking for something that can be trusted with solid entry/exits and hold for a couple days or so. Any help would be appreciated...
Use pivot points or ATR support resistance
 
I am having a little issue here when I apply the code. My chart looks totally different with 15 min time Frame. Here is the code that I have used. Please help .. @Huffmac90 .. @BenTen

I am not able to share the image over here.


Code:
#VolumeProfile_IntradaySelection with Expanded Intraday Period Selections plus
#
#the Prior Day's Value Areas
#INPUTS
input showlines = yes;
input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = .01;
input timePerProfile = {CHART, MINUTE, MIN2, MIN3, MIN4, MIN5, MIN10, default MIN15, MIN20, MIN30, HOUR, TWOHOUR, FOURHOUR, DAY , TWODAY, THREEDAY, FOURDAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 100.0;
input valueAreaPercent2 = 87.5;
input opacity            = 0;
def period;
def agg;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt      = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
period = 0;
agg = AggregationPeriod.DAY;
case MINUTE:
period = Floor(seconds / 60 + day_number * 24 * 60);
agg = AggregationPeriod.MIN;
case MIN2:
period = Floor(seconds / 120 + day_number * 24);
agg = AggregationPeriod.TWO_MIN;
case MIN3:
period = Floor(seconds / 180 + day_number * 24);
agg = AggregationPeriod.THREE_MIN;
case MIN4:
period = Floor(seconds / 240 + day_number * 24);
agg = AggregationPeriod.FOUR_MIN;
case MIN5:
period = Floor(seconds / 300 + day_number * 24);
agg = AggregationPeriod.FIVE_MIN;
case MIN10:
period = Floor(seconds / 600 + day_number * 24);
agg = AggregationPeriod.TEN_MIN;
case MIN15:
period = Floor(seconds / 900 + day_number * 24);
agg = AggregationPeriod.FIFTEEN_MIN;
case MIN20:
period = Floor(seconds / 1200 + day_number * 24);
agg = AggregationPeriod.TWENTY_MIN;
case MIN30:
period = Floor(seconds / 1800 + day_number * 24);
agg = AggregationPeriod.THIRTY_MIN;
case HOUR:
period = Floor(seconds / 3600 + day_number * 24);
agg = AggregationPeriod.HOUR;
case TWOHOUR:
period = Floor(seconds / 7200 + day_number * 24);
agg = AggregationPeriod.TWO_HOURS;
case FOURHOUR:
period = Floor(seconds / 14400 + day_number * 24);
agg = AggregationPeriod.FOUR_HOURS;
case DAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
agg = AggregationPeriod.DAY;
case TWODAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
agg = AggregationPeriod.TWO_DAYS;
case THREEDAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
agg = AggregationPeriod.THREE_DAYS;
case FOURDAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
agg = AggregationPeriod.FOUR_DAYS;
case WEEK:
period = Floor(day_number / 7);
agg = AggregationPeriod.WEEK;
case MONTH:
period = Floor(month - First(month));
agg = AggregationPeriod.MONTH;
case "OPT EXP":
period = exp_opt - First(exp_opt);
agg = AggregationPeriod.DAY;
case BAR:
period = BarNumber() - 1;
agg = AggregationPeriod.DAY;
}
def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % (if timePerProfile == timePerProfile.TWODAY then 2 else if timePerProfile == timePerProfile.THREEDAY then 3 else if timePerProfile == timePerProfile.FOURDAY then 4 else multiplier) else count[1], 0);
def cond = count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}
profile vol     = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion or showlines;
plot POC         = if plotsDomain then pc       else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow  = if plotsDomain then lProfile else Double.NaN;
def VAHigh       = if plotsDomain then hVA      else Double.NaN;
def VALow        = if plotsDomain then lVA      else Double.NaN;
DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", Color.CYAN);
DefineGlobalColor("Value Area", GetColor(8));
vol.Show(color = Color.CURRENT, opacity = opacity, "poc color" = Color.CURRENT);
def pc1   = if pc  != pc[1]  then pc[1]  else pc1[1];
def pc2 = if pc1 != pc1[1] then pc1[1] else pc2[1];
rec uppoc = if pc1 > pc      then 1 else if uppoc[1] == 1 and pc1 >= pc then 1 else 0;
POC.AssignValueColor(if uppoc == 1 then Color.RED else Color.GREEN);
POC.SetLineWeight(2);
ProfileHigh.SetStyle(Curve.POINTS);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.Hide();
ProfileLow.Hide();
input showarrows       = no;
input arrowsensitivity = 1;#Hint arrowsensitivity: number of ticks within 95% to create an arrow
def dn = if high >= VAHigh - TickSize() * arrowsensitivity
then 1
else if dn[1] == 1 and high >= VAHigh - TickSize() * arrowsensitivity
then 1
else 0;
plot dnarrow = if showarrows and dn[1] == 0 and dn == 1
then high + .02
else Double.NaN;
def up = if low <= VALow + TickSize() * arrowsensitivity
then 1
else if up[1] == 1 and low <= VALow + TickSize() * arrowsensitivity
then 1
else 0;
plot uparrow = if showarrows and up[1] == 0 and up == 1
then low - .02
else Double.NaN;
dnarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
dnarrow.SetDefaultColor(Color.YELLOW);
uparrow.SetDefaultColor(Color.WHITE);
profile vol1  = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent2);
def hVA1 = if IsNaN(vol1.GetHighestValueArea()) and con then hVA[1] else vol1.GetHighestValueArea();
def lVA1 = if IsNaN(vol1.GetLowestValueArea()) and con then lVA[1] else vol1.GetLowestValueArea();
def upvah1 = if hVA1[1] < hVA1 then 1 else if upvah1[1] == 1 and hVA1[1] <= hVA1 then 1 else 0;
def upval1 = if lVA1[1] < lVA1 then 1 else if upval1[1] == 1 and lVA1[1] <= lVA1 then 1 else 0;
plot VAHigh1 = if plotsDomain then hVA1 else Double.NaN;
plot VALow1 = if plotsDomain then lVA1 else Double.NaN;
VAHigh1.SetStyle(Curve.SHORT_DASH);
VALow1.SetStyle(Curve.SHORT_DASH);
#addcloud(vahigh,vahigh1,color.light_orange, color2 = Color.LIGHT_ORANGE);
#addcloud(valow1,valow,Color.LIGHT_GRAY, color2 = Color.LIGHT_GRAY);
def upvah = if hVA[1] < hVA then 1 else if upvah[1] == 1 and hVA[1] <= hVA then 1 else 0;
def upval = if lVA[1] < lVA then 1 else if upval[1] == 1 and lVA[1] <= lVA then 1 else 0;
def green = upvah1 == 1 and upval1 == 1;
def red = upvah1 == 0 and upval1 == 0;
def green1 = if green then 1 else if green1[1] == 1 and !red then 1 else 0;
def green1ext = if IsNaN(close) then green1ext[1] else green1;
def g1ext = green1ext;
def g1 = green1ext;
def red1 = if red then 1 else if red1[1] == 1 and !green then 1 else 0;
def red1ext = if IsNaN(close) then red1ext[1] else red1;
def r1ext = red1ext;
def r1        = red1;
VAHigh1.AssignValueColor(if green1 then Color.GREEN else Color.RED);
VALow1.AssignValueColor (if green1 then Color.GREEN else Color.RED);
plot vahplot = VAHigh;
vahplot.AssignValueColor(if green1 then Color.GREEN else Color.RED);
plot valplot = VALow;
valplot.AssignValueColor(if green1 then Color.GREEN else Color.RED);
def vahext = if IsNaN(close) then vahext[1] else VAHigh;
plot vahextp = vahext;
vahextp.AssignValueColor(if green1ext then Color.GREEN else Color.RED);
def valext = if IsNaN(close) then valext[1] else VALow;
plot valextp = valext;
valextp.AssignValueColor(if green1ext then Color.GREEN else Color.RED);
def vah1ext = if IsNaN(close) then vah1ext[1] else VAHigh1;
plot vah1extp = vah1ext;
vah1extp.AssignValueColor(if green1ext then Color.GREEN else Color.RED);
def val1ext = if IsNaN(close) then val1ext[1] else VALow1;
plot val1extp = val1ext;
val1extp.AssignValueColor(if green1ext then Color.GREEN else Color.RED);
input showclouds = no;
AddCloud(if showclouds and g1ext then vahextp else Double.NaN, vah1extp, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(if showclouds and g1ext then val1extp else Double.NaN, valextp, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(if showclouds and r1ext then vahextp else Double.NaN, vah1extp, Color.DARK_RED, Color.DARK_RED);
AddCloud(if showclouds and r1ext then val1extp else Double.NaN, valextp,  Color.DARK_RED, Color.DARK_RED);
POC.HideBubble();
VAHigh1.HideBubble();
VALow1.HideBubble();
vahplot.HideBubble();
valplot.HideBubble();
uparrow.HideBubble();
dnarrow.HideBubble();
vahextp.HideBubble();
vah1extp.HideBubble();
valextp.HideBubble();
val1extp.HideBubble();
input showbubbleperperiod = no;
input bubblemoverperperiodhorizontal = 10;
input bubblemoverperperiodvertical  = 2;
def bubble = if period[1] != period then BarNumber() + bubblemoverperperiodhorizontal else bubble[1];
AddChartBubble(showbubbleperperiod and BarNumber() == (bubble), Max(high, VAHigh) + bubblemoverperperiodvertical * TickSize(), (VAHigh - VALow) + "\n" + (VAHigh1 - VALow1) , if green then Color.GREEN else if red then Color.RED else Color.GRAY, yes);
input showcurrentperiodbubble = no;
input x = 8;
def x1  = x + 1;
AddChartBubble(showcurrentperiodbubble and !IsNaN(close[x1]) and IsNaN(close[x]), close[x1], (VAHigh[x1] - VALow[x1]) + " :\n" + volume(period = agg), if green[x1] then Color.GREEN else if red[x1] then Color.RED else Color.GRAY);
input n = 5;
def n1 = n + 1;
input showbubblesVAvalues = no;
AddChartBubble(showbubblesVAvalues and !IsNaN(close[n1]) and IsNaN(close[n]), Round(POC[n1], 2) , "POC: " + Round(POC[n1], 2), if uppoc[n1] == 1 then Color.RED else Color.GREEN, yes);
AddChartBubble(showbubblesVAvalues and !IsNaN(close[n1]) and IsNaN(close[n]), Round(VALow1[n1], 2) , "VL: " + Round(VALow1[n1], 2), if upval[n1] == 1 then Color.RED else Color.GREEN, yes);
AddChartBubble(showbubblesVAvalues and !IsNaN(close[n1]) and IsNaN(close[n]), Round(VALow[n1], 2) , "VL1: " + Round(VALow[n1], 2), if upval1[n1] == 1 then Color.RED else Color.GREEN, yes);
AddChartBubble(showbubblesVAvalues and !IsNaN(close[n1]) and IsNaN(close[n]), Round(VAHigh1[n1], 2) , "VH: " + Round(VAHigh1[n1], 2), if upvah1[n1] == 1 then Color.RED else Color.GREEN, yes);
AddChartBubble(showbubblesVAvalues and !IsNaN(close[n1]) and IsNaN(close[n]), Round(VAHigh[n1], 2) , "VH1: " + Round(VAHigh[n1], 2), if upvah[n1] == 1 then Color.RED else Color.GREEN, yes);
#Squeeze Added
input showsqueeze = no;
def bbupper = reference BollingerBands().UpperBand;
def kcupper = KeltnerChannels().Upper_Band;
def Squeeze = bbupper - kcupper < 0;
plot Squeezeplot = if showsqueeze and Squeeze then POC else Double.NaN;
Squeezeplot.SetDefaultColor(Color.WHITE);
Squeezeplot.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeezeplot.SetLineWeight(3);
Squeezeplot.HideBubble();
#Count of Periods in consecutive squeeze
rec countsq = if Squeeze then countsq[1] + 1 else 0;
rec count1sq = if !Squeeze then count1sq[1] + 1 else 0;
#Expansion Bubbles
input q = 3;
def q1 = q + 1;
AddChartBubble(showsqueeze and !IsNaN(close[q1]) and IsNaN(close[q]), POC[q1] , if Squeeze[q1] then "S " + Round(countsq[q1], 2) else "NS " + count1sq[q1] , if DMI_Oscillator()[q1] < 0 then Color.RED else Color.GREEN, no);
#COLORBARS
input pricecolor = yes;
AssignPriceColor(
if PRICECOLOR then
if dn[1] == 0 and dn == 1 then COLOR.RED else
if up[1] == 0 and up == 1 then COLOR.GREEN else
COLOR.GRAY
else
COLOR.CURRENT
);

#END OF STUDY
 
Last edited:
So I have a little more information on the origin of the volatility box offered by TOS indicators, and how it works. Perhaps this could be useful for those with the knowledge to replicate a like-for-like version of the indicator that the guys at TOS indicators are selling for a marked up price.

The nuts and bolts of this indicator lies within its use of the statistical volatility analysis data pulled from Autochartist, this is used to plot the levels, as far as I can see, there are different levels of probability which could be used for more aggressive and/or conservative levels. In order for these levels to be highly accurate, the indicator and the data feeding into the indicator would need to be updated weekly. All of this data can be pulled via the Autochartist API or via their regularly updated CSV files listed with each instrument within their web app.

The one caveat here is that, an Autochartist subscription is required. As far as I am aware, this is relatively cheap, and can be obtained via a few providers listed at the bottom of the page here. I saw that chartviper offer access to the Autochartist web platform for a monthly subscription of $29/pm. I have a feeling the TOS Indicator guys may have subscriptions with services that offer both stock and future asset classes, I guess it would depend on what you would need.

If you're curious about the Autochartist platform, these videos may also be interesting to take a look at, it seems like a powerful tool for pulling highly probable data.

After a little more digging, it looks as if the origin of this indicator was actually made popular by some older FX traders back in 2010. I also found a few more examples of the indicator here. Raghee Horner also uses this same logic to create a very similar indicator that she calls HPMR. I was also able to find a guide that details some of the calculations for how this is data is parsed which may be helpful when recreating the indicator.

I guess the real value/ask here is if someone is able to create a way to either translate the data from Autochartist into a ThinkScript indicator (updated weekly), or at least provide a few simple algorithms that parse the data so that others could do it themselves. Doing so would basically mean that we have the volatility box for a fraction of the price.

@horserider @BenTen
has there been a code written for this? I can get the calculations for the historic volatility I just want it to be auto into tos, I dont mind pulling the data from autochartist.
 
Not sure if anyone has asked yet but is it possible to make a scan for arrows? I keep "Unexpected error". When I try and save Scan. For the PRC_Volatility Cycle Breakout | indicator
 
Not sure if anyone has asked yet but is it possible to make a scan for arrows? I keep "Unexpected error". When I try and save Scan. For the PRC_Volatility Cycle Breakout | indicator

What is the error you are receiving...???
 
I don't know how to paste a screen shot but it is the one that says there is an error and you can view the "technical details":

Code:
Unexpected error detected.
java.lang.IllegalStateException
Error unpacking script PRC_Volatility_Cycle_BO {
#TITLE
#PRC_Volatility Cycle Breakout | indicator
 
@kmg526 Please see How to insert image in a post thread? for information o how to insert images...

Which script code are you using...??? Have you made any modifications to said code...??? I see the code you are using...
I have to modify for code to work for a scan..I had changed the plots -> def and made a plot scan = for my scan plot. If that is not the way..how should I do it?

Code:
#TITLE
#PRC_Volatility Cycle Breakout | indicator

#DESCRIPTION
#The Volatility Cycle Breakout indicator draws range boxes overlaid on the price chart.
#The upper and lower side of the boxes are made from recent Fractals.
#New boxes will be drawn only if the volatility is weak and
#if the new fractals discovered are far enough from the current upper and lower ones.
#
#The volatility cycle is extracted from Bollinger Bands (InpBandsPeriod=18 is the bands period).
#Fractals lookback periods can be adapted to catch new fractals far in the history
#or near of the current price (cp=10).
#
#The change variable is the percent variation needed to change the support and resistance
#levels of the boxes (0.1% seems to work fine for intraday timeframes on forex pairs for instance).
#
#This setting is important because it will reduce the noises of moving boxes each
#time new Fractals are discovered, specially when price is ranging. It results
#erfect range boxes on price to play mean reversion strategy when price is not moving enough
#to make real breakout.

#CREDITS
#https://www.prorealcode.com/prorealtime-indicators/volatility-breakout-indicator/
#https://www.prorealcode.com/user/nicolas/

#CHANGELOG
#2019.11.03 @diazlaz Initial Port

declare upper;

#INPUTS
input InpBandsPeriod = 18; #Period
input Smooth = 2; #Smoothness
input cp = 10; #Fractals periods
input change = 0.1; #Percent change to modify the upper/lower channel
input showArrows = no; # price cross channels signals

#LOGIC
def StdDev = StDev(close, InpBandsPeriod);

def highindex = Highest(StdDev, InpBandsPeriod)[1];
def lowindex = Lowest(StdDev, InpBandsPeriod)[1];

def VolDer = (StdDev - highindex) / (highindex - lowindex);
def VolSmooth = Average(VolDer, Smooth);

def VolSmooth1 = if VolSmooth > 0 then 0 else
if VolSmooth < -1.0 then -1.0 else VolSmooth;

def LH = if high[cp] >= Highest(high, (2 * cp + 1)) then 1 else 0;
def LL = if low[cp] <= Lowest(low, (2 * cp + 1)) then -1 else 0;

def TOPy = if LH == 1 then high[cp] else TOPy[1];
def BOTy = if LL == -1 then low[cp] else BOTy[1];

def upperchannel = if VolSmooth1 == -1.0 then
if AbsValue(TOPy - CompoundValue(1, upperchannel[1], 0)) / close > change / 100
then TOPy else upperchannel[1]
else upperchannel[1];

def lowerchannel = if VolSmooth1 == -1.0 then
if AbsValue(BOTy - CompoundValue(1, lowerchannel[1], 0)) / close > change / 100
then BOTy else lowerchannel[1]
else lowerchannel[1];

#PLOTS
def pUpperChannel = upperchannel;
#pUpperChannel.SetLineWeight(2);
#pUpperChannel.SetDefaultColor(CreateColor(100,150,100));

def pLowerChannel = lowerchannel;
#pLowerChannel.SetLineWeight(2);
#pLowerChannel.SetDefaultColor(CreateColor(150,100,100));

#ARROWS
def pUP = close crosses above lowerchannel;
#pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#pUP.SetDefaultColor(Color.GREEN);
#pUP.SetLineWeight(2);
#pUP.SetHiding(!showArrows);

def pDown = close crosses below upperchannel;
#pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#pDown.SetDefaultColor(Color.RED);
#pDown.SetLineWeight(2);
#pDown.SetHiding(!showArrows);

#FILLS
#AddCloud(pUpperChannel, pLowerChannel,COLOR.GRAY,COLOR.GRAY, yes);
plot scan = pUP is true;
#END OF PRC_Volatility Cycle Breakout | indicator
 
@kmg526 Don't paste the code directly into your scanner like that. First thing you need to do is add the original code as an indicator. Then, set up your scanner through the conditional wizard. Easier that way.
 
it uses yesterday's high and low to create a midpoint to use as a reference point, and ATR and ADR to create a range.
the x3 range is what seems to be the reversal sweet spot. I use it on currency Futures
 
Last edited:
@TonXas this looks interesting...how does it work or how do you trade with it?
it uses yesterday's high and low to create a midpoint to use as a reference point, and ATR and ADR to create a range.
the x3 range is what seems to be the reversal sweet spot. I use it on currency Futures
 
Hi guys, been a member for a little while here and it is time I share with you guys my take on this volatility box, which I have now dubbed "The Hot Zones." I really need help with creating a scanner out of this so if anyone can help I would really appreciate it. After going through this thread, I saw that one of the big issues was the repainting feature, and needless to say everything I have modified with the hot zones still has the repainting feature (because it is based off the POC-which is dynamic, and the high and low of the profile), but with the correct settings (which I believe I have found for how I trade-I'm a day trader) along with using the study on a higher time frame-which is really what I want to create the scanner for- I believe this is an extremely powerful tool. Take a look at the images below:

https%3A//i.imgur.com/kfcpF8R.png[/img]']
kfcpF8R.png



Please be advised that I do not solely base my entries and exits on the hot zones indicator (except for the daily chart) those settings are very powerful. The idea is to find stocks that are near or that have crossed into their hot zones on the daily chart and then move to a lower time frame to manage the entries and exits. Of course I am open to suggestions on any more modifications. The last caveat I have for you guys is that I am a volume based trader, which this study is based on (volumeprofile), on one of my screens I leave open a 10 day 5-min chart to verify where High and Low volume nodes are which is my extra layer of confirmation with the hot zones indicator. I suggest familiarizing yourself with VolumeProfile before using this indicator (if you are unfamiliar). Please let me know what you guys think and to reiterate, I am really looking for input to develop a scanner for the daily chart.


Code:
#HOT_ZONES_ slight modifications which include some of the COG indicator from this site. this is not original code, it is modified
#Higher_TIME_FRAME on Lower time frame chart

input showlines             = yes;

input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM};

input customRowHeight       = .01;

input timePerProfile        = {CHART, MINUTE, MIN2, MIN3, MIN4, MIN5, MIN10,  default  MIN15, MIN20,  MIN30, HOUR, TWOHOUR, FOURHOUR, DAY , TWODAY, THREEDAY, FOURDAY, WEEK, MONTH, "OPT EXP", BAR};

input multiplier         = 1;

input onExpansion        = no;

input profiles           = 1000;

input showPointOfControl = yes;

input showValueArea      = yes;

input valueAreaPercent   = 100.0;

input valueAreaPercent2  = 87.5;

input opacity            = 0;



def period;

def agg;

def yyyymmdd   = GetYYYYMMDD();

def seconds    = SecondsFromTime(0);

def month      = GetYear() * 12 + GetMonth();

def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));

def dom        = GetDayOfMonth(yyyymmdd);

def dow        = GetDayOfWeek(yyyymmdd - dom + 1);

def expthismonth = (if dow > 5 then 27 else 20) - dow;

def exp_opt      = month + (dom > expthismonth);

switch (timePerProfile) {

case CHART:

    period = 0;

    agg = AggregationPeriod.DAY;

case MINUTE:

    period = Floor(seconds / 60 + day_number * 24 * 60);

    agg = AggregationPeriod.MIN;

case MIN2:

    period = Floor(seconds / 120 + day_number * 24);

    agg = AggregationPeriod.TWO_MIN;

case MIN3:

    period = Floor(seconds / 180 + day_number * 24);

    agg = AggregationPeriod.THREE_MIN;

case MIN4:

    period = Floor(seconds / 240 + day_number * 24);

    agg = AggregationPeriod.FOUR_MIN;

case MIN5:

    period = Floor(seconds / 300 + day_number * 24);

    agg = AggregationPeriod.FIVE_MIN;

case MIN10:

    period = Floor(seconds / 600 + day_number * 24);

    agg = AggregationPeriod.TEN_MIN;

case MIN15:

    period = Floor(seconds / 900 + day_number * 24);

    agg = AggregationPeriod.FIFTEEN_MIN;

case MIN20:

    period = Floor(seconds / 1200 + day_number * 24);

    agg = AggregationPeriod.TWENTY_MIN;

case MIN30:

    period = Floor(seconds / 1800 + day_number * 24);

    agg = AggregationPeriod.THIRTY_MIN;

case HOUR:

    period = Floor(seconds / 3600 + day_number * 24);

    agg = AggregationPeriod.HOUR;

case TWOHOUR:

    period = Floor(seconds / 7200 + day_number * 24);

    agg = AggregationPeriod.TWO_HOURS;

case FOURHOUR:

    period = Floor(seconds / 14400 + day_number * 24);

    agg = AggregationPeriod.FOUR_HOURS;

case DAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.DAY;

case TWODAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.TWO_DAYS;

case THREEDAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.THREE_DAYS;

case FOURDAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.FOUR_DAYS;

case WEEK:

    period = Floor(day_number / 7);

    agg = AggregationPeriod.WEEK;

case MONTH:

    period = Floor(month - First(month));

    agg = AggregationPeriod.MONTH;

case "OPT EXP":

    period = exp_opt - First(exp_opt);

    agg = AggregationPeriod.DAY;

case BAR:

    period = BarNumber() - 1;

    agg = AggregationPeriod.DAY;

}



def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % (if timePerProfile == timePerProfile.TWODAY then 2 else if timePerProfile == timePerProfile.THREEDAY then 3 else if timePerProfile == timePerProfile.FOURDAY then 4 else multiplier) else count[1], 0);



def cond = count < count[1] + period - period[1];

def height;

switch (pricePerRowHeightMode) {

case AUTOMATIC:

    height = PricePerRow.AUTOMATIC;

case TICKSIZE:

    height = PricePerRow.TICKSIZE;

case CUSTOM:

    height = customRowHeight;

}



profile vol     = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);

def con         = CompoundValue(1, onExpansion, no);

def pc          = if IsNaN(vol.GetPointOfControl())   and con then pc[1]  else vol.GetPointOfControl();

def hVA         = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();

def lVA         = if IsNaN(vol.GetLowestValueArea())  and con then lVA[1] else vol.GetLowestValueArea();

def hProfile    = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();

def lProfile    = if IsNaN(vol.GetLowest())  and con then lProfile[1] else vol.GetLowest();

def plotsDomain = IsNaN(close) == onExpansion or showlines;

def pct = 100;
input width = 75;
input price = close;
def d = width / pct;
def d1 = 0.909 * d;
def d2 = 1.0 * d;
def d3 = 1.272 * d;
def stdDeviation1 = HighestAll("data" = AbsValue(PC - lProfile));
def stdDeviation2 = HighestAll("data" = AbsValue(hProfile - pc));



plot POC         = if plotsDomain then pc       else Double.NaN;

plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;

plot ProfileLow  = if plotsDomain then lProfile else Double.NaN;

def VAHigh       = if plotsDomain then hVA      else Double.NaN;

def VALow        = if plotsDomain then lVA      else Double.NaN;

plot UpperLine = pc + stdDeviation2 * d1;
plot LowerLine = pc - stdDeviation1 * d1;
plot UpperLine1 = pc + stdDeviation2 * d2;
plot LowerLine1 = pc - stdDeviation1 * d2;
plot UpperLine2 = pc + stdDeviation2 * d3;
plot LowerLine2 = pc - stdDeviation1 * d3;

UpperLine.SetStyle(Curve.SHORT_DASH);
UpperLine.SetDefaultColor(Color.GRAY);
UpperLine1.SetStyle(Curve.SHORT_DASH);
UpperLine1.SetDefaultColor(Color.LIGHT_RED);
UpperLine2.SetStyle(Curve.FIRM);
UpperLine2.SetDefaultColor(Color.RED);
LowerLine.SetStyle(Curve.SHORT_DASH);
LowerLine.SetDefaultColor(Color.GRAY);
LowerLine1.SetStyle(Curve.SHORT_DASH);
LowerLine1.SetDefaultColor(Color.LIGHT_GREEN);
LowerLine2.SetStyle(Curve.FIRM);
LowerLine2.SetDefaultColor(Color.GREEN);



DefineGlobalColor("Profile", GetColor(1));

DefineGlobalColor("Point Of Control", Color.CYAN);

DefineGlobalColor("Value Area", GetColor(8));



AddCloud(UpperLine2, UpperLine1, Color.RED, Color.RED);
AddCloud(LowerLine2, LowerLine1, Color.GREEN, Color.GREEN);

Settings for 1 day 1 min chart:
Time per profile: FOURHOUR
Width: 90
(I Turn off the ProfileHigh and ProfileLow)

Settings for 1 year 1 day chart:
Time per profile: Month
Width: 90
(I Turn off the ProfileHigh and ProfileLow)


Code:
#HOT_ZONES this code is for secondary hot zones on a smaller profile setting, again not original code, it has just been modified

input showlines             = yes;

input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM};

input customRowHeight       = .01;

input timePerProfile        = {CHART, MINUTE, MIN2, MIN3, MIN4, MIN5, MIN10,  default  MIN15, MIN20,  MIN30, HOUR, TWOHOUR, FOURHOUR, DAY , TWODAY, THREEDAY, FOURDAY, WEEK, MONTH, "OPT EXP", BAR};

input multiplier         = 1;

input onExpansion        = no;

input profiles           = 1000;

input showPointOfControl = yes;

input showValueArea      = yes;

input valueAreaPercent   = 100.0;

input valueAreaPercent2  = 87.5;

input opacity            = 0;



def period;

def agg;

def yyyymmdd   = GetYYYYMMDD();

def seconds    = SecondsFromTime(0);

def month      = GetYear() * 12 + GetMonth();

def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));

def dom        = GetDayOfMonth(yyyymmdd);

def dow        = GetDayOfWeek(yyyymmdd - dom + 1);

def expthismonth = (if dow > 5 then 27 else 20) - dow;

def exp_opt      = month + (dom > expthismonth);

switch (timePerProfile) {

case CHART:

    period = 0;

    agg = AggregationPeriod.DAY;

case MINUTE:

    period = Floor(seconds / 60 + day_number * 24 * 60);

    agg = AggregationPeriod.MIN;

case MIN2:

    period = Floor(seconds / 120 + day_number * 24);

    agg = AggregationPeriod.TWO_MIN;

case MIN3:

    period = Floor(seconds / 180 + day_number * 24);

    agg = AggregationPeriod.THREE_MIN;

case MIN4:

    period = Floor(seconds / 240 + day_number * 24);

    agg = AggregationPeriod.FOUR_MIN;

case MIN5:

    period = Floor(seconds / 300 + day_number * 24);

    agg = AggregationPeriod.FIVE_MIN;

case MIN10:

    period = Floor(seconds / 600 + day_number * 24);

    agg = AggregationPeriod.TEN_MIN;

case MIN15:

    period = Floor(seconds / 900 + day_number * 24);

    agg = AggregationPeriod.FIFTEEN_MIN;

case MIN20:

    period = Floor(seconds / 1200 + day_number * 24);

    agg = AggregationPeriod.TWENTY_MIN;

case MIN30:

    period = Floor(seconds / 1800 + day_number * 24);

    agg = AggregationPeriod.THIRTY_MIN;

case HOUR:

    period = Floor(seconds / 3600 + day_number * 24);

    agg = AggregationPeriod.HOUR;

case TWOHOUR:

    period = Floor(seconds / 7200 + day_number * 24);

    agg = AggregationPeriod.TWO_HOURS;

case FOURHOUR:

    period = Floor(seconds / 14400 + day_number * 24);

    agg = AggregationPeriod.FOUR_HOURS;

case DAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.DAY;

case TWODAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.TWO_DAYS;

case THREEDAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.THREE_DAYS;

case FOURDAY:

    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;

    agg = AggregationPeriod.FOUR_DAYS;

case WEEK:

    period = Floor(day_number / 7);

    agg = AggregationPeriod.WEEK;

case MONTH:

    period = Floor(month - First(month));

    agg = AggregationPeriod.MONTH;

case "OPT EXP":

    period = exp_opt - First(exp_opt);

    agg = AggregationPeriod.DAY;

case BAR:

    period = BarNumber() - 1;

    agg = AggregationPeriod.DAY;

}



def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % (if timePerProfile == timePerProfile.TWODAY then 2 else if timePerProfile == timePerProfile.THREEDAY then 3 else if timePerProfile == timePerProfile.FOURDAY then 4 else multiplier) else count[1], 0);



def cond = count < count[1] + period - period[1];

def height;

switch (pricePerRowHeightMode) {

case AUTOMATIC:

    height = PricePerRow.AUTOMATIC;

case TICKSIZE:

    height = PricePerRow.TICKSIZE;

case CUSTOM:

    height = customRowHeight;

}



profile vol     = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);

def con         = CompoundValue(1, onExpansion, no);

def pc          = if IsNaN(vol.GetPointOfControl())   and con then pc[1]  else vol.GetPointOfControl();

def hVA         = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();

def lVA         = if IsNaN(vol.GetLowestValueArea())  and con then lVA[1] else vol.GetLowestValueArea();

def hProfile    = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();

def lProfile    = if IsNaN(vol.GetLowest())  and con then lProfile[1] else vol.GetLowest();

def plotsDomain = IsNaN(close) == onExpansion or showlines;

def pct = 100;
input width = 75;
input price = close;
def d = width / pct;
def d1 = 0.909 * d;
def d2 = 1.0 * d;
def d3 = 1.272 * d;
def stdDeviation1 = HighestAll("data" = AbsValue(PC - lProfile));
def stdDeviation2 = HighestAll("data" = AbsValue(hProfile - pc));



plot POC         = if plotsDomain then pc       else Double.NaN;

plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;

plot ProfileLow  = if plotsDomain then lProfile else Double.NaN;

def VAHigh       = if plotsDomain then hVA      else Double.NaN;

def VALow        = if plotsDomain then lVA      else Double.NaN;

plot UpperLine = pc + stdDeviation2 * d1;
plot LowerLine = pc - stdDeviation1 * d1;
plot UpperLine1 = pc + stdDeviation2 * d2;
plot LowerLine1 = pc - stdDeviation1 * d2;
plot UpperLine2 = pc + stdDeviation2 * d3;
plot LowerLine2 = pc - stdDeviation1 * d3;

UpperLine.SetStyle(Curve.SHORT_DASH);
UpperLine.SetDefaultColor(Color.GRAY);
UpperLine1.SetStyle(Curve.SHORT_DASH);
UpperLine1.SetDefaultColor(Color.LIGHT_RED);
UpperLine2.SetStyle(Curve.SHORT_DASH);
UpperLine2.SetDefaultColor(Color.RED);
LowerLine.SetStyle(Curve.SHORT_DASH);
LowerLine.SetDefaultColor(Color.GRAY);
LowerLine1.SetStyle(Curve.SHORT_DASH);
LowerLine1.SetDefaultColor(Color.LIGHT_GREEN);
LowerLine2.SetStyle(Curve.SHORT_DASH);
LowerLine2.SetDefaultColor(Color.GREEN);



DefineGlobalColor("Profile", GetColor(1));

DefineGlobalColor("Point Of Control", Color.CYAN);

DefineGlobalColor("Value Area", GetColor(8));


Settings for 1 day 1 min chart:
Time per profile: HOUR
Width: 65
(I Turn off the ProfileHigh and ProfileLow)

Settings for 1 year 1 day chart:
Time per profile: WEEK
Width: 65
(I Turn off the POC, ProfileHigh and ProfileLow)
That looks promising. I was also hesitant to try out the VB. I will give it a go and get back to you.
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
414 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