vZone (Volumes Based Support/Resistance) For ThinkOrSwim

@SuryaKiranC , would it be possible to show each box/lines for the time between the start of the 1st zone to endtime of the 3rd zone (selecting "Yes" to extension param seems buggy)?

e.g.
zone 1 @8 AM to @12 PM
zone 2 @12 PM to @2 PM
zone 3 @2PM to @4:15 PM

Show the 1st zone box/lines from 8AM to 4:15 PM
Show the 2nd zone box/lines from 12PM to 4:15PM
Show the 3rd zone box/lines from 2PM to 4:15PM
(the extension would be of the most recent range of each zone)

For previous highest vol ranges of each zone for the same day, show dotted lines (same colors) and extend it to the 3rd zone's end time.

e.g.
Zone 1 range shifts between 8AM and 12PM multiple times.
a max vol candle range is derived @8AM > changes @9:45AM > Changes @11:50 AM
This would result in the main box/lines change as usual (and 11:50AM range would be extended to the end of 3rd zone)
And for ranges derived @8AM and @9:45AM would be drawn in dotted lines between 9:45AM (end of the first instance - 8AM candle ) to 4:15PM and 11:50AM (end of the 2nd instance - 9:45 candle) and 4:15PM. Guess you would only need to draw one boundary since the 2nd one would be drawn by the next instance. Maybe text-only bubbles would be needed to indicate lower and upper boundary of each zone to differentiate.

Also, alerts would work with previous/dotted zones as well.
Oh, and is it possible to hide the vertical boxes/lines that show at the time of shift in ranges?

This is just a thought, not sure how easy it would be though. :)

Thanks for this awesome indicator.
 

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

I agree, you can try this on 15,... I need to see how it reacts and if I can understand extraction for profit, otherwise I will stay with price action..
I to am mainly a price action trader..I do think this study fits perfectly into price action...

You can use this method even on the daily, drawing levels at highs and lows of extreme volume days

Unusual amounts of volume create a memory point in the market
 
e.g.
Zone 1 range shifts between 8AM and 12PM multiple times.
a max vol candle range is derived @8AM > changes @9:45AM > Changes @11:50 AM
This would result in the main box/lines change as usual (and 11:50AM range would be extended to the end of 3rd zone)
And for ranges derived @8AM and @9:45AM would be drawn in dotted lines between 9:45AM (end of the first instance - 8AM candle ) to 4:15PM and 11:50AM (end of the 2nd instance - 9:45 candle) and 4:15PM. Guess you would only need to draw one boundary since the 2nd one would be drawn by the next instance. Maybe text-only bubbles would be needed to indicate lower and upper boundary of each zone to differentiate.

Also, alerts would work with previous/dotted zones as well.
Oh, and is it possible to hide the vertical boxes/lines that show at the time of shift in ranges?

This is just a thought, not sure how easy it would be though. :)

Thanks for this awesome indicator.
Zone are defined as following, all time in EST.

## : Zone 1 : 09:30 - 11:00
## : Zone 2 : 11:00 - 14:00
## : Zone 3 : 14:00 - 16:00

As for the possibility, I supposed anything is a possibility, But that would be a deviation of the original theory explained in the video, if there is a well defined theory/strategy and edge to custom time zones by all means we can.

As for the Plots, Zone1 is plotted for the entire time of the trading hours. Zone2 & 3 from the defined start to end of trade hours.

Extend_On/Off is only to meant from the zones from prior day to be extended in to current day. Please refer to the screenshot, posed in the original post to see the difference.


Hiding the vertical lines, could be done but may require addition coding, more variable declaration, messy coding. Would you not rather see the same zone connected through out the session? that would be easier to track, when you are running around and switching through tickers and tracking a zillion thing during trader hours.

If we have a defined strategy though, we could always start a different indicator.

-S
 
I watched the video and it mentions zone 1 should be regular trading hours (rth) start to 90 minutes after open, zone 3 should be 120 minutes from rth end, and zone 2 everything in between. I trade futures that have start times other than 9:30 EST (like /CL and /6E) so I converted all the times for zone calculations to be dynamic based on the rules from the video. With this version you shouldn't need to mess with the script when you change to instruments with odd start and end times.

