Deviation Scaled VWAP with Fractal Energy for ThinkorSwim

horserider

horserider

Well-known member
VIP
For VWAP and Fractual Energy fans. Deviation scaled MA of the VWAP. You can adjust the length to fit your trading. The fractual energy is added as a coloring of the plot line. The FE does not give an indication of direction. It shows energy of the trend. Magenta is an exhaustion in the trend
(below .382). Cyan is a compression or squeeze ( above .618) and may hint a breakout one way or the other may occur.



Code:
# Deviation Scaled VWAP with Fractual Energy Coloring.

# Adapted from ToS DSMA

# Mobius FE added with two choices of coloring in the code,

# < > .5

# and > .618 between and below .382

#

# Horserider 12/1/2019


input length = 55;


def zeros = vwap - vwap[2];

def filter = reference EhlersSuperSmootherFilter(price = zeros, "cutoff length" = 0.5 * length);

def rms = Sqrt(Average(Sqr(filter), length));

def scaledFilter = filter / rms;

def alpha = 5 * AbsValue(scaledFilter) / length;

def deviationScaledVWAP = CompoundValue(1, alpha * vwap + (1 - alpha) * deviationScaledVWAP[1], 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 alphafe = (-beta + Sqrt(beta * beta + 2 * beta));

def Go = Power(alphafe, 4) * open +

             4 * (1 – alphafe) * Go[1] – 6 * Power( 1 - alphafe, 2 ) * Go[2] +

             4 * Power( 1 - alphafe, 3 ) * Go[3] - Power( 1 - alphafe, 4 ) * Go[4];

def Gh = Power(alphafe, 4) * high +

             4 * (1 – alphafe) * Gh[1] – 6 * Power( 1 - alphafe, 2 ) * Gh[2] +

             4 * Power( 1 - alphafe, 3 ) * Gh[3] - Power( 1 - alphafe, 4 ) * Gh[4];

def Gl = Power(alphafe, 4) * low +

             4 * (1 – alphafe) * Gl[1] – 6 * Power( 1 - alphafe, 2 ) * Gl[2] +

             4 * Power( 1 - alphafe, 3 ) * Gl[3] - Power( 1 - alphafe, 4 ) * Gl[4];

def Gc = Power(alphafe, 4) * data +

             4 * (1 – alphafe) * Gc[1] – 6 * Power( 1 - alphafe, 2 ) * Gc[2] +

             4 * Power( 1 - alphafe, 3 ) * Gc[3] - Power( 1 - alphafe, 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 DSVWAP = deviationScaledVWAP;

#DSVWAP.SetDefaultColor(GetColor(1));


#DSVWAP.DefineColor("Up", GetColor(1));

#DSVWAP.DefineColor("Down", GetColor(0));

#DSVWAP.AssignValueColor(if gamma < .5 then DSVWAP.Color("Down") else DSVWAP.Color("Up"));



DSVWAP.AssignValueColor(if gamma > .618  then Color.CYAN else

if gamma < .382   then Color.MAGENTA else Color.WHite);
 
Last edited:
markos

markos

Well-known member
VIP
@horserider Very inventive way of presenting VWAP. Thank you. Curious, why did you use 55 length & EhlersSS?
Always learning...
Thanks again, Markos
 
Last edited:
horserider

horserider

Well-known member
VIP
@markos The length was based on what best fit my likes. Looking for a smoother curve catching trends that skipped some of the small retraces.
As noted in the header adapted from DSMA which uses Ehlers filter.

@mc01439 Hope it works for you. Any tweaks let me know please.

I was a bit surprised more people did not have an interest. Seems to me to be a simple straightforward indicator. Maybe it is too simple and not full of lines and arrows. :unsure:;)
 
F

fpapedo

New member
VIP
@markos The length was based on what best fit my likes. Looking for a smoother curve catching trends that skipped some of the small retraces.
As noted in the header adapted from DSMA which uses Ehlers filter.

@mc01439 Hope it works for you. Any tweaks let me know please.

I was a bit surprised more people did not have an interest. Seems to me to be a simple straightforward indicator. Maybe it is too simple and not full of lines and arrows. :unsure:;)
Has anyone written a scan for this yet?
tried no success.
 
horserider

horserider

Well-known member
VIP
Added a better description of the concept of the indicator as some have requested such a description be done.
 
J

johntermotto

New member
2019 Donor
I'm looking for a study that allows you to program standard deviation bands with VWAP as the center. Screenshot attached from Sierra Charts on how this configuration works. I've learned how to calculate expected gamma bands, which needs a "programmable" offset for the deviation bands each day. I would prefer to keep this in TOS and not have a second account in Sierra Charts.

Has anyone seen something like this for TOS?

Thanks in advance for your help-
John

 
D

diazlaz

Well-known member
2019 Donor
VIP
I'm looking for a study that allows you to program standard deviation bands with VWAP as the center. Screenshot attached from Sierra Charts on how this configuration works. I've learned how to calculate expected gamma bands, which needs a "programmable" offset for the deviation bands each day. I would prefer to keep this in TOS and not have a second account in Sierra Charts.

Has anyone seen something like this for TOS?

Thanks in advance for your help-
John

I wonder if you can use the ToS standard out of the box channel indicator, StandardDevChannel, and change the price parameter to VWAP instead of close price, then add as many channels based on the deviation you want to show.
 
T

tomsk

Well-known member
VIP
The following study might help - VWAP Standard Deviation Bands, best to be run on an intraday aggregation e.g. 30 mins

 
Last edited:
J

johntermotto

New member
2019 Donor
The following study might help - VWAP Standard Deviation Bands, best to be run on an intraday aggregation e.g. 30 mins

Thanks @tomsk. Deviation bands are pretty sharp and I like how they adjust with VWAP. For now I'm calculating the gamma offsets and marking on my chart. Working well so far but nothing guaranteed. Appreciate your help!
 
T

Trading51

Member
2019 Donor
Warehouse
@mc01439 hello is that cloud moving average (purple and blue) available in here if so could you point out where thanks.

@horserider by chance do you have a setting for 5 or 15 min that you would recommend for this
 
horserider

horserider

Well-known member
VIP
@Trading51 Length depends on your style. It is a Deviation Scaled Moving Average. So try your favorite MA lengths.
 
B

Bung Bang

New member
Hi Horserider; I observe that there are very big gap on the " Deviation Scaled VWAP with Fractual Energy Coloring" study verus regular standard VWAP especially at lower aggregation like 1min; I am not sure how to interpret this as I am newbie - any help to explain. Thanks.
 
horserider

horserider

Well-known member
VIP
Yes there will be a difference. It is a moving average of the VWAP scaled to a standard deviation to the mean. Sorry cannot explain the math better.
So it will be more adaptive to rapid price movements. Just think of it as another type moving average.
 
Billions

Billions

Member
2019 Donor
Warehouse
@horserider is there anyway to get alerts on this? I appreciate it
 
Billions

Billions

Member
2019 Donor
Warehouse
@horserider When it crosses above or below
 

Top