Easycator's VWAP Trading Indicator/Strategy

rad14733

rad14733

Active member
VIP
I've searched the forums and haven't found anything like the VWAP Trading Strategy that Easycators has for sale and wondered if we have any of the components already created before I roll up my sleeves and have a go at a similar one... It is almost identical to what I had been envisioning before I stumbled across a video today... I am primarily interested in a lower study similar to his as well as the scan and watchlist column... I'm sure I can write what I want but don't want to reinvent the wheel from scratch if I don't have to... Any input would be greatly appreciated...

If I'm not too tired this evening I'd like to start scripting... I like having multiple trading systems at my disposal and have been playing with VWAP in recent days, comparing it to other indicators and systems that I currently employ... I have already modified the Acrylic VWAP Study to have multiple deviations and it seems to work to my liking...

Here are links to his YouTube Video and his Z-Score Distance From VWAP system for anyone not familiar with what I am talking about...
 
BenTen

BenTen

Administrative
Staff
VIP
@rad14733 Did you check the first page of this thread? Looks really similar to what @horserider posted.
 
Last edited:
rad14733

rad14733

Active member
VIP
@rad14733 Did you check the first page of this thread? Looks really similar to what @horserider posted.
I did, indeed, but it is not what I am referring to... That's why I started a new topic... Please move back to a new topic to keep things clear... It is close, however, but I intend to include more...
 
BenTen

BenTen

Administrative
Staff
VIP
@rad14733 Done. How is it different? I didn't get a chance to dive in on the video, but I thought they look the same.

Also, here is another VWAP script called V-Score. Hopefully that helps.

Code:
#TOS Indicators - Home of the Volatility Box
#Full YouTube Tutorial: https://youtu.be/mAPEodczf-k
#
#**10/6/19 - Feature Added: Ability for Users to Set Custom Standard Deviation in Label Output

declare lower;
input anchorDate = 20180901;
input barsGoBack = 120;
input showStopLabel = yes;
input devStop = {default One, Two, Three, Zero, NegOne, NegTwo, NegThree, Custom};
input customDev = 0.15;
def chosenDev;
switch(devStop){
case One:
    chosenDev = 1;
case Two:
    chosenDev = 2;
case Three:
    chosenDev = 3;
case Zero:
    chosenDev = 0;
case NegOne:
    chosenDev = -1;
case NegTwo:
    chosenDev = -2;
case NegThree:
    chosenDev = -3;
case Custom:
    chosenDev = customDev;
}



def postAnchorDate = if GetYYYYMMDD() >= anchorDate then 1 else 0;


def yyyyMmDd = getYyyyMmDd();
def periodIndx = if getAggregationPeriod() < AggregationPeriod.HOUR then yyyyMMDD else postAnchorDate;
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));

plot VScore = if (((price - close)*(-1))/deviation) > 5 or (((price - close)*(-1))/deviation) < -5 then 0 else (((price - close)*(-1))/(deviation));
plot zero = 0;
plot one = 1;
plot two = 2;
plot three = 3;
plot negOne = -1;
plot negTwo = -2;
plot negThree = -3;
plot posInt = 0.3;
plot negInt = -0.3;

def stopPrice = (chosenDev)*(deviation) + (price);
AddLabel(showStopLabel, "Price at ["+chosenDev+"] SD: "+AsPrice(Round(stopPrice,2)),color.white);
def zeroAndOne = if VScore > zero and VScore <= one then 1 else 0;
def oneAndTwo = if VScore > one and VScore <= two then 1 else 0;
def twoAndThree = if VScore > two and VScore <= three then 1 else 0;

def negZeroAndOne = if VScore > negOne and VScore < zero then 1 else 0;
def negOneAndTwo = if VScore > negTwo and VScore <= negOne then 1 else 0;
def negTwoAndThree = if VScore > negThree and VScore <= negTwo then 1 else 0;

