Hello everyone. Just seeing if someone could kindly turn this into a MTF indicator? Much appreciated!
Here is the code..
Here is the code..
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;
}
Stochastic.SetDefaultColor(GetColor(5));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
Buy.SetDefaultColor(Color.UPTICK);
Buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Buy.HideBubble();
Sell.SetDefaultColor(Color.DOWNTICK);
Sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Sell.HideBubble();
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);
#MovAvgAdaptive.SetDefaultColor(GetColor(1));
# End Code Normalized Study
Last edited by a moderator: