Anchored VWAP Indicator for ThinkorSwim

F

flippa

New member
Has anyone had any luck testing this indicator and seeing how delayed it is? I don't have a real account so i can't simulate.
 
P

Princedev

New member
@thinky Your questions are good ones. Unless someone else can help answer that question, I am out of answers.
Please call the Advanced Trading Support line. Their phone # is listed in the Tutorial Section 800-672-2098.
They can log into your computer and see what you are seeing. They are both traders and coders at that number.
Please let us know what answer you get.
How long is this indicator delayed for
 
3AMBH

3AMBH

Member
VIP
Warehouse
I am new to TOS and have not yet figured out how to back test. Has anyone done any work in that regard? Here are two 1 minute charts after close on9/18/2019, AMZN AND CMG with the Original Trwend Reversal and the VWAP Anchored. I am exited to see it in RT at open tomorrow.
@chillc15 & @thinky the only way a one minute chart would stay the same after you left it to look at a five minute or five year chart would be for the price to stay the same as it was when you first left it, and then it still would not be right. Looking at the code, it is taking 20 bars and looking for a pivot. Wherever you have the time starting when you click on a one minute or whatever chart, it starts over, looking for a pivot hi/low in 20 bars. I hope this makes sense because it is pretty much the best I can explain it. Anyone else?

Also, curious to know, why are you looking at anything at such a short timeframe? I know it all depends on where a person learned, and maybe it's just me, but trading at the speed of a hummingbird's wings seems a little excessive, meaning price is so very random. (I will be the first to admit I know little about trading /CL)

There are two ways to adjust a chart like this: Change the input for number of bars. Turn off after hours so that only RTH is showing.
 
Last edited by a moderator:
3AMBH

3AMBH

Member
VIP
Warehouse
Me too. I wonder the same thing. I am a big fan of VWAP. I use it with a 15 exponential MA.
 
S

skynetgen

Active member
Warehouse
Has anyone had any luck testing this indicator and seeing how delayed it is? I don't have a real account so i can't simulate.
It has adjustable delay: input setting n -that is delay it uses for pivots. So can be delayed from 1 bar to whatever
 
blakecmathis

blakecmathis

Active member
Warehouse
I really like this indicator but it is failing to plot new high/low levels on my chart. The only way the new levels show up for me is if I manually go in and click "show study" twice to get it to manually refresh. Any ideas?
 
P

Princedev

New member
I put it on the 15 min 5 day but do u know how long it’s delayed for ?
 
blakecmathis

blakecmathis

Active member
Warehouse
I have no idea man I just wanted to backtest this one but in live trading I try to stay away from indicators.
 
P

Princedev

New member
I mostly trade with moving averages but that with long term
 
K

KarlWolff

New member
I'm not getting new signals on live, real-time data. Any ideas?
 
T

toopoor88

New member
You won't get any signals, this is super super super Delayed from what I am looking at. I don't use this to trade but I love playing around with things on my spare time but anyways today this thing didn't show the signal to get in until almost 20 bars were printed. Another one took 14 bars to go before it was printed. Not sure how to trade with this but if you looking for just the signal to tell you when to go in then it will be way too late.
 
P

Playstation

Member
I think this gives an indication of support/resistance at that exact price in that exact time. I'm on 5mins intraday, and boy did it help me for entry.
Don't bother to look at those arrows signal. Use the vwap lines high and low, very good to determine the support/resistance.
 
Last edited:
P

princesly

New member
Warehouse
Nice! Indicator that only works after the fact... I wish i could make money after the trade has happened lol
 
N

nycreaching

New member
anchored VWAP is powerful from recent swing hi/lows, but whats the point if they dont extend to recent price action? is there any way to have all anchored vwaps extend across the chart? thanks
 
blakecmathis

blakecmathis

