Volatility Box Indicator for ThinkorSwim

james-smith

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

Huffmac90

Member
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.
 

Moose

Member
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
 
It is possible to use it as an oscillator without taking the share price, for example adding in Elliot's oscillator?

I try to add the code in my Elliot script but it takes the price of the action. Thanks
 

ponnaps

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

kmg526

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

kmg526

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

New member
VIP
@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
 

rad14733

Well-known member
VIP
@kmg526 It appears that something in the state logic is causing the issue... I've spent far too much time on this so unless someone else wants to give this a go I'd suggest starting out with a better script... I'm done on this one as I have other code to work on...
 

BenTen

Administrative
Staff
VIP
@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.
 

rad14733

Well-known member
VIP
@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.
Unfortunately, that didn't work in this instance... That was about the first thing I did to debug... Processing state is the most complex part of the whole script... I just can't invest more time into it... But it's still good practice to reference a Study/Indicator instead of pasting a ton of code... ;) (y)
 

kmg526

New member
VIP
Unfortunately, that didn't work in this instance... That was about the first thing I did to debug... Processing state is the most complex part of the whole script... I just can't invest more time into it... But it's still good practice to reference a Study/Indicator instead of pasting a ton of code... ;) (y)
Thanks for Trying!
 

Similar threads

Top