Ultimate VWAP Indicator for ThinkorSwim

Status
Not open for further replies.

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

added code for alerts, but not sure if they will work. try it out:
http://tos.mx/yQq3PFm
@Welkin Hey I'm a new trader and just finding out your posts and all the work and help you've done, looks amazing!
My only problem as a new trader its a little confusing watching the different videos that are posted to help supplement what you're adding on to.

Do you have or may you create a tutorial video for your indicators and how to set them up. I've watched multiple videos posted along side your scripts but still I'm very lost as a new trader.

May you demonstrate what it is you do and how you do it. So newbies like I would be able to benefit from a dummy proof way of learning.
 
@Welkin Hey I'm a new trader and just finding out your posts and all the work and help you've done, looks amazing!
My only problem as a new trader its a little confusing watching the different videos that are posted to help supplement what you're adding on to.

Do you have or may you create a tutorial video for your indicators and how to set them up. I've watched multiple videos posted along side your scripts but still I'm very lost as a new trader.

May you demonstrate what it is you do and how you do it. So newbies like I would be able to benefit from a dummy proof way of learning.
Appreciate the response, and I'm glad you like the scripts.

As a new trader this probably isn't the best way to start as there is a lot going on, and can be overwhelming. Basic VWAP deviation bands overlaying your chart with no squeeze clouds enabled and no weekly x monthly vwap crossovers would be the way to go + probably 1 or 2 lower indicators such as RSI and/or MACD. Also work in reading market internals. This way you won't be overwhelmed with so much information on your screen and once you have a consistant trading strategy then you should try to slowly add and test other things and see how it works out. I don't think there is any dummy proof way of learning, you just need a lot of screen time and reading charts. Paper trade micro futures or forex can also help outside of regular trading hours.

Not sure if I'll be making a video anytime soon, a more detailed write up is more likely at some point when I have more free time.

also feel free to send me an email, I try to respond to everyone in a timely manner, and I have some stuff I can share that'd probably help you out.
 
Last edited:
I like to consider these areas as overbought/oversold zones of interest where supply/demand dries up and sometimes you can even capture a liquidation break away from these zones, usually towards the weekly/monthly vwap I've found. This isn't 100%, use your own judgement, this is just something I've noticed after looking at a lot of charts and how price reacts to these zones
This is the primary setup that I look for when price breaks out of the crossover clouds. When price moves out of the clouds and retests I go short or long (depending on if its the upper or lower cloud).
another thing to keep in mind is the beginning of a new month, since the monthly vwap resets at the start of a new month this can make the crossover clouds a little wonky.
I feel silly but I don't 100% understand you regarding the clouds and Weekly-VWAP & Monthly-VWAP crossovers...
I do note your warning that on the 1st day of the month the day week and month VWAP will be the same but what I'm saying is this like the 12 avg crossing the 26 avg or what is up?
 
I feel silly but I don't 100% understand you regarding the clouds and Weekly-VWAP & Monthly-VWAP crossovers...
I do note your warning that on the 1st day of the month the day week and month VWAP will be the same but what I'm saying is this like the 12 avg crossing the 26 avg or what is up?
I don't think I'd equate it to a MA crossover... its more like marking on a map boundaries where it is the most statistically advantageous for big money to buy or sell. This doesn't mean that you should buy or sell as soon as you see them come up, many factors push the markets, catalysts, key levels on higher aggregations that want to be tested, etc... for me its a glowing neon sign that says "look out and pay attention, you might not want to buy or sell here".... and over the years its made itself clear to me to be highly probable.
8vFUJJs.png

y5NJX3u.png
 
@Welkin
Thank you so much for your contribution. I use VWAP band all the time to trade futures with Sierrachart and was looking for something similar for while. I'll try to explain how I use it after I'm used to this one later.

In the mean time I wonder if you can point me to where I can find more about Squeeze part your indicator.

