vZone (Volumes Based Support/Resistance) For ThinkOrSwim

Yet another Support/Resistance Indicator for DayTrading, but with a twist, We use high/low of High Volume Bar, in three different Zones of the Day.
With out further delay, Uploading the code here, will come back and edit this line with more appropriate description.

huge thanks to @cos251 for helping me with Coding this, Reviewing and Testing it.

Link to Video: https://www.screencast.com/users/Ma...10/media/f1702bb2-2090-463a-8ad2-59639c1166cd

vZone Extend On/Off
Shared Study Link: http://tos.mx/yA5VXad Click here for --> Easiest way to load shared links
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 : 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 StartTime = 0930;
def   Update1 = 1100;
def   Update2 = 1400;
def   EndTime = 1600;

def Zone1 = SecondsFromTime(StartTime) >= 0 and SecondsTillTime(Update1) >= 0;
def Zone2 =   SecondsFromTime(Update1) >= 0 and SecondsTillTime(Update2) >= 0;
def Zone3 =   SecondsFromTime(Update2) >= 0 and SecondsTillTime(EndTime) >= 0;

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;
    def TF = SecondsFromTime(CountIn) >= 0 and SecondsTillTime(CountOut) >= 0;

    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(CountIn = StartTime, CountOut = Update1).VZH;
 Z2H = Zone(CountIn =   Update1, CountOut = Update2).VZH;
 Z3H = Zone(CountIn =   Update2, CountOut = EndTime).VZH;

 Z1L = Zone(CountIn = StartTime, CountOut = Update1).VZL;
 Z2L = Zone(CountIn =   Update1, CountOut = Update2).VZL;
 Z3L = Zone(CountIn =   Update2, CountOut = EndTime).VZL;

Case "No":
 Z1H = if today != today[1] then Double.NaN else Zone(CountIn = StartTime, CountOut = Update1).VZH;
 Z2H = if today and  !Zone2 then Double.NaN else Zone(CountIn =   Update1, CountOut = Update2).VZH;
 Z3H = if today and  !Zone3 then Double.NaN else Zone(CountIn =   Update2, CountOut = EndTime).VZH;

 Z1L = if today != today[1] then Double.NaN else Zone(CountIn = StartTime, CountOut = Update1).VZL;
 Z2L = if today and  !Zone2 then Double.NaN else Zone(CountIn =   Update1, CountOut = Update2).VZL;
 Z3L = if today and  !Zone3 then Double.NaN else Zone(CountIn =   Update2, CountOut = EndTime).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    Update1 and beforeEnd then Z2H else Double.NaN, if    Update1 and beforeEnd then Z2L else Double.NaN, GlobalColor("Zone2"), GlobalColor("Zone2"));
AddCloud(if    Update2 and beforeEnd then Z3H else Double.NaN, if    Update2 and 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);
This is some amazing work. I am trying to play around with this code to see its limitations. I hope this isn't a dumb question, but Is there a way to show the aggregated 15min on the 5min chart. My goal would be to show the higher timeframe support/resistance while showing the lower timeframe 'candlestick patterns'. Thanks!
 
This is some amazing work. I am trying to play around with this code to see its limitations. I hope this isn't a dumb question, but Is there a way to show the aggregated 15min on the 5min chart. My goal would be to show the higher timeframe support/resistance while showing the lower timeframe 'candlestick patterns'. Thanks!
It is possible. The original code in post 1 would need to be modified to include the aggregation period. I will say, the original strategy was to view this on a 5m timeframe (that is what @SuryaKiranC based it on) so anything else would move away from the original strategy.
 
It is possible. The original code in post 1 would need to be modified to include the aggregation period. I will say, the original strategy was to view this on a 5m timeframe (that is what @SuryaKiranC based it on) so anything else would move away from the original strategy.
My intention was not to move away from the original strategy. I figured a breakout of the 5min VZone box which coincides with a breakout of the 15min VZone box could yield a larger run. Conversely, knowing where the 15min resistance might help place targets on a 5-min breakout. Although, it is just a thought that I wanted to back-test... it may all be nonsense.
 
My intention was not to move away from the original strategy. I figured a breakout of the 5min VZone box which coincides with a breakout of the 15min VZone box could yield a larger run. Conversely, knowing where the 15min resistance might help place targets on a 5-min breakout. Although, it is just a thought that I wanted to back-test... it may all be nonsense.
You want to test out that theory, try both the timeframes side-by-side, I keep both 5m & 15m on 2 different cells on the grid.

-S
 
Beautiful!

Nice work @SuryaKiranC - such a clean indicator!

Very powerful indicator! MSFT Levels today. From breakout to resistance.

HdQY7Ff.jpg



***** Alternate version of vZone w/ no time restrictions. Just looking for highest volume bar and tracking previous 2 highest bars.

xBXMMrJ.jpg



Ruby:
## vZoneNoTime.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.2 : Removed time restriction - alternate version (@cos251)
##
## 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




def volumeHigh;
def volumeLow;
def volVAR;
def ph;
def pl;
def ph2;
def pl2;
if volume > volVAR[1] {
    volumeHigh = high;
    volumeLow = low;
    volVAR = volume;
    ph = volumeHigh[1];
    pl = volumeLow[1];
    ph2 = ph[1];
    pl2 = pl[1];
} else {
    volumeHigh = volumeHigh[1];
    volumeLow = volumeLow[1];
    volVAR = volVAR[1];
    ph = ph[1];
    pl = pl[1];
    ph2 = ph2[1];
    pl2 = pl2[1];
}

# --- Zone 1
plot h = volumeHigh;
plot l = volumeLow;
AddCloud(h,  l, Color.GRAY,Color.PINK);