Ruby:
## vZoneSTUDY.ts
## This Indicator is based on the Following concept and, I suggest watch the video before you start to use this.
##
## https://www.screencast.com/users/MarketGauge/folders/DATE1010/media/f1702bb2-2090-463a-8ad2-59639c1166cd
## This is to Plot Support/Resistance based on High Volume Candle in three different time zones for the day.
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
## A big thanks to @COS251 for helping me with Coding this, Reviewing and Testing it.
##
## V 1.1_bigboss : adjusted logic to automatically detect start time, 90 minutes in, and 2 hours before end time for zones.
## V 1.1 : Just added the ability to disable the vZones, automatically, extending from previous in to current session.
##  Note : It is available as an option, should somebody prefer the extension. Set "Extend" to your needs accordingly.
## V 1.0 : Split Day in to three Zones and Find the highest Volume Candle for each zone and plot Support/Resistance.
##        :     Zone 1 : 09:30 - 11:00
##        :     Zone 2 : 11:00 - 14:00
##        :     Zone 3 : 14:00 - 16:00
##        :     vZones are Plotted on 15m and lower charts.
##        :  Plots EMA Cloud to assist with identifying reversals, Keeping EMA Clouds for all Timeframes


declare upper;
declare once_per_bar;

def Future = if GetSymbolPart(1) == "/YM:XCBT" or GetSymbolPart(1) == "/ES:XCME" or GetSymbolPart(1) == "/NQ:XCME" or GetSymbolPart(1) == "/RTY:XCME" or GetSymbolPart(1) == "/EMD:XCME" or GetSymbolPart(1) == "/NKD:XCME" or GetSymbolPart(1) == “/DX:XICE" or GetSymbolPart(1) == "/6E:XCME" or  GetSymbolPart(1) == "/6A:XCME" or GetSymbolPart(1) == "/ZB:XCBT" or GetSymbolPart(1) == "/ZN:XCBT" or GetSymbolPart(1) == "/CL:XNYM" or GetSymbolPart(1) == "/NG:XNYM" or GetSymbolPart(1) == "/GC:XCEC" or GetSymbolPart(1) == "/SI:XCEC" or  GetSymbolPart(1) == "/HG:XCEC” or GetSymbolPart(1) == "/6B:XCME" or GetSymbolPart(1) == "/ZC:XCBT" or GetSymbolPart(1) == "/ZS:XCBT" or GetSymbolPart(1) == "/CC:XICE" or GetSymbolPart(1) == "/KC:XICE" or GetSymbolPart(1) == ”/CT:XICE" or GetSymbolPart(1) == "/ZW:XCBT" or GetSymbolPart(1) == "/SB:XICE" or GetSymbolPart(1) == "/LE:XCME" or GetSymbolPart(1) == "/HO:XNYM" or GetSymbolPart(1) == "/HE:XCME" or GetSymbolPart(1) == "/OJ:XICE" then yes else no;

AddLabel(if Future then yes else no, "Future", Color.YELLOW);

input   showEMACloud = Yes;
input  audibleAlerts = Yes;
input Extend = {default "No", "Yes"};

def Today = GetYYYYMMDD();

def Zone1 = gettime() >= RegularTradingStart(GetYYYYMMDD()) and gettime() <= RegularTradingStart(GetYYYYMMDD()) + 90*60*1000;
def Zone2 = gettime() > RegularTradingStart(GetYYYYMMDD()) + 90*60*1000 and gettime() <= RegularTradingEnd(GetYYYYMMDD())-120*60*1000;
def Zone3 = gettime() > RegularTradingEnd(GetYYYYMMDD())-120*60*1000 and getTime() <= RegularTradingEnd(GetYYYYMMDD());

DefineGlobalColor("Zone1", CreateColor(204, 255, 225));
DefineGlobalColor("Zone2", CreateColor(252, 220, 101));
DefineGlobalColor("Zone3", CreateColor(204, 204, 198));
DefineGlobalColor( "EMA1+", CreateColor(201, 255, 234));
DefineGlobalColor( "EMA1-", CreateColor(255, 105, 105));
DefineGlobalColor( "EMA2+", CreateColor(125, 176, 130));
DefineGlobalColor( "EMA2-", CreateColor(194, 152, 227));
DefineGlobalColor( "EMA3+", CreateColor(161, 217, 247));
DefineGlobalColor( "EMA3-", CreateColor(255, 255, 112));

def  ema1low = 5;
def ema1high = 13;
def  ema2low = 34;
def ema2high = 51;
def  ema3low = 72;
def ema3high = 89;

