TrendMagic Indicator Help
Is there someone willing to help convert the TrendMagic indicator used on other platforms to Tradovate code?
See examples at: https://usethinkscript.com/threads/trend-magic-indicator-for-thinkorswim.282/
What I'm using in Thinkorswim follows. IDK if Multi-Timeframe can be done in Tradovate, if not, then it's not really necessary. Thanks in advance for any help provided.
declare upper;
input MTF = no;
input MTF_timeframe = AggregationPeriod.FIVE_MIN;
def p = if MTF then MTF_timeframe else GetAggregationPeriod();
def c = close(period = p);
def h = high(period = p);
def l = low(period = p);
def pricedata = hl2(period = p);
DefineGlobalColor("TrendUp", CreateColor(0, 254, 30));
DefineGlobalColor("TrendDown", CreateColor(255, 3, 2));
input lengthCCI = 18;
input lengthATR = 5;
input AtrFactor = 1;
def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
then 0
else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if CCI > 0
then Max(MT1[1], pricedata - ATRcci)
else Min(MT1[1], pricedata + ATRcci);
plot data = MT1;
data.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);
Please sign in to leave a comment.
Comments
0 comments