PS: This is not supposed to work on tick charts?
I tried to attach a picture or link to Lightshot (screen capture tool) upload to no avail. (Maybe because I'm new here?)
Anyhow on tick chart VWAP is not on although STDeviation bands are there. Also HeikenAshi doesn't work either.
Just in case this is the link to the picture https://prnt.sc/u2ht0m

Thank you.
 
Last edited:
@mptrader You'll need to use a reduced version of the vwap deviations script with all the features that involve multiple aggregations removed for use on tick charts. Heiken ashi will not have the MTF feature, and the squeeze will not be MTF and will only plot squeeze1 for the current tick aggregation. Because the Tick chart will only go up to 5 days the features involving Monthly VWAP will not be available. Also, this will not work on Range tick charts because those charts do not plot with volume.

The Squeeze is plotted when 2 Std Deviation BollingerBands cross inside of Keltner Channels. This is also the same squeeze signal for TTM_Squeeze, which is one of the default indicators provided in the ToS platform. You can read John Bollinger's book Bollinger on BollingerBands, he talks about the squeeze in it, as well as John F. Carter's Mastering the Trade there is also a chapter dedicated to the squeeze. I'm sure you can find those two books easily online if you wish to read them cough*pdfdrive*cough ahem... . There are also some vids on youtube which discuss the squeeze as well.

Code:
#VWAP Deviation Bands for 5 day TICK
#
#VWAP DAILY x WEEKLY 2nd deviation CROSSOVER CLOUDS
#VWAP Alerts
#Paint VWAP or Candlesticks according to Heiken Ashi Trend
#Bollinger and Keltner Squeeze Cloud
#[email protected]


declare upper;
def NA = Double.NaN;

#Colored VWAP to Heiken Ashi Trend toggles
input paintHeikenAshiCandles = no;
input paintHeikenAshiVWAP = yes;
def haAgg1 = GetAggregationPeriod();
input paintVwapBullBear = no;
#VWAP Deviation Band inputs
input vwapAggregation = {default "DAY", "WEEK", "MONTH"};

input vwapAlertSound = Sound.Ring;
input vwapAlertType = Alert.BAR;

input alertVwapDaily = yes;
input alertVwapWeekly = yes;

input alertVwapUB1   = no;
input alertVwapUB2    =yes;
input alertVwapUB3    =yes;
input alertVwapUB4    =yes;
input alertVwapWKHB   =yes;

input alertVwapLB1    =no;
input alertVwapLB2    =yes;
input alertVwapLB3    =yes;
input alertVwapLB4    =yes;
input alertVwapWKLB   =yes;


input enableDeviationClouds = yes;
input enableDailyXWeeklyClouds = yes;

input showVwapFromPriceLabels = yes;
input showDeviationBandWidthLabel = Yes;
input showDxwLabel = yes;

input band1Dev = 1.0;
input band2Dev = 2.0;
input band3Dev = 3.0;
input band4Dev = 4.0;
input band5Dev = 0.5;
input band6Dev = 1.5;
input band7Dev = 2.5;
input band8Dev = 3.5;

#Bollinger and Keltner SQUEEZE inputs
input enableSqueeze1 = yes;

input showSqz1Label = yes;
input sqz1Alert = yes;
input sqzAlertType = Alert.BAR;
input sqzAlertSound = Sound.Ding;
input sqz1VerticalLine = yes;

def displace = 0;
def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_up = 2.0;
def averageType = AverageType.SIMPLE;
def factor = 1.5;
def trueRangeAverageType = AverageType.SIMPLE;


#VWAP Bull Bear Coloring
plot VWAPBullBear = NA;
VWAPBullBear.HideTitle();
VWAPBullBear.DefineColor("Above", CreateColor(0,100,100));
VWAPBullBear.DefineColor("Below", Color.DARK_RED);


#VWAP Dev Above Below Coloring
plot VWAPDevColoring = NA;
VWAPDevColoring.HideTitle();
VWAPDevColoring.DefineColor("UpperAbove", Color.GRAY);
VWAPDevColoring.DefineColor("UpperBelow", CreateColor(30,30,30));
VWAPDevColoring.DefineColor("LowerAbove", CreateColor(30,30,30));
VWAPDevColoring.DefineColor("LowerBelow", Color.GRAY);


#VWAP Deviation Clouds Coloring
plot DeviationClouds = NA;
DeviationClouds.HideTitle();
DeviationClouds.DefineColor("2+3 UpperBand", Color.GRAY);
DeviationClouds.DefineColor("1+2 UpperBand", Color.DARK_GRAY);
DeviationClouds.DefineColor("vwap+1 UpperBand", Color.BLACK);
DeviationClouds.DefineColor("vwap-1 LowerBand", Color.BLACK);
DeviationClouds.DefineColor("1-2 LowerBand", Color.DARK_GRAY);
DeviationClouds.DefineColor("2-3 LowerBand", Color.GRAY);

#Crossover Clouds Coloring
plot CrossoverClouds = NA;
CrossoverClouds.HideTitle();
CrossoverClouds.DefineColor("Daily x Weekly UpperBands", Color.DARK_ORANGE);
CrossoverClouds.DefineColor("Daily x Weekly LowerBands", CreateColor(0, 100, 200));


#Squeeze Clouds Coloring
plot SqueezeClouds = NA;
SqueezeClouds.HideTitle();
SqueezeClouds.DefineColor("Squeeze1", Color.YELLOW);

#Heiken Trend Coloring
plot HeikenAshiPaintColors = NA;
HeikenAshiPaintColors.HideTitle();
HeikenAshiPaintColors.DefineColor("Heiken Up", Color.WHITE);
HeikenAshiPaintColors.DefineColor("Heiken Down", Color.RED);
HeikenAshiPaintColors.DefineColor("Neutral", Color.YELLOW);

#MTF Heiken Ashi
def o = open;
def h = high;
def l = low;
def c = close;

#HAgg1
def o1 = open;
def h1 = high;
def l1 = low;
def c1 = close;
def HA1open;
def HA1high;
def HA1low;
def HA1close;
HA1open = CompoundValue(1, (HA1open[1] + HA1close[1]) / 2, (o1[1] + c1[1]) / 2);
HA1high = Max(Max(h1, HA1open), HA1close[1]);
HA1low = Min(Min(l1, HA1open), HA1close[1]);
HA1close = (o1 + h1 + l1 + c1) / 4;

def HA1 = HA1close > HA1open;

AddLabel(1, "HA1", if HA1 then HeikenAshiPaintColors.Color("Heiken UP") else HeikenAshiPaintColors.Color("Heiken Down"));

#Paint Heiken Candles
AssignPriceColor(if paintHeikenAshiCandles and HA1 then HeikenAshiPaintColors.Color("Heiken UP") else if paintHeikenAshiCandles and !HA1 then HeikenAshiPaintColors.Color("Heiken Down") else Color.CURRENT);

#VWAP Daily, Weekly, and Monthly
plot VWAPDAY =  reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "DAY");
plot VWAPWK = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "WEEK");