Active member
Warehouse
I know this sounds crazy but hear me out. I would like to color code the intraday VWAP according to Fractal Energy. When FE falls below .5, I would like the VWAP to be Color A and then Color B for all other levels. Essentially the same way a Hull MA shifts colors. I've attempted to recreate what I am searching for in the screenshot below. When FE falls below .5, VWAP changes to blue. Tried to do it myself but couldn't find a solution (I have no idea what I'm doing). I really hope this is possible. Any help is greatly appreciated🤙

I have already merged the two here: https://tos.mx/6XSCJKd





Code:
#yakBro intraday anchoredVWAP excluding extended hours volume 2019

declare upper;

def anchorTime = 0930;
def anchorEnd = 1600;

input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def postAnchorTime = if SecondsFromTime(anchorTime) >= 0 then 1 else 0;
def endAchorTime = if SecondsTillTime(anchorEnd) >= 0 then 1 else 0;

#plot anchorVWAP for intraday
def  volumeSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeSum[1] + volume else 0, volume);
def  volumeVwapSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeVwapSum[1] + volume * vwap else 0, volume * vwap);

plot anchorVWAP = if ShowTodayOnly and !Today then Double.NaN else if anchorTime then volumeVwapSum / volumeSum else Double.NaN;
anchorVWAP.SetStyle(Curve.FIRM);
anchorVWAP.SetLineWeight(2);


anchorVWAP.DefineColor("Up", GetColor(1));
anchorVWAP.DefineColor("Down", GetColor(0));
anchorVWAP.AssignValueColor(if gamma < .5 then anchorVWAP.Color("Down") else anchorVWAP.Color("Up"));



#Inputs:
input nFE = 8;#hint nFE: length for Fractal Energy calculation.
input AlertOn = no;
input Glength  = 13;
input betaDev =  8;
input data = close;

def w = (2 * Double.Pi / Glength);
def beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
def alpha = (-beta + Sqrt(beta * beta + 2 * beta));
def Go = Power(alpha, 4) * open +
             4 * (1 – alpha) * Go[1] – 6 * Power( 1 - alpha, 2 ) * Go[2] +
             4 * Power( 1 - alpha, 3 ) * Go[3] - Power( 1 - alpha, 4 ) * Go[4];
def Gh = Power(alpha, 4) * high +
             4 * (1 – alpha) * Gh[1] – 6 * Power( 1 - alpha, 2 ) * Gh[2] +
             4 * Power( 1 - alpha, 3 ) * Gh[3] - Power( 1 - alpha, 4 ) * Gh[4];
def Gl = Power(alpha, 4) * low +
             4 * (1 – alpha) * Gl[1] – 6 * Power( 1 - alpha, 2 ) * Gl[2] +
             4 * Power( 1 - alpha, 3 ) * Gl[3] - Power( 1 - alpha, 4 ) * Gl[4];
def Gc = Power(alpha, 4) * data +
             4 * (1 – alpha) * Gc[1] – 6 * Power( 1 - alpha, 2 ) * Gc[2] +
             4 * Power( 1 - alpha, 3 ) * Gc[3] - Power( 1 - alpha, 4 ) * Gc[4];
# Variables:
def o;
def h;
def l;
def c;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
def L0;
def L1;
def L2;
def L3;



# Calculations
o = (Go + Gc[1]) / 2;
h = Max(Gh, Gc[1]);
l = Min(Gl, Gc[1]);
c = (o + h + l + Gc) / 4;
def gamma = Log(Sum((Max(Gh, Gc[1]) - Min(Gl, Gc[1])), nFE) /
        (Highest(Gh, nFE) - Lowest(Gl, nFE)))
            / Log(nFE);

L0 = (1 – gamma) * Gc + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1
then {
    CU1 = L0 - L1;
    CD1 = 0;
} else {
    CD1 = L1 - L0;
    CU1 = 0;
}
if L1 >= L2
then {
    CU2 = CU1 + L1 - L2;
    CD2 = CD1;
} else {
    CD2 = CD1 + L2 - L1;
    CU2 = CU1;
}
if L2 >= L3
then {
    CU = CU2 + L2 - L3;
    CD = CD2;
} else {
    CU = CU2;
    CD = CD2 + L3 - L2;
}
 
H

horserider

