Volatility Box Indicator for ThinkorSwim

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

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:

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)
Hey there,
This is amazing! thank you for sharing :). I see you use this for two main time frames, 1 minute and the daily. Im going to try to implement it in my trading style. Thanks again!
 
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:

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)
Hi,

I installed it and the hot zones are far from the price so I don't get any entry. I don't know what I'm missing but bear with me I'm a newbie with ThinkScript so probably I'm doing something wrong.

image

I want to use the Daily TF so I modified the settings as you said;

-" Time per profile" Month
-"Width" 90
- Turned off Profile High and Low.

(This is using the first code, but you mention it's not the original one. In this case, should I first copy the original and then attach yours?
 
Hi,

I installed it and the hot zones are far from the price so I don't get any entry. I don't know what I'm missing but bear with me I'm a newbie with ThinkScript so probably I'm doing something wrong.

image

I want to use the Daily TF so I modified the settings as you said;

-" Time per profile" Month
-"Width" 90
- Turned off Profile High and Low.

(This is using the first code, but you mention it's not the original one. In this case, should I first copy the original and then attach yours?
This is not original code meaning I did not create it. I pulled the code from other people from this sight and made the Hot Zones out of the two separate codes.

So in order to get the proper effect with this indicator, you need to enter both of the codes so that they are two separate studies on your chart. After you enter the second code, set it to the settings I mentioned for it:

Settings for 1 year 1 day chart:
Time per profile: WEEK
Width: 65
(I Turn off the POC, ProfileHigh and ProfileLow)

So essentially you are going to have the Month profile and the Week profile set on your charts. The month profile has the clouds (red and green) and the Week does not have the clouds.

The idea behind this is that when price crosses into the week profile there is a high likelihood for a reversal or bounce in the opposite direction.

When price crosses into the month profile (ie the clouds) price is about to reverse or bounce in the opposite direction.

I have found that the reason why the VBOX codes earlier in this thread were so bad with repainting is because the time frames were too low. Higher time frames mean stronger support and resistance.

Please keep in mind that not all charts are going to show opportunities with the Hot Zones. Stocks that are not volatile or stay flat or just gradually trend up or down their Hot zones will always be far away.

I hope this helps!
 
This is not original code meaning I did not create it. I pulled the code from other people from this sight and made the Hot Zones out of the two separate codes.

So in order to get the proper effect with this indicator, you need to enter both of the codes so that they are two separate studies on your chart. After you enter the second code, set it to the settings I mentioned for it:

Settings for 1 year 1 day chart:
Time per profile: WEEK
Width: 65
(I Turn off the POC, ProfileHigh and ProfileLow)

So essentially you are going to have the Month profile and the Week profile set on your charts. The month profile has the clouds (red and green) and the Week does not have the clouds.

The idea behind this is that when price crosses into the week profile there is a high likelihood for a reversal or bounce in the opposite direction.

When price crosses into the month profile (ie the clouds) price is about to reverse or bounce in the opposite direction.

I have found that the reason why the VBOX codes earlier in this thread were so bad with repainting is because the time frames were too low. Higher time frames mean stronger support and resistance.

Please keep in mind that not all charts are going to show opportunities with the Hot Zones. Stocks that are not volatile or stay flat or just gradually trend up or down their Hot zones will always be far away.

I hope this helps!
Thank you for the prompt answer and the extended explanation. However, I still run into some issues getting the indicator properly on the Daily Time Frame. I only use your two codes but do I need the original one to make it work?

Anyway, since an image is worth 1000 words I think it would be better for you to visualize where am I, so you can spot the issue easily.

TSLA Daily chart, you can see price doesn't get to the hot zones in a volatile stock like TSLA.


First code settings. (I turned off the Profile Highs and Profile Lows as you suggested)

Second code settings ( I turned off the POC and Profile Highs and Lows)

I hope it helps and thanks for helping me.
 
Thank you for the prompt answer and the extended explanation. However, I still run into some issues getting the indicator properly on the Daily Time Frame. I only use your two codes but do I need the original one to make it work?

Anyway, since an image is worth 1000 words I think it would be better for you to visualize where am I, so you can spot the issue easily.

TSLA Daily chart, you can see price doesn't get to the hot zones in a volatile stock like TSLA.


First code settings. (I turned off the Profile Highs and Profile Lows as you suggested)

Second code settings ( I turned off the POC and Profile Highs and Lows)

I hope it helps and thanks for helping me.
Are you on a 1 year 1 day chart?
 
Okay try these settings:

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

Settings for 1 year 1 day chart:
Time per profile: MONTH
Width: 20
(I Turn off the POC, ProfileHigh and ProfileLow)

There seems to be more opportunity this way while still staying within the confines of the indicator. Note: the clouds are considered extreme zones.

 
Okay try these settings:

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

Settings for 1 year 1 day chart:
Time per profile: MONTH
Width: 20
(I Turn off the POC, ProfileHigh and ProfileLow)

There seems to be more opportunity this way while still staying within the confines of the indicator. Note: the clouds are considered extreme zones.

It looks better thank you. I will play around with it
 
Hello. I would like to request help to make a volatility indicator that following historical hourly price movement ranges (HPMR) rather than an auto calculated volatility range like all of the indicators listed before. These hourly price movement ranges can be found on chartviper.com - I will post the link to imgur of chartviper S&P mini HPMR whose values could be programmed into the thinkorswim code.

This indicator would need to be updated weekly with the new hourly ranges out of chartviper, which I can do myself. The strength of this is it gives you better clarity on volatility exhaustion levels based on real data from the NASDAQ, S&P, Dow, and Russell. The draw back (in addition to updating weekly) is this code will be long because each hour will have be manually coded to contain each range.

This type of HPMR indictor would be similar to what Raghee Horner uses for intraday trading the indexes, futures, and stocks. I have tried researching a way to modify the following script such that volatility is plotted individually by the hour, but I have been unsuccessful.

Would a programmer be able to revamp the script such that each hour of the day is a constant volatility range based on the capture from chartviper? I would be very grateful for this help. Please let me know if you need any more clarification. Thanks in advance,


see imgur post for HPMR levels

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);
Did you find anything further about this? Also can you post the original code I think it would be worthwhile to explore this

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
Do you have the code for this?
 
Did you find anything further about this? Also can you post the original code I think it would be worthwhile to explore this
Did you know that clicking on a member's avatar will allow you to see when a member was last seen on the uTS forum? @TonXas and has not been seen in a while. :(
 
Last edited:
Did you find anything further about this? Also can you post the original code I think it would be worthwhile to explore this
Hi @Trikortreat12 did not find anything new about this. I think I am going to go ahead and just purchase the volatility indicator from simplertrading. Posted some code in the original post from a VolatilityBox indicator found previously in this whole thread. Other than that I am stumped.
 
Hello. I would like to request help to make a volatility indicator that following historical hourly price movement ranges (HPMR) rather than an auto calculated volatility range like all of the indicators listed before. These hourly price movement ranges can be found on chartviper.com - I will post the link to imgur of chartviper S&P mini HPMR whose values could be programmed into the thinkorswim code.

This indicator would need to be updated weekly with the new hourly ranges out of chartviper, which I can do myself. The strength of this is it gives you better clarity on volatility exhaustion levels based on real data from the NASDAQ, S&P, Dow, and Russell. The draw back (in addition to updating weekly) is this code will be long because each hour will have be manually coded to contain each range.

This type of HPMR indictor would be similar to what Raghee Horner uses for intraday trading the indexes, futures, and stocks. I have tried researching a way to modify the following script such that volatility is plotted individually by the hour, but I have been unsuccessful.

Would a programmer be able to revamp the script such that each hour of the day is a constant volatility range based on the capture from chartviper? I would be very grateful for this help. Please let me know if you need any more clarification. Thanks in advance,


see imgur post for HPMR levels

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);
This may help some... "HPMRs- aka hourly price movement ranges - show the high and low price movement zones for each hour of the trading day based on an historic 6-month lookback of data. The zones are dynamically drawn based on the price range data and current price."
 