def cloud1;
def cloud2;
if Sum(zeroAndOne, barsGoBack) > Sum(OneAndTwo,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negtwoAndThree,barsGoBack){
    cloud1 = zero;
    cloud2 = one;
}
else if Sum(OneAndTwo, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negtwoAndThree,barsGoBack){
    cloud1 = one;
    cloud2 = two;
}
else if Sum(twoAndThree, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negtwoAndThree,barsGoBack){
    cloud1 = two;
    cloud2 = three;
}
else if Sum(negZeroAndOne, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(negtwoAndThree,barsGoBack){
    cloud1 = zero;
    cloud2 = negOne;
}
else if Sum(negoneAndTwo, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(negtwoAndThree,barsGoBack){
    cloud1 = negOne;
    cloud2 = negTwo;
}
else if Sum(negtwoAndThree, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(negOneAndTwo,barsGoBack){
    cloud1 = negTwo;
    cloud2 = negThree;
}
else {
    cloud1 = Double.nan;
    cloud2 = Double.nan;
}
AddCloud(cloud1, cloud2, color.light_red, color.light_green);


plot BullSignal = if (cloud1 == one or cloud2 == one or cloud1 == two or cloud2 == two or cloud1 == three or cloud2 ==three) and (VScore <= 0.3 and Vscore[1] >0) and CCI() > -100 then -2 else Double.nan;

plot BearSignal = if (cloud1 == negOne or cloud2 == negOne or cloud1 == negTwo or cloud2 == negTwo or cloud1 == negThree or cloud2 ==negThree) and (VScore >= 0.3 and Vscore[1] < 0) and CCI() < 100 then 2 else Double.nan;

BullSignal.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
BearSignal.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
BullSignal.SetLineWeight(3);
BearSignal.SetLineWeight(3);

input soundAlertsOn = no;
Alert((cloud1 == one or cloud2 == one or cloud1 == two or cloud2 == two or cloud1 == three or cloud2 == three) and (VScore <= 0 and VScore[1] > 0) and (SoundAlertsOn), "Bullish VScore Entry", Alert.BAR);
Alert((cloud1 == negOne or cloud2 == negone or cloud1 == negtwo or cloud2 == negtwo or cloud1 == negthree or cloud2 == negthree) and (VScore >= 0 and VScore[1] < 0)and (SoundAlertsOn), "Bearish VScore Entry", Alert.BAR);
 
rad14733

rad14733

Active member
VIP
Thanks, BenTen... Yes, I have also seen that script and video... Both the code by Mobius and TOS Indicators gives ideas to work from but I need to add some additional bells and whistles... I'll plug away at it but I'm in no rush...
 
T

TraderKevin

New member
Thanks, BenTen... Yes, I have also seen that script and video... Both the code by Mobius and TOS Indicators gives ideas to work from but I need to add some additional bells and whistles... I'll plug away at it but I'm in no rush...
Very anxious to see what you come up with. Tempted to do it myself as well as I like this idea for trading, but I'll wait for your undoubtedly superior product to what I'd make.

In case you haven't thought of it, you might want to start with the bollinger band code and just change the middle line to be VWAP, then add additional outside lines for different deviations away from vwap. At least, that's how I'd do it, but I'm pretty new to coding.
 
rad14733

rad14733

Active member
VIP
@TraderKevin Thanks for the comments... I'm actually taking ideas from several different scripts and adding in some useful features... One item that I am currently testing is clipping extremes to maintain scale of the lower indicator... I'm not as concerned about how far the extremes go, just that they have reached my maximum intended levels... I am most interested in 1 - 2 deviations and currently have clipping limits set at 3 deviations but will be making the deviation levels user-adjustable...

I am including an image of a very rough first draft that needs a lot more work... As you can see, when the Zscore line reaches +3 it is clipped and flat-lines along the top... For my needs I don't need to see if it spikes to 4 or 5 deviations, just that it has reached my preferred maximum... I may include the ability to turn clipping off however...

 
T

TraderKevin

New member
@TraderKevin Thanks for the comments... I'm actually taking ideas from several different scripts and adding in some useful features... One item that I am currently testing is clipping extremes to maintain scale of the lower indicator... I'm not as concerned about how far the extremes go, just that they have reached my maximum intended levels... I am most interested in 1 - 2 deviations and currently have clipping limits set at 3 deviations but will be making the deviation levels user-adjustable...

I am including an image of a very rough first draft that needs a lot more work... As you can see, when the Zscore line reaches +3 it is clipped and flat-lines along the top... For my needs I don't need to see if it spikes to 4 or 5 deviations, just that it has reached my preferred maximum... I may include the ability to turn clipping off however...

Looks like a good start! The clipping is a good feature. Personally, I will probably only use the indicator on the chart itself, rather than a lower study... that way I can see more directly when price reaches certain levels and never lose focus on what matters most: price action.
 
T

TraderKevin

New member
For anyone interested, I went ahead and edited the built in VWAP study to include plots of 3 different standard deviations from VWAP, as seen in the OP's video. The 3 standard deviation band seems incredibly strong, as one would expect, though it's rarely touched.

Code:
input numDevDn = -1.0;
input numDevUp = 1.0;
input numDevDn2 = -2.0;
input numDevUp2 = 2.0;
input numDevDn3 = -3.0;
input numDevUp3 = 3.0;
input timeFrame = {default DAY, WEEK, MONTH};

def cap = getAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
    periodIndx = yyyyMmDd;
case WEEK:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));

plot VWAP = price;
plot UpperBand = price + numDevUp * deviation;
plot LowerBand = price + numDevDn * deviation;
plot UpperBand2 = price + numDevUp2 * deviation;
plot LowerBand2 = price + numDevDn2 * deviation;
plot UpperBand3 = price + numDevUp3 * deviation;
plot LowerBand3 = price + numDevDn3 * deviation;

VWAP.setDefaultColor(Color.CYAN);
UpperBand.setDefaultColor(Color.LIGHT_GRAY);
LowerBand.setDefaultColor(Color.LIGHT_GRAY);
UpperBand2.setDefaultColor(Color.RED);
LowerBand2.setDefaultColor(Color.LIGHT_GREEN);
UpperBand3.setDefaultColor(Color.DARK_RED);
LowerBand3.setDefaultColor(Color.DARK_GREEN);
 
rad14733

rad14733

Active member
VIP
@TraderKevin Yep, I have them in the code I'm working on along with the upper and lower clouds... Have also been working on the lower indicator... I traded with them today and things are shaping up nicely... I'll be polishing things up tonight and trading some more tomorrow before I post any of my Work In Progress code...
 
rad14733

rad14733

Active member
VIP
Just a quick update to let everyone interested know that I'm still working on things but have fallen a bit behind due to a minor bout of depression... Nothing earth shattering but these bouts do interfere with everyday life and sometimes cause me to make bad decisions... I'm working my way through it but haven't been doing much trading as, like I stated, I sometimes make bad decisions and I'd like to keep what little bit of trading capital I have left until I'm back on top of things... I did manage to dip my toes in the water and made a whopping $12 today using this WIP code, however...
 
MerryDay

MerryDay

Active member
VIP
The life and times of 2020. Hang in there. I really appreciate all your contributions. I am a better trader because of them.
 
Welkin

Welkin

Active member
VIP
Just saw this thread. I don't know about the easycator's vwap strat or zscore indicator but I've made something similar that I've based on the vwap deviations indicator that I use. I guess you could consider this a companion to that indicator. I look for daily VWAP 2nd devs to be outside of weekly 2nd deviations and weekly 2nd deviations to be outside of the monthly 2nd deviations. I've found when price is outside of these boundaries there can be a high probability to make a large push back towards the weekly/monthly vwaps. I made this a while ago but come back to it every now and then to make some tweaks. Maybe this can give you some ideas.
A few notes:
this is best used with extended trading hours turned on
the candles are hull MAs based on the high/low/close position relative to the daily VWAP deviations
the orange and red lines are hull MA's based on the close position relative to the weekly/monthy VWAP deviations
0 = VWAP for daily(candles)/weekly(orange line)/monthly(red line)
+/- 25 is = 1st deviation
+/- 50 is = 2nd deviation
+/- 75 is = 3rd deviation
+/- 100 is = 4th deviation
when price is below or above 2nd deviations (+/- 50) a magenta dot (daily) orange dot(weekly) or red dot (monthly) will plot at the top or bottom.
when price touches the daily/weekly/monthly vwap a magenta/orange/red dot will plot on the 0 line
if daily vwap is above or below 2nd deviations dark gray vertical lines will plot


Code:
#[email protected]
#version 7.29.2020

declare lower;
def NA = Double.NaN;
input thresh =50;
input threshWk = 50;
input threshMnth = 50;

def o = open;
def h = high;
def l = low;
def c = close;

DefineGlobalColor("Bullish", CreateColor(0,100,200));
DefineGlobalColor("Bearish", Color.YELLOW);
#VWAP Daily, Weekly, and Monthly
def VWAPDAY =  reference VWAP("time frame" = "DAY");
def VWAPWK = reference VWAP("time frame" = "WEEK");
def VWAPMNTH = reference VWAP("time frame" = "MONTH");
#VWAP UpperBand and LowerBand values
def VWAPDAYLB = reference VWAP("num dev dn" = -4.0, "time frame" = "DAY")."LowerBand";
def VWAPWKLB = reference VWAP("num dev dn" = -4.0, "time frame" = "WEEK")."LowerBand";
def VWAPMNTHLB = reference VWAP("num dev dn" = -4.0, "time frame" = "MONTH")."LowerBand";
def VWAPDAYHB = reference VWAP("num dev up" = 4.0, "time frame" = "DAY")."UpperBand";
def VWAPWKHB = reference VWAP("num dev up" = 4.0, "time frame" = "WEEK")."UpperBand";
def VWAPMNTHHB = reference VWAP("num dev up" = 4.0, "time frame" = "MONTH")."UpperBand";


#VWAP Deviation Bands
def VWAPUB = reference VWAP("num dev up" = 4.0, "time frame" = "DAY")."UpperBand";
def VWAPLB = reference VWAP("num dev dn" = -4.0, "time frame" = "DAY")."LowerBand";

##############################
input price = close;
input avgType = AverageType.HULL;
input avgLength = 5;
def VWDayBP = c - VWAPLB;
def VWDaySP = VWAPUB - c;
def VWDayBPh= h - VWAPLB;
def VWDaySPh = VWAPUB - h;
def VWDayBPl = l - VWAPLB;
def VWDaySPl = VWAPUB - l;
def VWDayRange = VWAPUB - VWAPLB;

#VWDayRange.Hide();
def VWDayBandWidthU = ((VWAPUB - VWAPLB)/VWAPDAY)*1000;
def VWDayBandWidthD = ((VWAPLB - VWAPUB)/VWAPDAY)*1000;

def VWWkBP = c - VWAPWKLB;
def VWWkSP = VWAPWKHB - c;
def VWWkBPh = h - VWAPWKLB;
def VWWkSPh = VWAPWKHB - h;
def VWWkBPl = l - VWAPWKLB;
def VWWkSPl = VWAPWKHB - l;
def VWWkRange = VWAPWKHB - VWAPWKLB;

def VWMnthBP = c - VWAPMNTHLB;
def VWMnthSP = VWAPMNTHHB - c;
def VWMnthBPh = h - VWAPMNTHLB;
def VWMnthSPh = VWAPMNTHHB - h;
def VWMnthBPl = l - VWAPMNTHLB;
def VWMnthSPl = VWAPMNTHHB - l;
def VWMnthRange = VWAPMNTHHB - VWAPMNTHLB;

def VWAPDayZh1 = MovingAverage(avgType,(((VWDayBPh - VWDaySPh)/(VWDayRange))*100),avgLength);
def VWAPDayZl1 = MovingAverage(avgType,(((VWDayBPl - VWDaySPl)/(VWDayRange))*100),avgLength);
def VWAPDayZc1 = MovingAverage(avgType,(((VWDayBP - VWDaySP)/(VWDayRange))*100),avgLength);
def VWAPDayZh = if AbsValue(VWAPDayZh1) > 120 then NA else VWAPDayZh1;
def VWAPDayZl = if AbsValue(VWAPDayZl1) > 120 then NA else VWAPDayZl1;
plot VWAPDayZc = if AbsValue(VWAPDayZc1) > 120 then NA else VWAPDayZc1;
VWAPDayZc.Hide();
def bb = VWAPDayZc > VWAPDayZc[1];
def VWAPWkZ1 = MovingAverage(avgType,(((VWWkBP - VWWkSP)/(VWWkRange))*100),avgLength);
plot VWAPWkZ = if AbsValue(VWAPWkZ1) > 120 then NA else VWAPWkZ1;
def VWAPWkZh1 = MovingAverage(avgType,(((VWWkBPh - VWWkSPh)/(VWWkRange))*100),avgLength);
def VWAPWkZl1 = MovingAverage(avgType,(((VWWkBPl - VWWkSPl)/(VWWkRange))*100),avgLength);
def VWAPWkZh = if AbsValue(VWAPWkZh1) > 120 then NA else VWAPWkZh1;
def VWAPWkZl = if AbsValue(VWAPWkZl1) > 120 then NA else VWAPWkZl1;

def VWAPMnthZ1 = MovingAverage(avgType,(((VWMnthBP - VWMnthSP)/(VWMnthRange))*100),avgLength);
plot VWAPMnthZ = if AbsValue(VWAPMnthZ1) > 120 then NA else VWAPMnthZ1;
def VWAPMnthZh1 = MovingAverage(avgType,(((VWMnthBPh - VWMnthSPh)/(VWMnthRange))*100),avgLength);
def VWAPMnthZl1 = MovingAverage(avgType,(((VWMnthBPl - VWMnthSPl)/(VWMnthRange))*100),avgLength);
def VWAPMnthZh =  if AbsValue(VWAPMnthZh1) > 120 then NA else VWAPMnthZh1;
def VWAPMnthZl =  if AbsValue(VWAPMnthZl1) > 120 then NA else VWAPMnthZl1;
VWAPWkZ.SetHiding(VWAPWkZ == VWAPDayZc);

AddChart(VWAPDayZh,VWAPDayZl,if bb then VWAPDayZl else NA,VWAPDayZc,ChartType.CANDLE, GlobalColor("Bullish"));
AddChart(VWAPDayZh,VWAPDayZl,if !bb then VWAPDayZh else NA,VWAPDayZc,ChartType.CANDLE, GlobalColor("Bearish"));

AddVerticalLine((AbsValue(VWAPDayZh) >= thresh) or (AbsValue(VWAPDayZl) >= thresh) or (AbsValue(VWAPDayZc) >= thresh),"", Color.DARK_GRAY, Curve.POINTS);

plot VWAPDaytopsig = if VWAPDayZc >= threshWk then 100 else NA;
plot VWAPDaybotsig = if VWAPDayZc <= -threshWk then -100 else NA;
plot VWAPWktopsig = if VWAPWkZ >= threshWk then 100 else NA;
plot VWAPWkbotsig = if VWAPWkZ <= -threshWk then -100 else NA;
plot VWAPMnthtopsig = if VWAPMnthZ >= threshMnth then 100 else NA;
plot VWAPMnthbotsig = if VWAPMnthZ <= -threshMnth then -100 else NA;


plot Dev1Pos = 25;
plot Dev1Neg = -25;
plot Dev2Pos = 50;
plot Dev2Neg = -50;
plot Dev3Pos = 75;
plot Dev3Neg = -75;
plot Dev4Pos = 100;
plot Dev4Neg = -100;
plot zero = 0;
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.BLUE);


