SuperTrend MTF...HELP!

H

HighBredCloud

Well-known member
VIP
I am not a coder...but I am trying to play around with this idea. I want to make an MTF version of the Mobius SuperTrend. What am I doing wrong? Someone please help. Thanks in advance.


Code:
# SuperTrend Blast Off
# original authors: Mobius and BenTen
# edits: netarchitech
# 10.30.2019


# Blast Off

input PaintBars = yes;
input trig = 20;
input aggregationPeriodST = AggregationPeriod.FIVE_MIN;

def val = AbsValue(close(period = aggregationPeriodST) - open(period = aggregationPeriodST));
def range = high(period = aggregationPeriodST) - low(period = aggregationPeriodST);
def blastOffVal = (val / range) * 100;
def trigger = trig;
def blast_candle = blastOffVal < trig;


def h = high(period = aggregationPeriodST);
def l = low(period = aggregationPeriodST);
def o = open(period = aggregationPeriodST);
def c = close(period = aggregationPeriodST);

# SuperTrend

input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;

def ATR = MovingAverage(AvgType, TrueRange(high(period = aggregationPeriodST), close(period = aggregationPeriodST), low(period = aggregationPeriodST)), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close(period = aggregationPeriodST) < ST[1] then UP else DN;
def SuperTrend = ST;



#ALTERNATIVE CANDLE COLOR

#AssignPriceColor(if PaintBars and close < ST and blast_candle
#                 then GetColor(9)
#                 else if PaintBars and close > ST
#                      then GetColor(7)
#                      else GetColor(5));

AssignPriceColor(if PaintBars and close(period = aggregationPeriodST) < ST and blastOffVal < trig
                then Color.WHITE
                else if PaintBars and close(period = aggregationPeriodST) > ST
                     then Color.GREEN
                     else Color.RED);
 
T

TrueDepth

Member
VIP
I have found for some of MTF studies you have to use fundamental type. I do not know why.

Like this:

def average = Average(fundamental(fundamentaltype.close, period=AggregationPeriod.FIVE_MIN ), length);

or to do a line from your code:

def range = fundamental(fundamentaltype.high,period = aggregationPeriodST) - fundamental(fundamentaltype.low,period = aggregationPeriodST);
 

Similar threads

Top