Well-known member
VIP
Warehouse
Without looking too closely, you are using gamma before it is defined. I just moved the vwap plot t o the bottom.

Code:
#yakBro intraday anchoredVWAP excluding extended hours volume 2019

declare upper;

def anchorTime = 0930;
def anchorEnd = 1600;

input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def postAnchorTime = if SecondsFromTime(anchorTime) >= 0 then 1 else 0;
def endAchorTime = if SecondsTillTime(anchorEnd) >= 0 then 1 else 0;

#plot anchorVWAP for intraday
def  volumeSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeSum[1] + volume else 0, volume);
def  volumeVwapSum = CompoundValue(1, if postAnchorTime and endAchorTime then volumeVwapSum[1] + volume * vwap else 0, volume * vwap);





#Inputs:
input nFE = 8;#hint nFE: length for Fractal Energy calculation.
input AlertOn = no;
input Glength  = 13;
input betaDev =  8;
input data = close;

def w = (2 * Double.Pi / Glength);
def beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
def alpha = (-beta + Sqrt(beta * beta + 2 * beta));
def Go = Power(alpha, 4) * open +
             4 * (1 – alpha) * Go[1] – 6 * Power( 1 - alpha, 2 ) * Go[2] +
             4 * Power( 1 - alpha, 3 ) * Go[3] - Power( 1 - alpha, 4 ) * Go[4];
def Gh = Power(alpha, 4) * high +
             4 * (1 – alpha) * Gh[1] – 6 * Power( 1 - alpha, 2 ) * Gh[2] +
             4 * Power( 1 - alpha, 3 ) * Gh[3] - Power( 1 - alpha, 4 ) * Gh[4];
def Gl = Power(alpha, 4) * low +
             4 * (1 – alpha) * Gl[1] – 6 * Power( 1 - alpha, 2 ) * Gl[2] +
             4 * Power( 1 - alpha, 3 ) * Gl[3] - Power( 1 - alpha, 4 ) * Gl[4];
def Gc = Power(alpha, 4) * data +
             4 * (1 – alpha) * Gc[1] – 6 * Power( 1 - alpha, 2 ) * Gc[2] +
             4 * Power( 1 - alpha, 3 ) * Gc[3] - Power( 1 - alpha, 4 ) * Gc[4];
# Variables:
def o;
def h;
def l;
def c;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
def L0;
def L1;
def L2;
def L3;



# Calculations
o = (Go + Gc[1]) / 2;
h = Max(Gh, Gc[1]);
l = Min(Gl, Gc[1]);
c = (o + h + l + Gc) / 4;
def gamma = Log(Sum((Max(Gh, Gc[1]) - Min(Gl, Gc[1])), nFE) /
        (Highest(Gh, nFE) - Lowest(Gl, nFE)))
            / Log(nFE);

L0 = (1 – gamma) * Gc + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1
then {
    CU1 = L0 - L1;
    CD1 = 0;
} else {
    CD1 = L1 - L0;
    CU1 = 0;
}
if L1 >= L2
then {
    CU2 = CU1 + L1 - L2;
    CD2 = CD1;
} else {
    CD2 = CD1 + L2 - L1;
    CU2 = CU1;
}
if L2 >= L3
then {
    CU = CU2 + L2 - L3;
    CD = CD2;
} else {
    CU = CU2;
    CD = CD2 + L3 - L2;
}

plot anchorVWAP = if ShowTodayOnly and !Today then Double.NaN else if anchorTime then volumeVwapSum / volumeSum else Double.NaN;
anchorVWAP.SetStyle(Curve.FIRM);
anchorVWAP.SetLineWeight(2);


anchorVWAP.DefineColor("Up", GetColor(1));
anchorVWAP.DefineColor("Down", GetColor(0));
anchorVWAP.AssignValueColor(if gamma < .5 then anchorVWAP.Color("Down") else anchorVWAP.Color("Up"));
 
blakecmathis

blakecmathis

Active member
Warehouse
@horserider Jumpin' Jesus Christ!!!!!! YOU DA MAN
 

Top