def  ema5 = if showEMACloud then ExpAverage(close,  ema1low) else Double.NaN;
def ema13 = if showEMACloud then ExpAverage(close, ema1high) else Double.NaN;
def ema34 = if showEMACloud then ExpAverage(close,  ema2low) else Double.NaN;
def ema51 = if showEMACloud then ExpAverage(close, ema2high) else Double.NaN;
def ema72 = if showEMACloud then ExpAverage(close,  ema3low) else Double.NaN;
def ema89 = if showEMACloud then ExpAverage(close, ema3high) else Double.NaN;

AddCloud( ema5, ema13, GlobalColor("EMA1+"), GlobalColor("EMA1-"));
AddCloud(ema34, ema51, GlobalColor("EMA2+"), GlobalColor("EMA2-"));
AddCloud(ema72, ema89, GlobalColor("EMA3+"), GlobalColor("EMA3-"));

def CrossAbove = if showEMACloud and ema5 > ema13 and ema5[1] <= ema13[1] then 1 else 0;
def CrossBelow = if showEMACloud and ema5 < ema13 and ema5[1] >= ema13[1] then 1 else 0;

Alert(showEMACloud and audibleAlerts and CrossAbove, "Buy", Alert.BAR, Sound.Ding);
Alert(showEMACloud and audibleAlerts and CrossBelow, "Sell", Alert.BAR, Sound.Ring);

################################################################
##########         Booleans Set for Plot Use           #########
################################################################
def afterStart;
def beforeEnd;
def openPrice;
if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN {
    afterStart = GetTime() > RegularTradingStart(GetYYYYMMDD());
    beforeEnd = GetTime() < RegularTradingEnd(GetYYYYMMDD());
    openPrice = DailyOpen();
} else {
    afterStart = Double.NaN;
    beforeEnd = Double.NaN;
    openPrice = Double.NaN;
}

plot DailyO = if openPrice then openPrice else Double.NaN;

script Zone {
    def H ;
    def L ;
    def V ;

#    input CountIn = 0930;
#    input CountOut = 1100;
    input TimeFrame = yes;   
#    def TF = SecondsFromTime(CountIn) >= 0 and SecondsTillTime(CountOut) >= 0;
    def tf = timeframe;
    if TF and !TF[1] {
        H = high;
        L = low;
        V = volume;
    } else if TF and volume > V[1] {
        H = high;
        L = low;
        V = volume;
    } else {
        H = H[1];
        L = L[1];
        V = V[1];
    }
    plot VZH = H;
    plot VZL = L;
    VZH.Hide();
    VZL.Hide();
}

def Z1H;
def Z1L;
def Z2H;
def Z2L;
def Z3H;
def Z3L;

switch (Extend){

Case "Yes":
 Z1H = Zone(Zone1).VZH;
 Z2H = Zone(Zone2).VZH;
 Z3H = Zone(Zone3).VZH;

 Z1L = Zone(Zone1).VZL;
 Z2L = Zone(Zone2).VZL;
 Z3L = Zone(Zone3).VZL;



Case "No":
 Z1H = if today != today[1] then Double.NaN else Zone(Zone1).VZH;
 Z2H = if today and  !Zone2 then Double.NaN else Zone(Zone2).VZH;
 Z3H = if today and  !Zone3 then Double.NaN else Zone(Zone3).VZH;

 Z1L = if today != today[1] then Double.NaN else Zone(Zone1).VZL;
 Z2L = if today and  !Zone2 then Double.NaN else Zone(Zone2).VZL;
 Z3L = if today and  !Zone3 then Double.NaN else Zone(Zone3).VZL;

}

def BelowVZ = if close < Z1L or close < Z2L or close < Z3L then 1 else 0;
def AboveVZ = if close > Z1H or close > Z2H or close > Z3H then 1 else 0;

AddLabel(if (GetAggregationPeriod() > AggregationPeriod.FIFTEEN_MIN) then yes else no, "vBox Zones on 5/10/15M Charts Only", Color.RED);

AddCloud(if afterStart and beforeEnd then Z1H else Double.NaN, if afterStart and beforeEnd then Z1L else Double.NaN, GlobalColor("Zone1"), GlobalColor("Zone1"));
AddCloud(if    beforeEnd then Z2H else Double.NaN, if    beforeEnd then Z2L else Double.NaN, GlobalColor("Zone2"), GlobalColor("Zone2"));
AddCloud(if    beforeEnd then Z3H else Double.NaN, if    beforeEnd then Z3L else Double.NaN, GlobalColor("Zone3"), GlobalColor("Zone3"));