VWAPDAY.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
VWAPWK.SetHiding(GetAggregationPeriod() >= AggregationPeriod.WEEK);

#VWAP Distance Label
def VWAPDAYDistance = c - VWAPDAY;
def VWAPWKDistance = c - VWAPWK;

AddLabel(if ShowVwapFromPriceLabels then 1 else 0, "DVWAP: " + AsDollars(VWAPDAYDistance) + " WVWAP: " + AsDollars(VWAPWKDistance), if AbsValue(VWAPDAYDistance) < AbsValue(VWAPWKDistance) then Color.WHITE else Color.DARK_ORANGE);

#VWAP UpperBand and LowerBand values
def VWAPDAYLB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "DAY")."LowerBand";
plot VWAPWKLB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "WEEK")."LowerBand";

def VWAPDAYHB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "DAY")."UpperBand";
plot VWAPWKHB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "WEEK")."UpperBand";

VWAPWKLB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
VWAPWKHB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);

# VWAP Day/Week and Week/Month LowerBand and UpperBand crossover validations
#Day x Week
def VDAYxWKLBDiffH = if !EnableDailyXWeeklyClouds then NA else if VWAPWKLB - VWAPDAYLB <= 0 then NA else VWAPWKLB;
def VDAYxWKLBDiffL = if !EnableDailyXWeeklyClouds then NA else if VWAPWKLB - VWAPDAYLB <= 0 then NA else VWAPDAYLB;
def VDAYxWKHBDiffH = if !EnableDailyXWeeklyClouds then NA else if VWAPDAYHB - VWAPWKHB <= 0 then NA else VWAPDAYHB;
def VDAYxWKHBDiffL = if !EnableDailyXWeeklyClouds then NA else if VWAPDAYHB - VWAPWKHB <= 0 then NA else VWAPWKHB;