ok - so we took a pass at porting it. please give it a eye and run, if you can find ways to trade it, enhance it, or use it, in return please provide commentary and find some edge ;)

pfsUWIX.png


Ruby:
#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
plot pUpperChannel = upperchannel;
pUpperChannel.SetLineWeight(2);
pUpperChannel.SetDefaultColor(CreateColor(100,150,100));

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

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

plot 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);

#END OF PRC_Volatility Cycle Breakout | indicator

Any feedback or bugs, please reply.

Does anyone know if the proper way to trade this is inside the box (top->bottom, bottom->top) or outside of the box?

Thanks!
 
Does anyone know if the proper way to trade this is inside the box (top->bottom, bottom->top) or outside of the box?

Thanks!

The volatility cycle is created from Bollinger Bands representing support and resistance.
You would use this indicator in the same fashion as you are currently trading bollinger bands and S&R studies.
What is said to make this indicator different is that the fractal calculations cuts down on noise.
 
  • Love
Reactions: IPA
Found it!! I knew I've seen something like the VBOX before.

Code:
#VolumeProfile_IntradaySelection with Expanded Intraday Period Selections plus the Prior Day's Value Areas

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);

 

input pricecolor = no;

AssignPriceColor(if pricecolor

                 then if !green

                      then Color.RED

                      else Color.GREEN

                 else Color.CURRENT);

 

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);

https://onedrive.live.com/redir?res...lus th|41f44a85-ec27-4d87-8bed-8d572de0a190/)
Hi Huffmac90 thanks for the script VBOX for any chance do you have the description of the plots. like what valow1 is for etc ? thanks for any help
 
Found it!! I knew I've seen something like the VBOX before.

Code:
#VolumeProfile_IntradaySelection with Expanded Intraday Period Selections plus the Prior Day's Value Areas

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);

 

input pricecolor = no;

AssignPriceColor(if pricecolor

                 then if !green

                      then Color.RED

                      else Color.GREEN

                 else Color.CURRENT);

 

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);

https://onedrive.live.com/redir?res...lus th|41f44a85-ec27-4d87-8bed-8d572de0a190/)
Hi Huffmac90 do you have the description for the plots for the VBox ? thanks
 
Hi Huffmac90 do you have the description for the plots for the VBox ? thanks
Did you know that by clicking on a member's name, you can easily check when they were last seen on the uTS forum? It's a great way to keep track of who's been around recently, and who hasn't. Speaking of which, it looks like @Huffmac90 is no longer active. :(

The poster stated that he found the study on the ThinkScript Lounge, unfortunately a search of the lounge found that the link for the study was provided with no additional information.

To become proficient in reading this indicator, the most effective method is to experiment with it firsthand. Nothing compares to hands-on experience, so add the indicator to your chart and observe how it operates in conjunction with your other indicators.

The originators of the the Volatility Box state:

Volatility Box Fades​

Our bread and butter setup, which has 2 different rules:
  1. Price must breach our Volatility Box edge, signaling we're in a key volatility reversal area
  2. Confirm the reversal with a 1-min Edge Signal confirmation of overbought/oversold zones.
You can watch a video and read more here: https://tosindicators.com/volatility-box/stocks
 
Last edited:

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
288 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