def VWAPtestD = VWAPDayZl <= 0 and VWAPDayZh >= 0;
def VWAPtestW = VWAPWkZl <= 0 and VWAPWkZh >= 0;
def VWAPtestM = VWAPMnthZl <= 0 and VWAPMnthZh >= 0;

plot VWAPztestD = if VWAPtestD then 0 else NA;
plot VWAPztestW = if VWAPtestW then 0 else NA;
plot VWAPztestM = if VWAPtestM then 0 else NA;

def VWAPDev1PosTest = VWAPDayZl <= Dev1Pos and VWAPDayZh >= Dev1Pos;
def VWAPDev1NegTest = VWAPDayZl <= Dev1Neg and VWAPDayZh >= Dev1Neg;
def VWAPDev2PosTest = VWAPDayZl <= Dev2Pos and VWAPDayZh >= Dev2Pos;
def VWAPDev2NegTest = VWAPDayZl <= Dev2Neg and VWAPDayZh >= Dev2Neg;
def VWAPDev3PosTest = VWAPDayZl <= Dev3Pos and VWAPDayZh >= Dev3Pos;
def VWAPDev3NegTest = VWAPDayZl <= Dev3Neg and VWAPDayZh >= Dev3Neg;
def VWAPDev4PosTest = VWAPDayZl <= Dev4Pos and VWAPDayZh >= Dev4Pos;
def VWAPDev4NegTest = VWAPDayZl <= Dev4Neg and VWAPDayZh >= Dev4Neg;


zero.SetDefaultColor(Color.BLUE);
VWAPztestD.SetDefaultColor(Color.MAGENTA);
VWAPztestW.SetDefaultColor(Color.DARK_ORANGE);
VWAPztestM.SetDefaultColor(Color.RED);
VWAPztestD.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestW.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestM.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestD.SetLineWeight(1);
VWAPztestW.SetLineWeight(3);
VWAPztestM.SetLineWeight(5);

Dev1Pos.SetDefaultColor(Color.DARK_GRAY);
Dev1Neg.SetDefaultColor(Color.DARK_GRAY);
Dev2Pos.SetDefaultColor(Color.DARK_GRAY);
Dev2Neg.SetDefaultColor(Color.DARK_GRAY);
Dev3Pos.SetDefaultColor(Color.DARK_GRAY);
Dev3Neg.SetDefaultColor(Color.DARK_GRAY);
Dev4Pos.SetDefaultColor(Color.RED);
Dev4Neg.SetDefaultColor(Color.GREEN);

VWAPDayZc.SetDefaultColor(Color.YELLOW);
VWAPWkZ.SetDefaultColor(Color.DARK_ORANGE);
VWAPWkZ.SetLineWeight(2);
VWAPMnthZ.SetDefaultColor(Color.RED);
VWAPMnthZ.SetLineWeight(2);
#VWDayBandWidthU.SetDefaultColor(Color.GRAY);
#VWDayBandWidthD.SetDefaultColor(Color.GRAY);

VWAPDaytopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPDaybotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPDaytopsig.SetDefaultColor(Color.MAGENTA);
VWAPDaybotsig.SetDefaultColor(Color.MAGENTA);
VWAPWktopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPWkbotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPWktopsig.SetDefaultColor(Color.DARK_ORANGE);
VWAPWkbotsig.SetDefaultColor(Color.DARK_ORANGE);
VWAPWktopsig.SetLineWeight(3);
VWAPWkbotsig.SetLineWeight(3);
VWAPMnthtopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPMnthbotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPMnthtopsig.SetDefaultColor(Color.RED);
VWAPMnthbotsig.SetDefaultColor(Color.RED);
VWAPMnthtopsig.SetLineWeight(5);
VWAPMnthbotsig.SetLineWeight(5);
 
T

TraderKevin

New member
Just saw this thread. I don't know about the easycator's vwap strat or zscore indicator but I've made something similar that I've based on the vwap deviations indicator that I use. I guess you could consider this a companion to that indicator. I look for daily VWAP 2nd devs to be outside of weekly 2nd deviations and weekly 2nd deviations to be outside of the monthly 2nd deviations. I've found when price is outside of these boundaries there can be a high probability to make a large push back towards the weekly/monthly vwaps. I made this a while ago but come back to it every now and then to make some tweaks. Maybe this can give you some ideas.
A few notes:
this is best used with extended trading hours turned on
the candles are hull MAs based on the high/low/close position relative to the daily VWAP deviations
the orange and red lines are hull MA's based on the close position relative to the weekly/monthy VWAP deviations
0 = VWAP for daily(candles)/weekly(orange line)/monthly(red line)
+/- 25 is = 1st deviation
+/- 50 is = 2nd deviation
+/- 75 is = 3rd deviation
+/- 100 is = 4th deviation
when price is below or above 2nd deviations (+/- 50) a magenta dot (daily) orange dot(weekly) or red dot (monthly) will plot at the top or bottom.
when price touches the daily/weekly/monthly vwap a magenta/orange/red dot will plot on the 0 line
if daily vwap is above or below 2nd deviations dark gray vertical lines will plot