#Format Main VWAP Bands
#PaintVWAP According to HeikenAshi
VWAPDAY.DefineColor("Default", Color.YELLOW);

VWAPDAY.AssignValueColor(if !paintHeikenAshiVWAP and !paintVwapBullBear then VWAPDAY.Color("Default") else if paintHeikenAshiVWAP and HA1 then HeikenAshiPaintColors.Color("Heiken Up") else if paintHeikenAshiVWAP and !HA1 then HeikenAshiPaintColors.Color("Heiken Down") else if paintVwapBullBear and c > VWAPDAY then HeikenAshiPaintColors.Color("Heiken Up") else HeikenAshiPaintColors.Color("Heiken Down"));
VWAPDAY.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VWAPWK.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VWAPWK.SetDefaultColor(Color.DARK_ORANGE);

VWAPWKHB.SetStyle(Curve.SHORT_DASH);
VWAPWKHB.SetDefaultColor(Color.DARK_ORANGE);

VWAPWKLB.SetStyle(Curve.SHORT_DASH);
VWAPWKLB.SetDefaultColor(Color.DARK_ORANGE);

AddCloud(VDAYxWKLBDiffH, VDAYxWKLBDiffL, CrossoverClouds.Color("Daily x Weekly LowerBands"), CrossoverClouds.Color("Daily x Weekly LowerBands"));
AddCloud(VDAYxWKHBDiffH, VDAYxWKHBDiffL, CrossoverClouds.Color("Daily x Weekly UpperBands"), CrossoverClouds.Color("Daily x Weekly UpperBands"));

