• Get $40 off VIP by signing up for a free account! Sign Up

Ehlers Stochastic and AMA into a MTF?


Hello everyone. Just seeing if someone could kindly turn this into a MTF indicator? Much appreciated!

Here is the code..

# Normalized Ehlers Stochastic and AMA
# Mobius
# Chat Room Request 03.21.2018

declare lower;

input price = close;
input length = 20;
input cutoffLength = 10;
input over_bought = 0.8;
input over_sold = 0.2;
input mode = {default Predictive, Conventional};

def filt = reference EhlersRoofingFilter(price, cutoffLength);
def highestP = Highest(filt, length);
def lowestP = Lowest(filt, length);
def stoch = if (highestP - lowestP) != 0 then (filt - lowestP) / (highestP - lowestP) else 0;

plot Stochastic = reference EhlersSuperSmootherFilter(stoch, cutoffLength);
plot OverBought = over_bought;
plot OverSold = over_sold;
plot Buy;
plot Sell;
switch (mode) {
case Predictive:
    Buy = if Stochastic crosses below OverSold then OverSold + 0.05 else Double.NaN;
    Sell = if Stochastic crosses above OverBought then OverBought - 0.05 else Double.NaN;
case Conventional:
    Buy = if Stochastic crosses above OverSold then OverSold + 0.05 else Double.NaN;
    Sell = if Stochastic crosses below OverBought then OverBought - 0.05 else Double.NaN;


script Scale {
    input c = close;
    input Min = 0;
    input Max = 1;
    def hh = Highest(c, 20);
    def ll = Lowest(c, 20);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;

input fastLength = 2;
input slowLength = 30;
input effRatioLength = 10;

assert(fastLength > 0, "'fast length' must be positive: " + fastLength);
assert(slowLength > 0, "'slow length' must be positive: " + slowLength);

def direction = AbsValue(price - price[effRatioLength]);
def volatility = sum(AbsValue(price - price[1]), effRatioLength);
def ER = if volatility != 0 then direction / volatility else 0;
def FastSF = 2 / (fastLength + 1);
def SlowSF = 2 / (slowLength + 1);
def ScaledSF = ER * (FastSF - SlowSF) + SlowSF;
def AMA = compoundValue(1, AMA[1] + Sqr(ScaledSF) * (price - AMA[1]), price);

plot MovAvgAdaptive = Scale(AMA);

# End Code Normalized Study
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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