Code:
#[email protected]
#version 7.29.2020

declare lower;
def NA = Double.NaN;
input thresh =50;
input threshWk = 50;
input threshMnth = 50;

def o = open;
def h = high;
def l = low;
def c = close;

DefineGlobalColor("Bullish", CreateColor(0,100,200));
DefineGlobalColor("Bearish", Color.YELLOW);
#VWAP Daily, Weekly, and Monthly
def VWAPDAY =  reference VWAP("time frame" = "DAY");
def VWAPWK = reference VWAP("time frame" = "WEEK");
def VWAPMNTH = reference VWAP("time frame" = "MONTH");
#VWAP UpperBand and LowerBand values
def VWAPDAYLB = reference VWAP("num dev dn" = -4.0, "time frame" = "DAY")."LowerBand";
def VWAPWKLB = reference VWAP("num dev dn" = -4.0, "time frame" = "WEEK")."LowerBand";
def VWAPMNTHLB = reference VWAP("num dev dn" = -4.0, "time frame" = "MONTH")."LowerBand";
def VWAPDAYHB = reference VWAP("num dev up" = 4.0, "time frame" = "DAY")."UpperBand";
def VWAPWKHB = reference VWAP("num dev up" = 4.0, "time frame" = "WEEK")."UpperBand";
def VWAPMNTHHB = reference VWAP("num dev up" = 4.0, "time frame" = "MONTH")."UpperBand";


#VWAP Deviation Bands
def VWAPUB = reference VWAP("num dev up" = 4.0, "time frame" = "DAY")."UpperBand";
def VWAPLB = reference VWAP("num dev dn" = -4.0, "time frame" = "DAY")."LowerBand";

##############################
input price = close;
input avgType = AverageType.HULL;
input avgLength = 5;
def VWDayBP = c - VWAPLB;
def VWDaySP = VWAPUB - c;
def VWDayBPh= h - VWAPLB;
def VWDaySPh = VWAPUB - h;
def VWDayBPl = l - VWAPLB;
def VWDaySPl = VWAPUB - l;
def VWDayRange = VWAPUB - VWAPLB;

#VWDayRange.Hide();
def VWDayBandWidthU = ((VWAPUB - VWAPLB)/VWAPDAY)*1000;
def VWDayBandWidthD = ((VWAPLB - VWAPUB)/VWAPDAY)*1000;

def VWWkBP = c - VWAPWKLB;
def VWWkSP = VWAPWKHB - c;
def VWWkBPh = h - VWAPWKLB;
def VWWkSPh = VWAPWKHB - h;
def VWWkBPl = l - VWAPWKLB;
def VWWkSPl = VWAPWKHB - l;
def VWWkRange = VWAPWKHB - VWAPWKLB;

def VWMnthBP = c - VWAPMNTHLB;
def VWMnthSP = VWAPMNTHHB - c;
def VWMnthBPh = h - VWAPMNTHLB;
def VWMnthSPh = VWAPMNTHHB - h;
def VWMnthBPl = l - VWAPMNTHLB;
def VWMnthSPl = VWAPMNTHHB - l;
def VWMnthRange = VWAPMNTHHB - VWAPMNTHLB;

