Deviation Scaled VWAP with Fractal Energy for ThinkorSwim

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.

2019-12-11-TOS-CHARTS.png


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:

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

@horserider Very inventive way of presenting VWAP. Thank you. Curious, why did you use 55 length & EhlersSS?
Always learning...
Thanks again, Markos
 
Last edited:
@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:;)
 
@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.
 
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'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.
 
@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
 
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.
 
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.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
425 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top