hitogamy
New member
hi im trying to paste and copy the code to my thinkorswim but it doesn't show up i need some help pleaseLook very nice! But the VWAP deviation bands are not showing for me. Anyone else with same problem?
hi im trying to paste and copy the code to my thinkorswim but it doesn't show up i need some help pleaseLook very nice! But the VWAP deviation bands are not showing for me. Anyone else with same problem?
this is a good starting point to learn about vwap. i also recommend scouring youtube for other vids on trading with vwap.This looks like a very nice indicator. Is there any link or documentation of how one uses this indicator? Thanks
this should do itIs it possible to create an audio alert when the price gets to and crosses the 2nd VWAP deviation band (upper)? @Welkin
#VWAP Deviation Bands
#VWAP DAILY x WEEKLY AND WEEKLY x MONTHLY 2nd deviation CROSSOVER CLOUDS
#Paint VWAP or Candlesticks according to Heiken Ashi Trend
#Bollinger and Keltner MTF Squeeze Clouds
#[email protected]
#version 7.23.2020
declare upper;
def NA = Double.NaN;
#Colored VWAP to Heiken Ashi Trend toggles
input paintHeikenAshiCandles = no;
input paintHeikenAshiVWAP = no;
#VWAP Deviation Band inputs
input vwapAggregation = {default "DAY", "WEEK", "MONTH"};
input enableDailyXWeeklyClouds = yes;
input enableWeeklyXMonthlyClouds = yes;
input showVwapFromPriceLabels = yes;
input showDeviationBandWidthLabel = Yes;
input showDXWLabel = yes;
input showWXMLabel = yes;
input vwapAlerts = yes;
input vwapAlertSound = Sound.Chimes;
input vwapUpperAlertTrigger = {VWAPUB1, default VWAPUB2, VWAPUB3, VWAPWKHB, VWAPMNTHHB};
input vwapLowerAlertTrigger = {VWAPLB1, default VWAPLB2, VWAPLB3, VWAPWKLB, VWAPMNTHLB};
input vwapAlertType = Alert.BAR;
input band1Dev = 1.0;
input band2Dev = 2.0;
input band3Dev = 3.0;
#Bollinger and Keltner SQUEEZE inputs
input enableSqueeze1 = yes;
input enableSqueeze2 = no;
input enableSqueeze3 = no;
def SqzAggregation1 = GetAggregationPeriod();
input sqzAggregation2 = AggregationPeriod.THIRTY_MIN;
input sqzAggregation3 = AggregationPeriod.HOUR;
input showSqz1Label = yes;
input showSqz2Label = yes;
input showSqz3Label = yes;
input sqz1Alert = yes;
input sqz2Alert = yes;
input sqz3Alert = yes;
input sqzAlertType = Alert.BAR;
input sqzAlertSound = Sound.Ding;
input sqz1VerticalLine = yes;
input sqz2VerticalLine = yes;
input sqz3VerticalLine = 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;
#Aggregation Warning Labels
AddLabel(if (EnableSqueeze2 and GetAggregationPeriod() > SqzAggregation2) or (EnableSqueeze3 and GetAggregationPeriod() > SqzAggregation3) then 1 else 0, if GetAggregationPeriod() > SqzAggregation2 then "Time Frame > SqzAggregation2" else "Time Frame > SqzAggregation3" , Color.YELLOW);
AddLabel(if (GetAggregationPeriod() >= AggregationPeriod.DAY and VWAPAggregation == VWAPAggregation."DAY") or (GetAggregationPeriod() >= AggregationPeriod.WEEK and VWAPAggregation == VWAPAggregation."WEEK") or (GetAggregationPeriod() >= AggregationPeriod.MONTH and VWAPAggregation == VWAPAggregation."MONTH") then 1 else 0, "Time Frame >= VWAPAggregation", Color.YELLOW);
#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", CreateColor(0, 100, 200));
CrossoverClouds.DefineColor("Weekly x Monthly UpperBands", CreateColor(100, 0, 200));
CrossoverClouds.DefineColor("Daily x Weekly LowerBands", CreateColor(0, 100, 200));
CrossoverClouds.DefineColor("Weekly x Monthly LowerBands", CreateColor(100, 0, 200));
#Squeeze Clouds Coloring
plot SqueezeClouds = NA;
SqueezeClouds.HideTitle();
SqueezeClouds.DefineColor("Squeeze1", Color.YELLOW);
SqueezeClouds.DefineColor("Squeeze2", Color.DARK_ORANGE);
SqueezeClouds.DefineColor("Squeeze3", Color.RED);
#Define Heiken Ashi
def o = open;
def h = high;
def l = low;
def c = close;
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (o[1] + c[1]) / 2);
HAhigh = Max(Max(h, HAopen), HAclose[1]);
HAlow = Min(Min(l, HAopen), HAclose[1]);
HAclose = (open + high + low + close) / 4;
plot HeikenAshiPaintColors = NA;
HeikenAshiPaintColors.HideTitle();
#VWAPDAY.DefineColor("Default", Color.WHITE);
HeikenAshiPaintColors.DefineColor("Heiken Up", CreateColor(0, 100, 255));
HeikenAshiPaintColors.DefineColor("Heiken Down", Color.RED);
#Paint Heiken Candles
AssignPriceColor(if !PaintHeikenAshiCandles then Color.CURRENT else if HAclose > HAopen then HeikenAshiPaintColors.Color("Heiken UP") else HeikenAshiPaintColors.Color("Heiken Down"));
#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");
plot VWAPMNTH = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH");
VWAPDAY.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
VWAPWK.SetHiding(GetAggregationPeriod() >= AggregationPeriod.WEEK);
#VWAP Distance Label
def VWAPDAYDistance = close - VWAPDAY;
def VWAPWKDistance = close - VWAPWK;
def VWAPMNTHDistance = close - VWAPMNTH;
AddLabel(if ShowVwapFromPriceLabels then 1 else 0,"DVWAP: "+ AsDollars(VWAPDAYDistance) + " WVWAP: " + AsDollars(VWAPWKDistance) + " MVWAP: " + AsDollars(VWAPMNTHDistance), if AbsValue(VWAPDAYDistance) < AbsValue(VWAPWKDistance) and AbsValue(VWAPDAYDistance) < AbsValue(VWAPMNTHDistance) then Color.WHITE else if AbsValue(VWAPWKDistance) < AbsValue(VWAPDAYDistance) and AbsValue(VWAPWKDistance) < AbsValue(VWAPMNTHDistance) then Color.DARK_ORANGE else if VWAPWKDistance and VWAPMNTHdistance == VWAPDayDistance then Color.WHITE else Color.RED);
#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";
plot VWAPMNTHLB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH")."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";
plot VWAPMNTHHB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH")."UpperBand";
VWAPWKLB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
VWAPWKHB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
VWAPMNTHLB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
VWAPMNTHHB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
# 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;
#Week x Month
def VWKxMNTHLBDiffH = if !EnableWeeklyxMonthlyClouds then NA else if VWAPMNTHLB - VWAPWKLB <= 0 then NA else VWAPMNTHLB;
def VWKxMNTHLBDiffL = if !EnableWeeklyxMonthlyClouds then NA else if VWAPMNTHLB - VWAPWKLB <= 0 then NA else VWAPWKLB;
def VWKxMNTHHBDiffH = if !EnableWeeklyxMonthlyClouds then NA else if VWAPWKHB - VWAPMNTHHB <= 0 then NA else VWAPWKHB;
def VWKxMNTHHBDiffL = if !EnableWeeklyxMonthlyClouds then NA else if VWAPWKHB - VWAPMNTHHB <= 0 then NA else VWAPMNTHHB;
#Format Main VWAP Bands
#PaintVWAP According to HeikenAshi
VWAPDAY.DefineColor("Default", Color.WHITE);
VWAPDAY.AssignValueColor(if !PaintHeikenAshiVWAP then VWAPDAY.Color("Default") else if HAclose > HAopen 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);
VWAPMNTH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VWAPMNTH.SetDefaultColor(Color.RED);
VWAPMNTHHB.SetStyle(Curve.LONG_DASH);
VWAPMNTHHB.SetDefaultColor(Color.RED);
VWAPMNTHLB.SetStyle(Curve.LONG_DASH);
VWAPMNTHLB.SetDefaultColor(Color.RED);
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"));
AddCloud(VWKxMNTHLBDiffH, VWKxMNTHLBDiffL, CrossoverClouds.Color("Weekly x Monthly LowerBands"), CrossoverClouds.Color("Weekly x Monthly LowerBands"));
AddCloud(VWKxMNTHHBDiffH, VWKxMNTHHBDiffL, CrossoverClouds.Color("Weekly x Monthly UpperBands"), CrossoverClouds.Color("Weekly x Monthly UpperBands"));
#VWAP Deviation Bands
#UpperBands 123
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";
VWAPUB1.Hide();
VWAPUB2.Hide();
VWAPUB3.Hide();
#LowerBands 123
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";
VWAPLB1.Hide();
VWAPLB2.Hide();
VWAPLB3.Hide();
#Format Deviation Bands
VWAPUB1.SetStyle(Curve.FIRM);
VWAPUB1.SetDefaultColor(CreateColor(120, 120, 120));
VWAPUB2.SetStyle(Curve.FIRM);
VWAPUB2.SetDefaultColor(CreateColor(0, 0, 35));
VWAPUB3.SetStyle(Curve.FIRM);
VWAPUB3.SetDefaultColor(CreateColor(0, 0, 35));
VWAPLB1.SetStyle(Curve.FIRM);
VWAPLB1.SetDefaultColor(CreateColor(120, 120, 120));
VWAPLB2.SetStyle(Curve.FIRM);
VWAPLB2.SetDefaultColor(CreateColor(0, 0, 35));
VWAPLB3.SetStyle(Curve.FIRM);
VWAPLB3.SetDefaultColor(CreateColor(0, 0, 35));
#Clouds for Deviation Bands 2 and 3
AddCloud(VWAPUB3, VWAPUB2, DeviationClouds.Color("2+3 UpperBand"), DeviationClouds.Color("2+3 UpperBand"), no);
AddCloud(VWAPUB2, VWAPUB1, DeviationClouds.Color("1+2 UpperBand"), DeviationClouds.Color("1+2 UpperBand"), yes);
AddCloud(VWAPUB1, VWAPDAY, DeviationClouds.Color("VWAP+1 UpperBand"), DeviationClouds.Color("VWAP+1 UpperBand"), no);
AddCloud(VWAPDAY, VWAPLB1, DeviationClouds.Color("VWAP-1 LowerBand"), DeviationClouds.Color("VWAP-1 LowerBand"), no);
AddCloud(VWAPLB1, VWAPLB2, DeviationClouds.Color("1-2 LowerBand"), DeviationClouds.Color("1-2 LowerBand"), yes);
AddCloud(VWAPLB2, VWAPLB3, DeviationClouds.Color("2-3 LowerBand"), DeviationClouds.Color("2-3 LowerBand"), no);
AddCloud(VWAPUB3, VWAPLB3, Color.DARK_GRAY, Color.DARK_GRAY,no);
#Deviation Bandwidth Label
AddLabel(ShowDeviationBandwidthLabel,"DevBW: $"+ AsText((VWAPUB1 - VWAPDAY),NumberFormat.TWO_DECIMAL_PLACES), Color.GRAY);
#VWAP Alerts
Alert(if vwapAlerts then close crosses above vwapUpperAlertTrigger else NA, "VWAP 2nd Deviation Cross", vwapAlertType, vwapAlertSound);
Alert(if vwapAlerts then close crosses below vwapLowerAlertTrigger else NA, "VWAP 2nd Deviation Cross", vwapAlertType, vwapAlertSound);
#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);
AddLabel(if EnableWeeklyxMonthlyClouds and ShowWxMLabel then 1 else 0,"WxM", if (VWAPWKHB > VWAPMNTHHB) then CrossoverClouds.Color("Weekly x Monthly UpperBands") else if (VWAPWKLB < VWAPMNTHLB) then CrossoverClouds.Color("Weekly x Monthly LowerBands") else Color.DARK_GRAY);
#Bollinger and Keltner SQUEEZE
#MTF Squeeze Clouds
def price1 = close("Period" = SqzAggregation1);
def price2 = close("Period" = SqzAggregation2);
def price3 = close("Period" = SqzAggregation3);
#BollingerBands Upper Middle Lower
def sDev1 = StDev(data = price1[-displace], length = length);
def sDev2 = StDev(data = price2[-displace], length = length);
def sDev3 = StDev(data = price3[-displace], length = length);
def MidLine1 = MovingAverage(averageType, data = price1[-displace], length = length);
def MidLine2 = MovingAverage(averageType, data = price2[-displace], length = length);
def MidLine3 = MovingAverage(averageType, data = price3[-displace], length = length);
def BLowerBand1 = MidLine1 + Num_Dev_Dn * sDev1;
def BLowerBand2 = MidLine2 + Num_Dev_Dn * sDev2;
def BLowerBand3 = MidLine3 + Num_Dev_Dn * sDev3;
def BUpperBand1 = MidLine1 + Num_Dev_up * sDev1;
def BUpperBand2 = MidLine2 + Num_Dev_up * sDev2;
def BUpperBand3 = MidLine3 + Num_Dev_up * sDev3;
#Keltner Channels Upper Middle Lower
def shift1 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAggregation1), close("Period" = SqzAggregation1), low("Period" = SqzAggregation1)), length);
def shift2 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAggregation2), close("Period" = SqzAggregation2), low("Period" = SqzAggregation2)), length);
def shift3 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAggregation3), close("Period" = SqzAggregation3), low("Period" = SqzAggregation3)), length);
def average1 = MovingAverage(averageType, price1, length);
def average2 = MovingAverage(averageType, price2, length);
def average3 = MovingAverage(averageType, price3, length);
def Avg1 = average1[-displace];
def Avg2 = average2[-displace];
def Avg3 = average3[-displace];
def KUpperBand1 = average1[-displace] + shift1[-displace];
def kUpperBand2 = average2[-displace] + shift2[-displace];
def kUpperBand3 = average3[-displace] + shift3[-displace];
def KLowerBand1 = average1[-displace] - shift1[-displace];
def KLowerBand2 = average2[-displace] - shift2[-displace];
def KLowerBand3 = average3[-displace] - shift3[-displace];
#Squeeze Verification = Bollinger Upper and Lower Bands Cross inside Keltner Channel Upper and Lower Bands
def BollKeltUB1DiffH = if !EnableSqueeze1 then NA else if KUpperBand1 - BUpperBand1 <= 0 then NA else KUpperBand1;
def BollKeltUB1DiffL = if !EnableSqueeze1 then NA else if KUpperBand1 - BUpperBand1 <= 0 then NA else BUpperBand1;
def BollKeltLB1DiffH = if !EnableSqueeze1 then NA else if BLowerBand1 - KLowerBand1 <= 0 then NA else BLowerBand1;
def BollKeltLB1DiffL = if !EnableSqueeze1 then NA else if BLowerBand1 - KLowerBand1 <= 0 then NA else KLowerBand1;
def BollKeltUB2DiffH = if !EnableSqueeze2 then NA else if kUpperBand2 - BUpperBand2 <= 0 then NA else kUpperBand2;
def BollKeltUB2DiffL = if !EnableSqueeze2 then NA else if kUpperBand2 - BUpperBand2 <= 0 then NA else BUpperBand2;
def BollKeltLB2DiffH = if !EnableSqueeze2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else BLowerBand2;
def BollKeltLB2DiffL = if !EnableSqueeze2 then NA else if BLowerBand2 - KLowerBand2 <= 0 then NA else KLowerBand2;
def BollKeltUB3DiffH = if !EnableSqueeze3 then NA else if kUpperBand3 - BUpperBand3 <= 0 then NA else kUpperBand3;
def BollKeltUB3DiffL = if !EnableSqueeze3 then NA else if kUpperBand3 - BUpperBand3 <= 0 then NA else BUpperBand3;
def BollKeltLB3DiffH = if !EnableSqueeze3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else BLowerBand3;
def BollKeltLB3DiffL = if !EnableSqueeze3 then NA else if BLowerBand3 - KLowerBand3 <= 0 then NA else KLowerBand3;
#Sqz 1 2 3 Labels
AddLabel(if EnableSqueeze1 and ShowSqz1Label then 1 else 0,"Sqz1", if (kUpperBand1 - BUpperBand1) > 0 then SqueezeClouds.Color("Squeeze1") else Color.DARK_GRAY);
AddLabel(if EnableSqueeze2 and ShowSqz2Label then 1 else 0,"Sqz2", if (kUpperBand2 - BUpperBand2) > 0 then SqueezeClouds.Color("Squeeze2") else Color.DARK_GRAY);
AddLabel(if EnableSqueeze3 and ShowSqz3Label then 1 else 0,"Sqz3", if (kUpperBand3 - BUpperBand3) > 0 then SqueezeClouds.Color("Squeeze3") else Color.DARK_GRAY);
#squeeze alerts
Alert(if Sqz1Alert then ((kUpperBand1[2] - BUpperBand1[2]) < 0) and ((kUpperBand1[1] - BUpperBand1[1]) > 0) and ((kUpperBand1 - BUpperBand1) > 0) else NA, "Squeeze1", sqzAlertType, sqzAlertSound);
Alert(if Sqz2Alert then ((kUpperBand2[2] - BUpperBand2[2]) < 0) and ((kUpperBand2[1] - BUpperBand2[1]) > 0) and ((kUpperBand2 - BUpperBand2) > 0) else NA, "Squeeze2", sqzAlertType, sqzAlertSound);
Alert(if Sqz3Alert then ((kUpperBand3[2] - BUpperBand3[2]) < 0) and ((kUpperBand3[1] - BUpperBand3[1]) > 0) and ((kUpperBand3 - BUpperBand3) > 0) else NA, "Squeeze3", sqzAlertType, sqzAlertSound);
AddVerticalLine(if Sqz1VerticalLine then ((kUpperBand1[2] - BUpperBand1[2]) < 0) and ((kUpperBand1[1] - BUpperBand1[1]) > 0) and ((kUpperBand1 - BUpperBand1) > 0) else NA, "Sqz1", SqueezeClouds.Color("Squeeze1"), stroke = Curve.POINTS);
AddVerticalLine(if Sqz2VerticalLine then((kUpperBand2[2] - BUpperBand2[2]) < 0) and ((kUpperBand2[1] - BUpperBand2[1]) > 0) and ((kUpperBand2 - BUpperBand2) > 0) else NA, "Sqz2", SqueezeClouds.Color("Squeeze2"), stroke = Curve.POINTS);
AddVerticalLine(if Sqz3VerticalLine then ((kUpperBand3[2] - BUpperBand3[2]) < 0) and ((kUpperBand3[1] - BUpperBand3[1]) > 0) and ((kUpperBand3 - BUpperBand3) > 0) else NA, "Sqz3", SqueezeClouds.Color("Squeeze3"), stroke = Curve.POINTS);
#Clouds for Squeezes
AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
AddCloud(BollKeltUB2DiffH, BollKeltUB2DiffL, SqueezeClouds.Color("Squeeze2"), SqueezeClouds.Color("Squeeze2"));
AddCloud(BollKeltLB2DiffH, BollKeltLB2DiffL, SqueezeClouds.Color("Squeeze2"), SqueezeClouds.Color("Squeeze2"));
AddCloud(BollKeltUB3DiffH, BollKeltUB3DiffL, SqueezeClouds.Color("Squeeze3"), SqueezeClouds.Color("Squeeze3"));
AddCloud(BollKeltLB3DiffH, BollKeltLB3DiffL, SqueezeClouds.Color("Squeeze3"), SqueezeClouds.Color("Squeeze3"));
Updated the alerts and how they are triggered, you can now have simultaneous alerts for any of the VWAP plots.Thank you for adding the alerts @Welkin
Works great
#VWAP Deviation Bands
#VWAP DAILY x WEEKLY AND WEEKLY x MONTHLY 2nd deviation CROSSOVER CLOUDS
#VWAP Alerts
#Paint VWAP or Candlesticks according to Heiken Ashi Trend
#Bollinger and Keltner MTF Squeeze Clouds
#[email protected]
#version 7.29.2020
declare upper;
def NA = Double.NaN;
#Colored VWAP to Heiken Ashi Trend toggles
input paintHeikenAshiCandles = yes;
input paintHeikenAshiVWAP = no;
def haAgg1 = GetAggregationPeriod();
input haAgg2 = AggregationPeriod.FIVE_MIN;
input paintVwapBullBear = yes;
#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 alertVwapMonthly = yes;
input alertVwapUB1 = no;
input alertVwapUB2 =yes;
input alertVwapUB3 =yes;
input alertVwapUB4 =yes;
input alertVwapWKHB =yes;
input alertVwapMNTHHB =yes;
input alertVwapLB1 =no;
input alertVwapLB2 =yes;
input alertVwapLB3 =yes;
input alertVwapLB4 =yes;
input alertVwapWKLB =yes;
input alertVwapMNTHLB =yes;
input enableDeviationClouds = yes;
input enableDailyXWeeklyClouds = yes;
input enableWeeklyXMonthlyClouds = yes;
input showVwapFromPriceLabels = yes;
input showDeviationBandWidthLabel = Yes;
input showDxwLabel = yes;
input showWxmLabel = 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 enableSqueeze2 = yes;
input enableSqueeze3 = yes;
def sqzAggregation1 = GetAggregationPeriod();
input sqzAggregation2 = AggregationPeriod.THIRTY_MIN;
def SqzAgg2 = if GetAggregationPeriod() > SqzAggregation2 then GetAggregationPeriod() else SqzAggregation2;
input sqzAggregation3 = AggregationPeriod.HOUR;
def SqzAgg3 = if GetAggregationPeriod() > SqzAggregation3 then GetAggregationPeriod() else SqzAggregation3;
input showSqz1Label = yes;
input showSqz2Label = yes;
input showSqz3Label = yes;
input sqz1Alert = yes;
input sqz2Alert = yes;
input sqz3Alert = yes;
input sqzAlertType = Alert.BAR;
input sqzAlertSound = Sound.Ding;
input sqz1VerticalLine = yes;
input sqz2VerticalLine = yes;
input sqz3VerticalLine = 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;
#Aggregation Warning Labels
AddLabel(if (EnableSqueeze2 and GetAggregationPeriod() > SqzAggregation2) or (EnableSqueeze3 and GetAggregationPeriod() > SqzAggregation3) then 1 else 0, if GetAggregationPeriod() > SqzAggregation2 then "Time Frame > SqzAggregation2" else "Time Frame > SqzAggregation3" , Color.YELLOW);
AddLabel(if (GetAggregationPeriod() >= AggregationPeriod.DAY and VWAPAggregation == VWAPAggregation."DAY") or (GetAggregationPeriod() >= AggregationPeriod.WEEK and VWAPAggregation == VWAPAggregation."WEEK") or (GetAggregationPeriod() >= AggregationPeriod.MONTH and VWAPAggregation == VWAPAggregation."MONTH") then 1 else 0, "Time Frame >= VWAPAggregation", Color.YELLOW);
#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("Weekly x Monthly UpperBands", Color.RED);
CrossoverClouds.DefineColor("Daily x Weekly LowerBands", CreateColor(0, 100, 200));
CrossoverClouds.DefineColor("Weekly x Monthly LowerBands", Color.GREEN);
#Squeeze Clouds Coloring
plot SqueezeClouds = NA;
SqueezeClouds.HideTitle();
SqueezeClouds.DefineColor("Squeeze1", Color.YELLOW);
SqueezeClouds.DefineColor("Squeeze2", Color.DARK_ORANGE);
SqueezeClouds.DefineColor("Squeeze3", Color.RED);
#Heiken Trend Coloring
plot HeikenAshiPaintColors = NA;
HeikenAshiPaintColors.HideTitle();
HeikenAshiPaintColors.DefineColor("Heiken Up", Color.GREEN);
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("period" = haAgg1);
def h1 = high("period" = haAgg1);
def l1 = low("period" = haAgg1);
def c1 = close("period" = haAgg1);
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;
#HAgg2
def o2 = open("period" = haAgg2);
def h2 = high("period" = haAgg2);
def l2 = low("period" = haAgg2);
def c2 = close("period" = haAgg2);
def HA2open;
def HA2high;
def HA2low;
def HA2close;
HA2open = CompoundValue(1, (HA2open[1] + HA2close[1]) / 2, (o2[1] + c2[1]) / 2);
HA2high = Max(Max(h2, HA2open), HA2close[1]);
HA2low = Min(Min(l2, HA2open), HA2close[1]);
HA2close = (o2 + h2 + l2 + c2) / 4;
def HA1 = HA1close > HA1open;
def HA2 = HA2close > HA2open;
AddLabel(1, "HA1", if HA1 then HeikenAshiPaintColors.Color("Heiken UP") else HeikenAshiPaintColors.Color("Heiken Down"));
AddLabel(1, "HA2", if HA2 then HeikenAshiPaintColors.Color("Heiken UP") else HeikenAshiPaintColors.Color("Heiken Down"));
#Paint Heiken Candles
AssignPriceColor(if !paintHeikenAshiCandles then Color.CURRENT else if HA1 and HA2 then HeikenAshiPaintColors.Color("Heiken UP") else if !HA1 and !HA2 then HeikenAshiPaintColors.Color("Heiken Down") else HeikenAshiPaintColors.Color("Neutral"));
#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");
plot VWAPMNTH = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH");
VWAPDAY.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
VWAPWK.SetHiding(GetAggregationPeriod() >= AggregationPeriod.WEEK);
VWAPMNTH.SetHiding(GetAggregationPeriod() >= AggregationPeriod.MONTH);
#VWAP Distance Label
def VWAPDAYDistance = c - VWAPDAY;
def VWAPWKDistance = c - VWAPWK;
def VWAPMNTHDistance = c - VWAPMNTH;
AddLabel(if ShowVwapFromPriceLabels then 1 else 0, "DVWAP: " + AsDollars(VWAPDAYDistance) + " WVWAP: " + AsDollars(VWAPWKDistance) + " MVWAP: " + AsDollars(VWAPMNTHDistance), if AbsValue(VWAPDAYDistance) < AbsValue(VWAPWKDistance) and AbsValue(VWAPDAYDistance) < AbsValue(VWAPMNTHDistance) then Color.WHITE else if AbsValue(VWAPWKDistance) < AbsValue(VWAPDAYDistance) and AbsValue(VWAPWKDistance) < AbsValue(VWAPMNTHDistance) then Color.DARK_ORANGE else if VWAPWKDistance and VWAPMNTHDistance == VWAPDAYDistance then Color.WHITE else Color.RED);
#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";
plot VWAPMNTHLB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH")."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";
plot VWAPMNTHHB = reference VWAP("num dev dn" = -2.0, "num dev up" = 2.0, "time frame" = "MONTH")."UpperBand";
VWAPWKLB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
VWAPWKHB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.FOUR_HOURS);
VWAPMNTHLB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
VWAPMNTHHB.SetHiding(GetAggregationPeriod() >= AggregationPeriod.DAY);
# 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;
#Week x Month
def VWKxMNTHLBDiffH = if !EnableWeeklyXMonthlyClouds then NA else if VWAPMNTHLB - VWAPWKLB <= 0 then NA else VWAPMNTHLB;
def VWKxMNTHLBDiffL = if !EnableWeeklyXMonthlyClouds then NA else if VWAPMNTHLB - VWAPWKLB <= 0 then NA else VWAPWKLB;
def VWKxMNTHHBDiffH = if !EnableWeeklyXMonthlyClouds then NA else if VWAPWKHB - VWAPMNTHHB <= 0 then NA else VWAPWKHB;
def VWKxMNTHHBDiffL = if !EnableWeeklyXMonthlyClouds then NA else if VWAPWKHB - VWAPMNTHHB <= 0 then NA else VWAPMNTHHB;
#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 and HA2 then HeikenAshiPaintColors.Color("Heiken Up") else if paintHeikenAshiVWAP and !HA1 and !HA2 then HeikenAshiPaintColors.Color("Heiken Down") else if paintHeikenAshiVWAP and (HA1 and !HA2) or paintHeikenAshiVWAP and (!HA1 and HA2) then HeikenAshiPaintColors.Color("Neutral") 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);
VWAPMNTH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VWAPMNTH.SetDefaultColor(Color.RED);
VWAPMNTHHB.SetStyle(Curve.LONG_DASH);
VWAPMNTHHB.SetDefaultColor(Color.RED);
VWAPMNTHLB.SetStyle(Curve.LONG_DASH);
VWAPMNTHLB.SetDefaultColor(Color.RED);
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"));
AddCloud(VWKxMNTHLBDiffH, VWKxMNTHLBDiffL, CrossoverClouds.Color("Weekly x Monthly LowerBands"), CrossoverClouds.Color("Weekly x Monthly LowerBands"));
AddCloud(VWKxMNTHHBDiffH, VWKxMNTHHBDiffL, CrossoverClouds.Color("Weekly x Monthly UpperBands"), CrossoverClouds.Color("Weekly x Monthly 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";
VWAPUB1.Hide();
VWAPUB2.Hide();
VWAPUB3.Hide();
VWAPUB4.Hide();
#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";
VWAPLB1.Hide();
VWAPLB2.Hide();
VWAPLB3.Hide();
VWAPLB4.Hide();
#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);
Alert(if AlertVWAPMonthly then (h >= VWAPMNTH) and (l <= VWAPMNTH) else NA, "VWAP Monthly 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);
Alert(if AlertVWAPMNTHHB then (h >= VWAPMNTHHB) and (l <= VWAPMNTHHB) else NA, "VWAP Monthly 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);
Alert(if AlertVWAPMNTHLB then (l <= VWAPMNTHLB) and (h >= VWAPMNTHLB) else NA, "VWAP Monthly 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);
AddLabel(if EnableWeeklyXMonthlyClouds and ShowWXMLabel then 1 else 0, "WxM", if (VWAPWKHB > VWAPMNTHHB) then CrossoverClouds.Color("Weekly x Monthly UpperBands") else if (VWAPWKLB < VWAPMNTHLB) then CrossoverClouds.Color("Weekly x Monthly LowerBands") else Color.DARK_GRAY);
#Bollinger and Keltner SQUEEZE
#MTF Squeeze Clouds
def price1 = close("Period" = SqzAggregation1);
def price2 = close("Period" = SqzAgg2);
def price3 = close("Period" = SqzAgg3);
#BollingerBands Upper Middle Lower
def sDev1 = StDev(data = price1[-displace], length = length);
def sDev2 = StDev(data = price2[-displace], length = length);
def sDev3 = StDev(data = price3[-displace], length = length);
def MidLine1 = MovingAverage(averageType, data = price1[-displace], length = length);
def MidLine2 = MovingAverage(averageType, data = price2[-displace], length = length);
def MidLine3 = MovingAverage(averageType, data = price3[-displace], length = length);
def BLowerBand1 = MidLine1 + Num_Dev_Dn * sDev1;
def BLowerBand2 = MidLine2 + Num_Dev_Dn * sDev2;
def BLowerBand3 = MidLine3 + Num_Dev_Dn * sDev3;
def BUpperBand1 = MidLine1 + Num_Dev_up * sDev1;
def BUpperBand2 = MidLine2 + Num_Dev_up * sDev2;
def BUpperBand3 = MidLine3 + Num_Dev_up * sDev3;
#Keltner Channels Upper Middle Lower
def shift1 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAggregation1), close("Period" = SqzAggregation1), low("Period" = SqzAggregation1)), length);
def shift2 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAgg2), close("Period" = SqzAgg2), low("Period" = SqzAgg2)), length);
def shift3 = factor * MovingAverage(trueRangeAverageType, TrueRange(high("Period" = SqzAgg3), close("Period" = SqzAgg3), low("Period" = SqzAgg3)), length);
def average1 = MovingAverage(averageType, price1, length);
def average2 = MovingAverage(averageType, price2, length);
def average3 = MovingAverage(averageType, price3, length);
def Avg1 = average1[-displace];
def Avg2 = average2[-displace];
def Avg3 = average3[-displace];
def KUpperBand1 = average1[-displace] + shift1[-displace];
def kUpperBand2 = average2[-displace] + shift2[-displace];
def kUpperBand3 = average3[-displace] + shift3[-displace];
def KLowerBand1 = average1[-displace] - shift1[-displace];
def KLowerBand2 = average2[-displace] - shift2[-displace];
def KLowerBand3 = average3[-displace] - shift3[-displace];
#Squeeze Verification = Bollinger Upper and Lower Bands Cross inside Keltner Channel Upper and Lower Bands
def sqz1conf = KUpperBand1 - BUpperBand1 <= 0;
def sqz2conf = KUpperBand2 - BUpperBand2 <= 0;
def sqz3conf = KUpperBand3 - BUpperBand3 <= 0;
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;
def BollKeltUB2DiffH = if !EnableSqueeze2 then NA else if sqz2conf then NA else kUpperBand2;
def BollKeltUB2DiffL = if !EnableSqueeze2 then NA else if sqz2conf then NA else BUpperBand2;
def BollKeltLB2DiffH = if !EnableSqueeze2 then NA else if sqz2conf then NA else BLowerBand2;
def BollKeltLB2DiffL = if !EnableSqueeze2 then NA else if sqz2conf then NA else KLowerBand2;
def BollKeltUB3DiffH = if !EnableSqueeze3 then NA else if sqz3conf then NA else kUpperBand3;
def BollKeltUB3DiffL = if !EnableSqueeze3 then NA else if sqz3conf then NA else BUpperBand3;
def BollKeltLB3DiffH = if !EnableSqueeze3 then NA else if sqz3conf then NA else BLowerBand3;
def BollKeltLB3DiffL = if !EnableSqueeze3 then NA else if sqz3conf then NA else KLowerBand3;
plot Sqz1H = BollKeltUB1DiffL;
plot Sqz1L = BollKeltLB1DiffH;
plot Sqz2H = BollKeltUB2DiffL;
plot Sqz2L = BollKeltLB2DiffH;
plot Sqz3H = BollKeltUB3DiffL;
plot Sqz3L = BollKeltLB3DiffH;
#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);
AddLabel(if EnableSqueeze2 and ShowSqz2Label then 1 else 0,"Sqz2", if !sqz2conf then SqueezeClouds.Color("Squeeze2") else Color.DARK_GRAY);
AddLabel(if EnableSqueeze3 and ShowSqz3Label then 1 else 0,"Sqz3", if !sqz3conf then SqueezeClouds.Color("Squeeze3") else Color.DARK_GRAY);
#squeeze alerts
Alert(if Sqz1Alert then sqz1conf[1] and !sqz1conf else NA, "Squeeze1", sqzAlertType, sqzAlertSound);
Alert(if Sqz2Alert then sqz2conf[1] and !sqz2conf else NA, "Squeeze2", sqzAlertType, sqzAlertSound);
Alert(if Sqz3Alert then sqz3conf[1] and !sqz3conf else NA, "Squeeze3", sqzAlertType, sqzAlertSound);
AddVerticalLine(if Sqz1VerticalLine then sqz1conf[1] and !sqz1conf else NA, "Sqz1", SqueezeClouds.Color("Squeeze1"), stroke = Curve.POINTS);
AddVerticalLine(if Sqz2VerticalLine then sqz2conf[1] and !sqz2conf else NA, "Sqz2", SqueezeClouds.Color("Squeeze2"), stroke = Curve.POINTS);
AddVerticalLine(if Sqz3VerticalLine then sqz3conf[1] and !sqz3conf else NA, "Sqz3", SqueezeClouds.Color("Squeeze3"), stroke = Curve.POINTS);
Sqz1H.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz1H.AssignValueColor(SqueezeClouds.Color("Squeeze1"));
Sqz1H.SetLineWeight(1);
Sqz1L.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz1L.AssignValueColor(SqueezeClouds.Color("Squeeze1"));
Sqz1L.SetLineWeight(1);
Sqz2H.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz2H.AssignValueColor(SqueezeClouds.Color("Squeeze2"));
Sqz2H.SetLineWeight(1);
Sqz2L.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz2L.AssignValueColor(SqueezeClouds.Color("Squeeze2"));
Sqz2L.SetLineWeight(1);
Sqz3H.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz3H.AssignValueColor(SqueezeClouds.Color("Squeeze3"));
Sqz3H.SetLineWeight(1);
Sqz3L.SetPaintingStrategy(PaintingStrategy.LINE);
Sqz3L.AssignValueColor(SqueezeClouds.Color("Squeeze3"));
Sqz3L.SetLineWeight(1);
#Clouds for Squeezes
AddCloud(BollKeltUB1DiffH, BollKeltUB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
AddCloud(BollKeltLB1DiffH, BollKeltLB1DiffL, SqueezeClouds.Color("Squeeze1"), SqueezeClouds.Color("Squeeze1"));
AddCloud(BollKeltUB2DiffH, BollKeltUB2DiffL, SqueezeClouds.Color("Squeeze2"), SqueezeClouds.Color("Squeeze2"));
AddCloud(BollKeltLB2DiffH, BollKeltLB2DiffL, SqueezeClouds.Color("Squeeze2"), SqueezeClouds.Color("Squeeze2"));
AddCloud(BollKeltUB3DiffH, BollKeltUB3DiffL, SqueezeClouds.Color("Squeeze3"), SqueezeClouds.Color("Squeeze3"));
AddCloud(BollKeltLB3DiffH, BollKeltLB3DiffL, SqueezeClouds.Color("Squeeze3"), SqueezeClouds.Color("Squeeze3"));
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 zonesCan I ask how someone would interpret the vwap cross over clouds? thanks!
I recommend reading or watching videos on 'standard deviations in trading' or 'VWAP standard deviations'. Understand the probability and statistics of standard deviations. Thats all this is, those crossover clouds are simply 2 standard deviations on either the daily crossing weekly, or weekly crossing monthly. The cloud itself is just a visual aid for when price is on the fringe of these higher time frame VWAP 2 standard deviation zones.Is there any writeup or video about how to make use of this for going intraday/swing trading? Appreciate your help. I can see lots of good pointers but not able to digest when to long or short a stock using this.
http://tos.mx/KaTHRrLany chance this could work on mobile?
http://tos.mx/KaTHRrL
pieced together a mobile friendly version. can only do the deviation bands and current aggregation squeeze, multiple aggregations don't work on mobile. if you want weekly vwap on top of it just add regular VWAP and set it to weekly.
yes it is different. I edited the code to a bare min, will see if can get alerts working for you.Thank you! is this different code than the updated code you posted which included the alerts?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
The Ultimate Buy and Sell Indicator for ThinkOrSwim | Indicators | 5 | ||
P | Ultimate MACD For ThinkOrSwim | Indicators | 16 | |
Ultimate RSI [LuxAlgo] for ThinkOrSwim | Indicators | 12 | ||
Ultimate Bullish Cross using Price Momentum and Volume For SwingTrading | Indicators | 26 | ||
YungTrader's Ultimate Indicator | Indicators | 685 |
Start a new thread and receive assistance from our community.
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.
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.