I use this one often on think or swim, and it has several adjustable parameters. fast length, slow length, trend length, noise type, noise length, and correction factor. Anyway to program this one for Ninjatrader?
Source from ToS Platform:
#
# TD Ameritrade IP Company, Inc. (c) 2009-2015
#
declare lower;
input fastLength = 7;
input slowLength = 15;
input trendLength = 4;
input noiseType = {default linear, squared};
input noiseLength = 250;
input correctionFactor = 2;
assert(trendLength > 0, "'trend length' must be positive: " + trendLength);
assert(correctionFactor > 0, "'correction factor' must be positive: " + correctionFactor);
def smf = 2 / (1 + trendLength);
def reversal = TrendPeriods(fastLength, slowLength);
def cpc = if isNaN(reversal[1]) then 0 else if reversal[1] != reversal then 0 else cpc[1] + close - close[1];
def trend = if isNaN(reversal[1]) then 0 else if reversal[1] != reversal then 0 else trend[1] * (1 - smf) + cpc * smf;
def noise;
def diff = AbsValue(cpc - trend);
switch(noiseType) {
case linear:
noise = correctionFactor * Average(diff, noiseLength);
case squared:
noise = correctionFactor * Sqrt(Average(diff*diff, noiseLength));
}
def denom = AbsValue(trend) + AbsValue(noise);
plot TNB = if denom == 0 then 0 else 100 * AbsValue(trend) / denom;
plot HalfLine = 50;
TNB.SetDefaultColor(GetColor(9));
HalfLine.SetDefaultColor(GetColor(5));

Comment