def VWAPDayZh1 = MovingAverage(avgType,(((VWDayBPh - VWDaySPh)/(VWDayRange))*100),avgLength);
def VWAPDayZl1 = MovingAverage(avgType,(((VWDayBPl - VWDaySPl)/(VWDayRange))*100),avgLength);
def VWAPDayZc1 = MovingAverage(avgType,(((VWDayBP - VWDaySP)/(VWDayRange))*100),avgLength);
def VWAPDayZh = if AbsValue(VWAPDayZh1) > 120 then NA else VWAPDayZh1;
def VWAPDayZl = if AbsValue(VWAPDayZl1) > 120 then NA else VWAPDayZl1;
plot VWAPDayZc = if AbsValue(VWAPDayZc1) > 120 then NA else VWAPDayZc1;
VWAPDayZc.Hide();
def bb = VWAPDayZc > VWAPDayZc[1];
def VWAPWkZ1 = MovingAverage(avgType,(((VWWkBP - VWWkSP)/(VWWkRange))*100),avgLength);
plot VWAPWkZ = if AbsValue(VWAPWkZ1) > 120 then NA else VWAPWkZ1;
def VWAPWkZh1 = MovingAverage(avgType,(((VWWkBPh - VWWkSPh)/(VWWkRange))*100),avgLength);
def VWAPWkZl1 = MovingAverage(avgType,(((VWWkBPl - VWWkSPl)/(VWWkRange))*100),avgLength);
def VWAPWkZh = if AbsValue(VWAPWkZh1) > 120 then NA else VWAPWkZh1;
def VWAPWkZl = if AbsValue(VWAPWkZl1) > 120 then NA else VWAPWkZl1;

def VWAPMnthZ1 = MovingAverage(avgType,(((VWMnthBP - VWMnthSP)/(VWMnthRange))*100),avgLength);
plot VWAPMnthZ = if AbsValue(VWAPMnthZ1) > 120 then NA else VWAPMnthZ1;
def VWAPMnthZh1 = MovingAverage(avgType,(((VWMnthBPh - VWMnthSPh)/(VWMnthRange))*100),avgLength);
def VWAPMnthZl1 = MovingAverage(avgType,(((VWMnthBPl - VWMnthSPl)/(VWMnthRange))*100),avgLength);
def VWAPMnthZh =  if AbsValue(VWAPMnthZh1) > 120 then NA else VWAPMnthZh1;
def VWAPMnthZl =  if AbsValue(VWAPMnthZl1) > 120 then NA else VWAPMnthZl1;
VWAPWkZ.SetHiding(VWAPWkZ == VWAPDayZc);

AddChart(VWAPDayZh,VWAPDayZl,if bb then VWAPDayZl else NA,VWAPDayZc,ChartType.CANDLE, GlobalColor("Bullish"));
AddChart(VWAPDayZh,VWAPDayZl,if !bb then VWAPDayZh else NA,VWAPDayZc,ChartType.CANDLE, GlobalColor("Bearish"));

AddVerticalLine((AbsValue(VWAPDayZh) >= thresh) or (AbsValue(VWAPDayZl) >= thresh) or (AbsValue(VWAPDayZc) >= thresh),"", Color.DARK_GRAY, Curve.POINTS);

plot VWAPDaytopsig = if VWAPDayZc >= threshWk then 100 else NA;
plot VWAPDaybotsig = if VWAPDayZc <= -threshWk then -100 else NA;
plot VWAPWktopsig = if VWAPWkZ >= threshWk then 100 else NA;
plot VWAPWkbotsig = if VWAPWkZ <= -threshWk then -100 else NA;
plot VWAPMnthtopsig = if VWAPMnthZ >= threshMnth then 100 else NA;
plot VWAPMnthbotsig = if VWAPMnthZ <= -threshMnth then -100 else NA;


plot Dev1Pos = 25;
plot Dev1Neg = -25;
plot Dev2Pos = 50;
plot Dev2Neg = -50;
plot Dev3Pos = 75;
plot Dev3Neg = -75;
plot Dev4Pos = 100;
plot Dev4Neg = -100;
plot zero = 0;
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.BLUE);


def VWAPtestD = VWAPDayZl <= 0 and VWAPDayZh >= 0;
def VWAPtestW = VWAPWkZl <= 0 and VWAPWkZh >= 0;
def VWAPtestM = VWAPMnthZl <= 0 and VWAPMnthZh >= 0;

plot VWAPztestD = if VWAPtestD then 0 else NA;
plot VWAPztestW = if VWAPtestW then 0 else NA;
plot VWAPztestM = if VWAPtestM then 0 else NA;