# --- Zone 2
plot previoush = ph;
plot previousl = pl;
AddCloud(previoush,previousl,Color.PINK);

# --- Zone 3
plot previoush2 = ph2;
plot previousl2 = pl2;
AddCloud(previoush2,previousl2,Color.MAGENTA);

# --- Labels
AddLabel(yes,"Zone 1",Color.GRAY);
AddLabel(yes,"Zone 2",Color.PINK);
AddLabel(yes,"Zone 3",Color.MAGENTA);

One more image: Same SPY from above but 5m

ikLUy4R.jpg
@SuryaKiranC Question the Vzone with no time can you add more zones like maybe add 2 more?
 
This is a wonderful indicator and I've been trying to incorporate it into my own price action trading (not necessarily using the intended strat discussed in post #1). I would like it to show 1min. volume zones no matter what time frame I use. I like the 1m volume zones intraday because it's more precise for finding reaction and stop loss locations, but I like to use slightly higher time frame (usually 2m) for price action analysis with less noise than 1m charts. So basically, I want to see 1m volume zones no matter what time frame I switch to.

I have tried to figure out how to alter the code to do only 1m, but with my limited coding knowledge I have been unable to figure it out. Any help with this would be greatly appreciated.
 
So what do the different EMAs represent?
Just lookup on EMA Cloud strategy, and what people do with it, there are few theories out there. vZone by itself will not show reversals, I was trying to use EMA clouds to determine if I should hold my longs or book profit.
-S
 
This is a wonderful indicator and I've been trying to incorporate it into my own price action trading (not necessarily using the intended strat discussed in post #1). I would like it to show 1min. volume zones no matter what time frame I use. I like the 1m volume zones intraday because it's more precise for finding reaction and stop loss locations, but I like to use slightly higher time frame (usually 2m) for price action analysis with less noise than 1m charts. So basically, I want to see 1m volume zones no matter what time frame I switch to.

I have tried to figure out how to alter the code to do only 1m, but with my limited coding knowledge I have been unable to figure it out. Any help with this would be greatly appreciated.
Do I understand this right? you want to see the vZones based on 1m timeframe, regardless of your chart timeframe.

if that is the ask, that is not possible in TOS platform. In TOS, you can show higher frame stats in lower frames not the other way.

example, you can be in 1m chart and show the starts of any higher frame like 5m all the way to a Quarter, if you must. but if you are in a 5m chart you can not show the stats (price or volume) of 1m.

-S
 
Last edited:
Do I understand this right? you want to see the vZones based on 1m timeframe, regardless of your chart timeframe.

if that is the ask, that is not possible in TOS platform. In TOS, you can show higher frame stats in lower frames not the other way.

example, you can be in 1m chart and show the starts of any higher frame like 5m all the way to a Quarter, if you must. but if you are in a 5m chart you can not show the stats (price or volume) of 1m.

-S
Yes, you understood correctly and thank you so much for responding with exactly the information I needed. Once again, thank you for the indicator. It sits on my charts permanently now and it's one of the most important guiding factors for my trades.
 
@Ahmar824 then /USER] says, "Your Wish is my command." 🤣
[/QUOTE]
[USER=6343]@cos251
[
i was trying to make this one with 5 zones, can you guy check what im missing
Thank you

declare upper;
declare once_per_bar;

input showEMACloud = Yes;
input audibleAlerts = Yes;

def StartTime = 0930;
def Update1 = 0930;
def Update2 = 1600;
def EndTime = 1600;

DefineGlobalColor("Zone1", CreateColor(182, 242, 198));
DefineGlobalColor("Zone2", CreateColor(252, 220, 101));
DefineGlobalColor("Zone3", CreateColor(204, 204, 198));
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, Color.DARK_GREEN, Color.RED);
AddCloud(ema34, ema51, Color.GREEN, Color.VIOLET);
AddCloud(ema72, ema89, Color.BLUE, Color.YELLOW);

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 today;
def openPrice;
if GetAggregationPeriod() <= AggregationPeriod.day {
afterStart = GetTime() > RegularTradingStart(GetYYYYMMDD());
beforeEnd = GetTime() < RegularTradingEnd(GetYYYYMMDD());
today = if GetLastDay() == GetDay() then 1 else Double.NaN;
openPrice = DailyOpen();
} else {
afterStart = Double.NaN;
beforeEnd = Double.NaN;
today = 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 = 1600;
def TF = SecondsFromTime(CountIn) >= 0 and SecondsTillTime(CountOut) >= 0;

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 = Zone(CountIn = StartTime, CountOut = Update1).VZH;
def Z2H = Zone(CountIn = Update1, CountOut = Update2).VZH;
def Z3H = Zone(CountIn = Update1, CountOut = Update3).VZH;
def Z4H = Zone(CountIn = Update1, CountOut = Update4).VZH;
def Z5H = Zone(CountIn = Update2, CountOut = EndTime).VZH;

def Z1L = Zone(CountIn = StartTime, CountOut = Update1).VZL;
def Z2L = Zone(CountIn = Update1, CountOut = Update2).VZL;
def Z3L = Zone(CountIn = Update1, CountOut = Update3).VZL;
def Z4L = Zone(CountIn = Update1, CountOut = Update4).VZL;
def Z5L = Zone(CountIn = Update2, CountOut = EndTime).VZL;

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


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 Update1 and beforeEnd then Z2H else Double.NaN, if Update1 and beforeEnd then Z2L else Double.NaN, GlobalColor("Zone2"), GlobalColor("Zone2"));
AddCloud(if Update2 and beforeEnd then Z3H else Double.NaN, if Update2 and 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);[/USER]
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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