Alert(audibleAlerts and AboveVZ, "Above High VolumeBar Caution Long", Alert.BAR, Sound.Ding);
Alert(audibleAlerts and BelowVZ, "Below High VolumeBar Look for Reversal", Alert.BAR, Sound.Ring);
 
Zone are defined as following, all time in EST.

## : Zone 1 : 09:30 - 11:00
## : Zone 2 : 11:00 - 14:00
## : Zone 3 : 14:00 - 16:00

As for the possibility, I supposed anything is a possibility, But that would be a deviation of the original theory explained in the video, if there is a well defined theory/strategy and edge to custom time zones by all means we can.

As for the Plots, Zone1 is plotted for the entire time of the trading hours. Zone2 & 3 from the defined start to end of trade hours.

Extend_On/Off is only to meant from the zones from prior day to be extended in to current day. Please refer to the screenshot, posed in the original post to see the difference.


Hiding the vertical lines, could be done but may require addition coding, more variable declaration, messy coding. Would you not rather see the same zone connected through out the session? that would be easier to track, when you are running around and switching through tickers and tracking a zillion thing during trader hours.

If we have a defined strategy though, we could always start a different indicator.

-S
Whats up man I like the VolumeBox code! I want to do the samething but for DPL!
 
Zone are defined as following, all time in EST.

## : Zone 1 : 09:30 - 11:00
## : Zone 2 : 11:00 - 14:00
## : Zone 3 : 14:00 - 16:00

As for the possibility, I supposed anything is a possibility, But that would be a deviation of the original theory explained in the video, if there is a well defined theory/strategy and edge to custom time zones by all means we can.

As for the Plots, Zone1 is plotted for the entire time of the trading hours. Zone2 & 3 from the defined start to end of trade hours.

Extend_On/Off is only to meant from the zones from prior day to be extended in to current day. Please refer to the screenshot, posed in the original post to see the difference.


Hiding the vertical lines, could be done but may require addition coding, more variable declaration, messy coding. Would you not rather see the same zone connected through out the session? that would be easier to track, when you are running around and switching through tickers and tracking a zillion thing during trader hours.

If we have a defined strategy though, we could always start a different indicator.

-S
Ok, I now understand the decision behind zones' timing.

For extending the zones' drawings, I think the following might help describe what I'm thinking.

X4zwrO9.jpg


Green lines/box= Zone 1
-- 1: Low of 1st highest vol candle withing this zone
-- 2: High of the 1st highest vol candle within the zone
-- 3: High of the 2nd and final highest vol candle within the zone (note, the Low of the 2nd and final highest vol candle within the zone happens to be same as 2)

Yellow lines/Box = Zone 2
-- 4: Low of 1st highest vol candle withing this zone
-- 5: High of the 1st highest vol candle within the zone
-- 6: High of the 2nd highest vol candle within the zone (note, the Low of the 2nd highest vol candle within the zone happens to be same as 5)
-- 7: Low of the 3rd and final highest vol candle within the zone
-- 8: High of the 3rd and final highest vol candle within the zone

Blue Lines/Box = Zone 3
-- 9: Low of 1st highest vol candle withing this zone
-- 10: High of the 1st highest vol candle within the zone
-- 11: Low of the 2ndrd and final highest vol candle within the zone
-- 12 High of the 2nd and final highest vol candle within the zone

For all non-final instances of the highest vol candles within each zone are marked with lines and extends until the end of RTH (16:00).
For all final instances of the highest vol candles within each zone are marked with boxes and extends until the end of RTH.

I was thinking about these lines/boxes extending until the end of day to use them as S/R levels. Also, alerts when candles crossing these lines/boxes would be a "nice-to-have" (aka, not necessary if too complex).

Please let me know if this helps. That said, not sure how complex this makes things so I totally understand if it's not something that is doable. Thanks
 
Ok, I now understand the decision behind zones' timing.

For extending the zones' drawings, I think the following might help describe what I'm thinking.

X4zwrO9.jpg


Green lines/box= Zone 1
-- 1: Low of 1st highest vol candle withing this zone
-- 2: High of the 1st highest vol candle within the zone
-- 3: High of the 2nd and final highest vol candle within the zone (note, the Low of the 2nd and final highest vol candle within the zone happens to be same as 2)

Yellow lines/Box = Zone 2
-- 4: Low of 1st highest vol candle withing this zone
-- 5: High of the 1st highest vol candle within the zone
-- 6: High of the 2nd highest vol candle within the zone (note, the Low of the 2nd highest vol candle within the zone happens to be same as 5)
-- 7: Low of the 3rd and final highest vol candle within the zone
-- 8: High of the 3rd and final highest vol candle within the zone

