Deviation Scaled VWAP with Fractal Energy for ThinkorSwim

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

@horserider Thank you for this, as well as all of your contributions. I was actually able to use this on the daily chart, with great success. Combined with TMO, im buying when price is above and selling when price is below
 
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:;)
Interesting approach, I am downloading and examining it.
Not sure. What are you alerting?
Interesting approach to VWAP. I am downloading it into TOS and will be examining it. Thanks for your creativity and energy
 
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);
Ehlers work is exellent. Adding the VWAP to it is an enhancement: { It offers an alternative to ratio based Bayerism assumption of equally based ranked ratio system. Suggest you add the Ehlers median based DistantCoefficientFilter to a chart as an overlay.. It is a technique for finding the weigthed mov ave of the Median price, thereby showing the internal tension as the moving average occillates.} Engineers use such techniques in addition to Rate of Change with Bands to extract the positive and negative squared error of the means of any moving vector.. Once you grasp the significance of this it gives you an additional insight into the actual auction- price discovery process. Also Horserider, I have seen you before and am grateful for your diligence and work ethic. I have used this indicator and a series of similar ones as well. I commend your work ethic and generosity. Best wishes and Happy Holidays
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
276 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