#VWAP Deviation Bands
#UpperBands 1234
plot VWAPUB1 = reference VWAP("num dev up" = Band1Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB2 = reference VWAP("num dev up" = Band2Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB3 = reference VWAP("num dev up" = Band3Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB4 = reference VWAP("num dev up" = Band4Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB5 = reference VWAP("num dev up" = Band5Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB6 = reference VWAP("num dev up" = Band6Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB7 = reference VWAP("num dev up" = Band7Dev, "time frame" = VWAPAggregation)."UpperBand";
plot VWAPUB8 = reference VWAP("num dev up" = Band8Dev, "time frame" = VWAPAggregation)."UpperBand";



#LowerBands 1234
plot VWAPLB1 = reference VWAP("num dev dn" = -Band1Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB2 = reference VWAP("num dev dn" = -Band2Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB3 = reference VWAP("num dev dn" = -Band3Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB4 = reference VWAP("num dev dn" = -Band4Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB5 = reference VWAP("num dev dn" = -Band5Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB6 = reference VWAP("num dev dn" = -Band6Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB7 = reference VWAP("num dev dn" = -Band7Dev, "time frame" = VWAPAggregation)."LowerBand";
plot VWAPLB8 = reference VWAP("num dev dn" = -Band8Dev, "time frame" = VWAPAggregation)."LowerBand";


#VWAP Alerts
Alert(if AlertVWAPDaily then (h >= VWAPDAY) and (l <= VWAPDAY) else NA, "VWAP Daily Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPWeekly then (h >= VWAPWK) and (l <= VWAPWK) else NA, "VWAP Weekly Cross", vwapAlertType, vwapAlertSound);

#VWAP UpperBand Alerts
Alert(if AlertVWAPUB1 then (h >= VWAPUB1) and (l <= VWAPUB1) else NA, "VWAP Upper 1 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPUB2 then (h >= VWAPUB2) and (l <= VWAPUB2) else NA, "VWAP Upper 2 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPUB3 then (h >= VWAPUB3) and (l <= VWAPUB3) else NA, "VWAP Upper 3 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPUB4 then (h >= VWAPUB4) and (l <= VWAPUB4) else NA, "VWAP Upper 4 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPWKHB then (h >= VWAPWKHB) and (l <= VWAPWKHB) else NA, "VWAP Weekly Upper 2 Std Dev Cross", vwapAlertType, vwapAlertSound);

#VWAP LowerBand ALerts
Alert(if AlertVWAPLB1 then (l <= VWAPLB1) and (h >= VWAPLB1) else NA, "VWAP Lower 1 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPLB2 then (l <= VWAPLB2) and (h >= VWAPLB2) else NA, "VWAP Lower 2 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPLB3 then (l <= VWAPLB3) and (h >= VWAPLB3) else NA, "VWAP Lower 3 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPLB4 then (l <= VWAPLB4) and (h >= VWAPLB4) else NA, "VWAP Lower 4 Std Dev Cross", vwapAlertType, vwapAlertSound);
Alert(if AlertVWAPWKLB then (l <= VWAPWKLB) and (h >= VWAPWKLB) else NA, "VWAP Weekly Lower 2 Std Dev Cross", vwapAlertType, vwapAlertSound);

#Format Deviation Bands
VWAPUB1.SetStyle(Curve.FIRM);
VWAPUB1.AssignValueColor(if h >= VWAPUB1 then VWAPDevColoring.Color("UpperAbove") else VWAPDevColoring.Color("UpperBelow"));
VWAPUB2.SetStyle(Curve.FIRM);
VWAPUB2.AssignValueColor(if h >= VWAPUB2 then VWAPDevColoring.Color("UpperAbove") else VWAPDevColoring.Color("UpperBelow"));
VWAPUB3.SetStyle(Curve.FIRM);
VWAPUB3.AssignValueColor(if h >= VWAPUB3 then VWAPDevColoring.Color("UpperAbove") else VWAPDevColoring.Color("UpperBelow"));
VWAPUB4.SetStyle(Curve.FIRM);
VWAPUB4.AssignValueColor(if h >= VWAPUB4 then VWAPDevColoring.Color("UpperAbove") else VWAPDevColoring.Color("UpperBelow"));
VWAPUB5.SetStyle(Curve.SHORT_DASH);
VWAPUB5.SetDefaultColor(CreateColor(30,30,30));
VWAPUB6.SetStyle(Curve.SHORT_DASH);
VWAPUB6.SetDefaultColor(CreateColor(30,30,30));
VWAPUB7.SetStyle(Curve.SHORT_DASH);
VWAPUB7.SetDefaultColor(CreateColor(30,30,30));
VWAPUB8.SetStyle(Curve.SHORT_DASH);
VWAPUB8.SetDefaultColor(CreateColor(30,30,30));


VWAPLB1.SetStyle(Curve.FIRM);
VWAPLB1.AssignValueColor(if l >= VWAPLB1 then VWAPDevColoring.Color("LowerAbove") else VWAPDevColoring.Color("LowerBelow"));
VWAPLB2.SetStyle(Curve.FIRM);
VWAPLB2.AssignValueColor(if l >= VWAPLB2 then VWAPDevColoring.Color("LowerAbove") else VWAPDevColoring.Color("LowerBelow"));
VWAPLB3.SetStyle(Curve.FIRM);
VWAPLB3.AssignValueColor(if l >= VWAPLB3 then VWAPDevColoring.Color("LowerAbove") else VWAPDevColoring.Color("LowerBelow"));
VWAPLB4.SetStyle(Curve.FIRM);
VWAPLB4.AssignValueColor(if l >= VWAPLB4 then VWAPDevColoring.Color("LowerAbove") else VWAPDevColoring.Color("LowerBelow"));
VWAPLB5.SetStyle(Curve.SHORT_DASH);
VWAPLB5.SetDefaultColor(CreateColor(30,30,30));
VWAPLB6.SetStyle(Curve.SHORT_DASH);
VWAPLB6.SetDefaultColor(CreateColor(30,30,30));
VWAPLB7.SetStyle(Curve.SHORT_DASH);
VWAPLB7.SetDefaultColor(CreateColor(30,30,30));
VWAPLB8.SetStyle(Curve.SHORT_DASH);
VWAPLB8.SetDefaultColor(CreateColor(30,30,30));

#Clouds for Deviation Bands 2 and 3
AddCloud(if enableDeviationClouds then VWAPUB3 else NA, VWAPUB2, DeviationClouds.Color("2+3 UpperBand"), DeviationClouds.Color("2+3 UpperBand"), no);
AddCloud(if enableDeviationClouds then VWAPUB2 else NA, VWAPUB1, DeviationClouds.Color("1+2 UpperBand"), DeviationClouds.Color("1+2 UpperBand"), yes);
AddCloud(if enableDeviationClouds then VWAPUB1 else NA, VWAPDAY, DeviationClouds.Color("VWAP+1 UpperBand"), DeviationClouds.Color("VWAP+1 UpperBand"), no);

AddCloud(if enableDeviationClouds then VWAPDAY else NA, VWAPLB1, DeviationClouds.Color("VWAP-1 LowerBand"), DeviationClouds.Color("VWAP-1 LowerBand"), no);
AddCloud(if enableDeviationClouds then VWAPLB1 else NA, VWAPLB2, DeviationClouds.Color("1-2 LowerBand"), DeviationClouds.Color("1-2 LowerBand"), yes);
AddCloud(if enableDeviationClouds then VWAPLB2 else NA, VWAPLB3, DeviationClouds.Color("2-3 LowerBand"), DeviationClouds.Color("2-3 LowerBand"), no);
#VWAP Dev Clouds
#AddCloud(hl2, VWAPDAY, VWAPBullBear.Color("Above"), VWAPBullBear.Color("Below"), no);


#Deviation Bandwidth Label
AddLabel(ShowDeviationBandWidthLabel, "DevBW: $" + AsText((VWAPUB1 - VWAPDAY), NumberFormat.TWO_DECIMAL_PLACES), Color.GRAY);


#DxW and WxM Crossover Labels
AddLabel(if EnableDailyXWeeklyClouds and ShowDXWLabel then 1 else 0, "DxW", if (VWAPDAYHB > VWAPWKHB) then CrossoverClouds.Color("Daily x Weekly UpperBands") else if (VWAPDAYLB < VWAPWKLB) then CrossoverClouds.Color("Daily x Weekly LowerBands") else Color.DARK_GRAY);

#Bollinger and Keltner SQUEEZE
#MTF Squeeze Clouds

def price1 = close;

#BollingerBands Upper Middle Lower
def sDev1 = StDev(data = price1[-displace], length = length);
def MidLine1 = MovingAverage(averageType, data = price1[-displace], length = length);
def BLowerBand1 = MidLine1 + Num_Dev_Dn * sDev1;
def BUpperBand1 = MidLine1 + Num_Dev_up * sDev1;

#Keltner Channels Upper Middle Lower
def shift1 = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);

def average1 = MovingAverage(averageType, price1, length);
def Avg1 = average1[-displace];
def KUpperBand1 = average1[-displace] + shift1[-displace];
def KLowerBand1 = average1[-displace] - shift1[-displace];

#Squeeze Verification = Bollinger Upper and Lower Bands Cross inside Keltner Channel Upper and Lower Bands
def sqz1conf = KUpperBand1 - BUpperBand1 <= 0;

plot sqz1MarkerH = if EnableSqueeze1 and sqz1conf[1] and !sqz1conf then BUpperBand1 else NA;
plot sqz1MarkerL = if EnableSqueeze1 and sqz1conf[1] and !sqz1conf then BLowerBand1 else NA;

def BollKeltUB1DiffH = if !EnableSqueeze1 then NA else if sqz1conf then NA else KUpperBand1;
def BollKeltUB1DiffL = if !EnableSqueeze1 then NA else if sqz1conf then NA else BUpperBand1;
def BollKeltLB1DiffH = if !EnableSqueeze1 then NA else if sqz1conf then NA else BLowerBand1;
def BollKeltLB1DiffL = if !EnableSqueeze1 then NA else if sqz1conf then NA else KLowerBand1;

plot Sqz1H = BollKeltUB1DiffL;
plot Sqz1L = BollKeltLB1DiffH;

#Sqz 1 2 3 Labels
AddLabel(if EnableSqueeze1 and ShowSqz1Label then 1 else 0,"Sqz1", if !sqz1conf then SqueezeClouds.Color("Squeeze1") else Color.DARK_GRAY);

#squeeze alerts
Alert(if Sqz1Alert then sqz1conf[1] and !sqz1conf else NA, "Squeeze1", sqzAlertType, sqzAlertSound);
AddVerticalLine(if Sqz1VerticalLine then sqz1conf[1] and !sqz1conf else NA, "Sqz1", SqueezeClouds.Color("Squeeze1"), stroke = Curve.POINTS);

Sqz1H.AssignValueColor(SqueezeClouds.Color("Squeeze1"));
Sqz1H.SetLineWeight(1);
Sqz1L.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz1L.AssignValueColor(SqueezeClouds.Color("Squeeze1"));
Sqz1L.SetLineWeight(1);

sqz1MarkerH.SetDefaultColor(SqueezeClouds.Color("Squeeze1"));
sqz1MarkerL.SetDefaultColor(SqueezeClouds.Color("Squeeze1"));
sqz1MarkerH.SetPaintingStrategy(PaintingStrategy.SQUARES);
sqz1MarkerL.SetPaintingStrategy(PaintingStrategy.SQUARES);

#Clouds for Squeezes
AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
 
Last edited:
Hey Welkin,
Thanks for the great work! :D I love it.
What does HA1 & HA2 labels indicate?
Thanks
No problem, glad you like it.
HA1 is Heiken Ashi trend for current aggregation, HA2 is the Heiken Ashi trend 2nd aggregation specified in the settings.
 
Last edited:
Hi @Welkin

I was wondering if you could help me code a script that does one thing only, paint a cloud between the two upper standard vwap deviation bands 1.0 and 2.0? I know that your Ultimate Vwap study already does this but i only need this single cloud and nothing else and i don't know exactly what part of the code i need to remove to have only the cloud left so if you could help me create a new study with this i would appreciate it very much.

Edit: And if you could possibly also add audio alert when price crosses into this cloud (std dev 1.0) from below that would be great.
 
Last edited:
Hi @Welkin

I was wondering if you could help me code a script that does one thing only, paint a cloud between the two upper standard vwap deviation bands 1.0 and 2.0? I know that your Ultimate Vwap study already does this but i only need this single cloud and nothing else and i don't know exactly what part of the code i need to remove to have only the cloud left so if you could help me create a new study with this i would appreciate it very much.

Edit: And if you could possibly also add audio alert when price crosses into this cloud (std dev 1.0) from below that would be great.
here you go
http://tos.mx/iHrPreA
 
Hi @Welkin what do you think of this 'synthetic VWAP' some people are using?
The reason I ask is because the Day VWAP doesn't do you much good at the market open or on other times if you trade futures.
This one a 5min chart...
For a minute I thought well okay here is the official formula to something we all know.

DQ3wqmb.jpg


But then here we have a formula that uses the existing VWAP only 'smoothed' I guess
Code:
input VWAPlength = 200;
def zeros = vwap - vwap[2];
def filter = reference EhlersSuperSmootherFilter(price = zeros, "cutoff length" = 0.5 * VWAPlength);
def rms = Sqrt(Average(Sqr(filter),VWAPlength));
def scaledFilter = filter / rms;
def alpha = 5 * AbsValue(scaledFilter) / VWAPlength;
def deviationScaledVWAP = CompoundValue(1, alpha * vwap + (1 - alpha) * deviationScaledVWAP[1], vwap);
plot feVWAP = deviationScaledVWAP;

BTW Is everyone in the family back to normal yet? 🤞
 
Hi @Welkin what do you think of this 'synthetic VWAP' some people are using?
The reason I ask is because the Day VWAP doesn't do you much good at the market open or on other times if you trade futures.
This one a 5min chart...
For a minute I thought well okay here is the official formula to something we all know.

DQ3wqmb.jpg


But then here we have a formula that uses the existing VWAP only 'smoothed' I guess
Code:
input VWAPlength = 200;
def zeros = vwap - vwap[2];
def filter = reference EhlersSuperSmootherFilter(price = zeros, "cutoff length" = 0.5 * VWAPlength);
def rms = Sqrt(Average(Sqr(filter),VWAPlength));
def scaledFilter = filter / rms;
def alpha = 5 * AbsValue(scaledFilter) / VWAPlength;
def deviationScaledVWAP = CompoundValue(1, alpha * vwap + (1 - alpha) * deviationScaledVWAP[1], vwap);
plot feVWAP = deviationScaledVWAP;

BTW Is everyone in the family back to normal yet? 🤞
Don't think I've come across this one before, I understand what you meant though about its potential with futures at the start of a new session due to it not 'resetting' like the normal vwap on a new day or requiring a warm-up period as I'd like to call it... Not sure if its something I'd be using though, not because I'm just too attached to the normal VWAP, but because one of the key features of the VWAP is that it's calculations are consistant across multiple timeframes. I think this 'synthetic VWAP' should be considered a hybrid of a VWMA+VWAP because it combines both the average function with a defined length and a cumulative function using compoundvalue(). The Cyan plot is purely a VWMA, however.

Thanks for asking about the fam, things are looking a lot better, but not completely out of the woods just yet! My bro is on some very strong antibiotics and has a catheter ran directly to the bladder through an incision in his pelvic region. Good thing is that the cystoscopy didn't show kidney stones, a tumor, or blood clots blocking his kidney, it was due to the inflammation over a long period of time from fighting off UTIs that caused a lot of waste to build up in his left kidney.
 
@Welkin A simple question. How to expand the main chart portion to suit the current price range (such as your). Mine came out not easy too focus on the current price range
 
A simple question. How to expand the main chart portion to suit the current price range (such as your). Mine came out not easy too focus on the current price range
if you're referring to how I keep the chart zoomed out just enough for price action to still be clear, i use the + and - zoom buttons on the bottom right of the chart until I hit a sweet spot of readability, or click and drag on the x axis where the date and time is on the bottom of the charts.
 
Can anyone add code to this indicator so you can designate start and end times. I want to run this on a eth chart but show the rth vwap. Currently I use 2 charts and would like simplicity. Thank you all.
 
@keithm Add the following code at the bottom of any Study or Strategy...

Ruby:
#hint:Places vertical lines at start and end times
#TOS title = VertLines_at_START_END_times
input Start = 0930;
input End = 1600;
def StartTime = SecondsFromTime(Start) == 0;
def EndTime = SecondsFromTime(End) == 0;
AddVerticalLine(StartTime,"Start",Color.GREEN,Curve.SHORT_DASH);
AddVerticalLine(EndTime,"End",Color.RED,Curve.SHORT_DASH);
 
The author of the study isn't available on the forum to provide answers to questions. So this thread has been locked.
 
Last edited:
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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