def VWAPDev1PosTest = VWAPDayZl <= Dev1Pos and VWAPDayZh >= Dev1Pos;
def VWAPDev1NegTest = VWAPDayZl <= Dev1Neg and VWAPDayZh >= Dev1Neg;
def VWAPDev2PosTest = VWAPDayZl <= Dev2Pos and VWAPDayZh >= Dev2Pos;
def VWAPDev2NegTest = VWAPDayZl <= Dev2Neg and VWAPDayZh >= Dev2Neg;
def VWAPDev3PosTest = VWAPDayZl <= Dev3Pos and VWAPDayZh >= Dev3Pos;
def VWAPDev3NegTest = VWAPDayZl <= Dev3Neg and VWAPDayZh >= Dev3Neg;
def VWAPDev4PosTest = VWAPDayZl <= Dev4Pos and VWAPDayZh >= Dev4Pos;
def VWAPDev4NegTest = VWAPDayZl <= Dev4Neg and VWAPDayZh >= Dev4Neg;


zero.SetDefaultColor(Color.BLUE);
VWAPztestD.SetDefaultColor(Color.MAGENTA);
VWAPztestW.SetDefaultColor(Color.DARK_ORANGE);
VWAPztestM.SetDefaultColor(Color.RED);
VWAPztestD.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestW.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestM.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPztestD.SetLineWeight(1);
VWAPztestW.SetLineWeight(3);
VWAPztestM.SetLineWeight(5);

Dev1Pos.SetDefaultColor(Color.DARK_GRAY);
Dev1Neg.SetDefaultColor(Color.DARK_GRAY);
Dev2Pos.SetDefaultColor(Color.DARK_GRAY);
Dev2Neg.SetDefaultColor(Color.DARK_GRAY);
Dev3Pos.SetDefaultColor(Color.DARK_GRAY);
Dev3Neg.SetDefaultColor(Color.DARK_GRAY);
Dev4Pos.SetDefaultColor(Color.RED);
Dev4Neg.SetDefaultColor(Color.GREEN);

VWAPDayZc.SetDefaultColor(Color.YELLOW);
VWAPWkZ.SetDefaultColor(Color.DARK_ORANGE);
VWAPWkZ.SetLineWeight(2);
VWAPMnthZ.SetDefaultColor(Color.RED);
VWAPMnthZ.SetLineWeight(2);
#VWDayBandWidthU.SetDefaultColor(Color.GRAY);
#VWDayBandWidthD.SetDefaultColor(Color.GRAY);

VWAPDaytopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPDaybotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPDaytopsig.SetDefaultColor(Color.MAGENTA);
VWAPDaybotsig.SetDefaultColor(Color.MAGENTA);
VWAPWktopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPWkbotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPWktopsig.SetDefaultColor(Color.DARK_ORANGE);
VWAPWkbotsig.SetDefaultColor(Color.DARK_ORANGE);
VWAPWktopsig.SetLineWeight(3);
VWAPWkbotsig.SetLineWeight(3);
VWAPMnthtopsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPMnthbotsig.SetPaintingStrategy(PaintingStrategy.POINTS);
VWAPMnthtopsig.SetDefaultColor(Color.RED);
VWAPMnthbotsig.SetDefaultColor(Color.RED);
VWAPMnthtopsig.SetLineWeight(5);
VWAPMnthbotsig.SetLineWeight(5);
Very interesting and thorough indicator. Thanks for sharing! Have you tried backtesting it to see how significant the edge is?
 
rad14733

rad14733

Active member
VIP
Just saw this thread. I don't know about the easycator's vwap strat or zscore indicator but I've made something similar that I've based on the vwap deviations indicator that I use. I guess you could consider this a companion to that indicator. I look for daily VWAP 2nd devs to be outside of weekly 2nd deviations and weekly 2nd deviations to be outside of the monthly 2nd deviations. I've found when price is outside of these boundaries there can be a high probability to make a large push back towards the weekly/monthly vwaps. I made this a while ago but come back to it every now and then to make some tweaks. Maybe this can give you some ideas.
A few notes:
this is best used with extended trading hours turned on
the candles are hull MAs based on the high/low/close position relative to the daily VWAP deviations
the orange and red lines are hull MA's based on the close position relative to the weekly/monthy VWAP deviations
0 = VWAP for daily(candles)/weekly(orange line)/monthly(red line)
+/- 25 is = 1st deviation
+/- 50 is = 2nd deviation
+/- 75 is = 3rd deviation
+/- 100 is = 4th deviation
when price is below or above 2nd deviations (+/- 50) a magenta dot (daily) orange dot(weekly) or red dot (monthly) will plot at the top or bottom.
when price touches the daily/weekly/monthly vwap a magenta/orange/red dot will plot on the 0 line
if daily vwap is above or below 2nd deviations dark gray vertical lines will plot
Nice work, Welkin... (y) I'm going to watch your lower indicator on one of my charts to see how well it performs... ;)
 

Similar threads

Top