Blue Lines/Box = Zone 3
-- 9: Low of 1st highest vol candle withing this zone
-- 10: High of the 1st highest vol candle within the zone
-- 11: Low of the 2ndrd and final highest vol candle within the zone
-- 12 High of the 2nd and final highest vol candle within the zone

For all non-final instances of the highest vol candles within each zone are marked with lines and extends until the end of RTH (16:00).
For all final instances of the highest vol candles within each zone are marked with boxes and extends until the end of RTH.

I was thinking about these lines/boxes extending until the end of day to use them as S/R levels. Also, alerts when candles crossing these lines/boxes would be a "nice-to-have" (aka, not necessary if too complex).

Please let me know if this helps. That said, not sure how complex this makes things so I totally understand if it's not something that is doable. Thanks

We do all of this today, but all with boxes though not with lines for some and then boxes for new zone. Most days you wont. find Zone1 Re-plotting, As Zone1 consists of Accumulated Overnight Volume and is the shortest zone to find another candle higher than the open candle, that said there is a chance, we can see that Zone replotted, after the initial few candles.

Zone2 & 3 are easy re-plot, and zone2 is the lengthiest of the 3 and Zone3 could get the pop in the volume as much as last candle. That said all 3 of them are plotted from the time they start to the End of the Day. then Extension on/off is only plotting last session in to Current.

Having mix and match of these zone plots between lines and cloud, while not impossible, but could involve in a bit of tedious coding.

-S
 
We do all of this today, but all with boxes though not with lines for some and then boxes for new zone. Most days you wont. find Zone1 Re-plotting, As Zone1 consists of Accumulated Overnight Volume and is the shortest zone to find another candle higher than the open candle, that said there is a chance, we can see that Zone replotted, after the initial few candles.

Zone2 & 3 are easy re-plot, and zone2 is the lengthiest of the 3 and Zone3 could get the pop in the volume as much as last candle. That said all 3 of them are plotted from the time they start to the End of the Day. then Extension on/off is only plotting last session in to Current.

Having mix and match of these zone plots between lines and cloud, while not impossible, but could involve in a bit of tedious coding.

-S
9b3cLl1.jpg

Here's the updated version (more constant with how clouds are drawn). I believe the only needed change would be to extend the clouds to the end and also extend the previous high/low of each zone to the end with lines (or dotted lines).
 
Last edited:
for some reason its slowing down my TOS. Curious is this available in Trading view?
We didn't code it for Trading View, But again this is not our original concept, so it is possible there is a Trading View version out there.

As for slow, would you mind listing your config and what Timeframe you are loading this, and how many charts you keep open?
 
Interesting indicator, nice touch with the EMA clouds. I use a specific volume indicator modified from the TD Ameritrade Vol Profile which I call POC Zone. It pares down the code to what I need with easy visuals.
Below is an image of todays 1 minute chart for Microsoft with the POC Zones set to 15 bars (15 minutes) on the chart and an explanation of how they help confirm a directional trade (along with a number of others).

The image is self explanatory. I can post the indicator if anyone is interested.

8t0TWXP.jpg
 
Here is a link to POC_Zones modified from VolProfile. The logic of using high volume areas with this indicator is similar to the logic of the using the Volume Area on the open. This indicator allows you to determine the number of bars (intraday) or Days to include in your POC_Zones plus the size of the Value Area with a cloud visual.

http://tos.mx/PpSzPfs
Ruby:
# Modified @rlohmeyer
# TD Ameritrade IP Company, Inc. (c) 2010-2020
input ProfileTime = {default BAR, DAY};
input multiplier = 5;
input profiles = 78;
input showPOC = yes;
input valueAreaPercent = 70;
input opacity = 20;

def na = Double.NaN;
def period;
def yyyymmdd = GetYYYYMMDD();
switch (ProfileTime) {
case BAR:
    period = BarNumber() - 1;
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
}


def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
def height = PricePerRow.TICKSIZE;


profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, no, 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 plotsDomain = IsNaN(close) == no;
plot POC = if plotsDomain then pc else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;
DefineGlobalColor("PC", Color.CYAN);
POC.SetDefaultColor(GlobalColor("PC"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("PC"));
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetDefaultColor(GlobalColor("PC"));
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
declare hide_on_daily;
AddCloud(VAHigh,VALow, Color.CYAN, Color.CYAN, no);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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