Important Note for MTF Studies utilizing script() for Secondary Aggs

T

tomsk

Well-known member
VIP
Just a heads up for those that have MTF studies that use script() to handle secondary aggregations do not work
This was discussed at length in the TSL yesterday as well as about a week ago.
Mobius eluded to the fact that secondary aggs using script() do not work
Hence if your MTF study displays strange results, this would be the underlying cause
 
D

diazlaz

Well-known member
2019 Donor
VIP
thanks @tomsk I've never had an issue with secondary inside scripts. can you the summary of the discussion and issue?

this is how I always have done it, and I spent time comparing the results over the last year or so, and scripts seem to always have work fine for me.

Here is an example on how I've used them:



in this example notice the comment (label to right), compare the values to the 5MIN in the left/lower inside the 3 scripts.

Any insight or examples would be greatly appreciated. this revelation might have me go back and retest a bunch of code now :|

aggTestScript
Ruby:
script Superfast {
    input useCurrentAggPeriod = yes;
    input AggPeriod = AggregationPeriod.FIVE_MIN;
    input superfast_length = 8;
    input fast_length = 13;
    input slow_length = 21;
    input displace = 0;
    def agg = If(useCurrentAggPeriod, GetAggregationPeriod(), AggPeriod);

    def h = high(period = agg);
    def l = low(period = agg);
    def o = open(period = agg);
    def c = close(period = agg);
    def v = volume(period = agg);
    def price = close(period = agg);

    plot Superfast = ExpAverage(price[-displace], superfast_length);
}

script Fast {
    input useCurrentAggPeriod = yes;
    input AggPeriod = AggregationPeriod.FIVE_MIN;
    input superfast_length = 8;
    input fast_length = 13;
    input slow_length = 21;
    input displace = 0;
    def agg = If(useCurrentAggPeriod, GetAggregationPeriod(), AggPeriod);

    def h = high(period = agg);
    def l = low(period = agg);
    def o = open(period = agg);
    def c = close(period = agg);
    def v = volume(period = agg);
    def price = close(period = agg);

    plot Fast = ExpAverage(price[-displace], fast_length);
}

script Slow {
    input useCurrentAggPeriod = yes;
    input AggPeriod = AggregationPeriod.FIVE_MIN;
    input superfast_length = 8;
    input fast_length = 13;
    input slow_length = 21;
    input displace = 0;
    def agg = If(useCurrentAggPeriod, GetAggregationPeriod(), AggPeriod);

    def h = high(period = agg);
    def l = low(period = agg);
    def o = open(period = agg);
    def c = close(period = agg);
    def v = volume(period = agg);
    def price = close(period = agg);

    plot Slow = ExpAverage(price[-displace], slow_length);
}

plot Superfast = SuperFast(no, "FIVE_MIN");
plot Fast = Fast(no, "FIVE_MIN");
plot Slow = Slow(no, "FIVE_MIN");
aggTestNoScript
Ruby:
input useCurrentAggPeriod = yes;
input AggPeriod = AggregationPeriod.FIVE_MIN;
input superfast_length = 8;
input fast_length = 13;
input slow_length = 21;
input displace = 0;
def agg = If(useCurrentAggPeriod,getAggregationPeriod(),AggPeriod);

def h = high(period = agg);
def l = low(period = agg);
def o = open(period = agg);
def c = close(period = agg);
def v = volume(period = agg);
def price = close(period = agg);

AddLabel(yes,"using current: " + useCurrentAggPeriod, COLOR.WHITE);

plot Superfast = ExpAverage(price[-displace], superfast_length);
plot Fast = ExpAverage(price[-displace], fast_length);
plot Slow = ExpAverage(price[-displace], slow_length);
 
horserider

horserider

Well-known member
VIP
Confusing to me. This looks simpler.

input AggPeriod = AggregationPeriod.FIVE_MIN;
input superfast_length = 8;
input fast_length = 13;
input slow_length = 21;
input displace = 0;
def price = close(period = aggperiod);
plot Superfast = ExpAverage(price[-displace], superfast_length);
plot Fast = ExpAverage(price[-displace], fast_length);
plot Slow = ExpAverage(price[-displace], slow_length);


 
S

SmellyCat

New member
I was given this by Mobius but I have found that it did not plot accurately in the higher time frames. Something glitchy with ToS.
it will blink back and forth red to green. also it is just inaccurate when you actually compare to the real time chart in the higher time frame.
let me know your thoughts or corrections

 
T

tomsk

Well-known member
VIP
@SmellyCat Yes, this is precisely the reason I sounded the alert when I posted this thread several days ago. In the study you posted, notice the use of a script function that uses a secondary aggregation. Thus as noted earlier in my post, this will not yield the results you seek and will not work. The workaround is to revamp the code and avoid using the using script() function for secondary aggregation
 
D

diazlaz

Well-known member
2019 Donor
VIP
thanks @SmellyCat and @tomsk



what is the issue? rendering, data results, expect values wrong, NaN?

I do a lot of secondary aggregation in scripts and I have validated the results; haven't run into significant issues when calling multiple aggregations in scripts.

thanks for bring attention to this!
 
D

diazlaz

Well-known member
2019 Donor
VIP
I was curious, so took it a part to quickly test, I think it's working correctly.

the only difference that I made, is made the current time aggregation run inside the script, and made a few modifications to reduce functions that could be causing issues during testing and removed the back lookup of [1] on the aggregations and was able to match it exactly on the secondary 5 minute chart see example:



Ruby:
### TEST VERSION TO TEST OUT THE MULTIPLE AGGREGATION ###

# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

declare lower;

script ST{
input agg = AggregationPeriod.Five_Min;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
def h = high(period = agg);
def l = low(period = agg);
def c = close(period = agg);
def hl = hl2(period = agg);
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = hl + (AtrMult * ATR);
def DN = hl + (-AtrMult * ATR);
def S = if c < S[1]
        then Round(UP / tickSize(), 0) * tickSize()
        else Round(DN / tickSize(), 0) * tickSize();
plot ST = if c > S then 1 else 0;
}

#INPUT
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

#LOGIC

def FirstAgg = ST(agg = "min", AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FirstAggPlot = if isNaN(close) then double.nan else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1 then color.green else color.red);

def SecondAgg = ST(agg = "FIVE_MIN", AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot SecondAggPlot = if isNaN(close) then double.nan else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1 then color.green else color.red);

def ThirdAgg = ST(agg = "Ten_Min", AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot ThirdAggPlot = if isNaN(close) then double.nan else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1 then color.green else color.red);

def FourthAgg = ST(agg = "Fifteen_Min", AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FourthAggPlot = if isNaN(close) then double.nan else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1 then color.green else color.red);

def FifthAgg = ST(agg = "Hour", AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FifthAggPlot = if isNaN(close) then double.nan else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1 then color.green else color.red);
 
T

tomsk

Well-known member
VIP
Folks, given the recent interest in the MTF SuperTrend, I have modified the study that @SmellyCat posted earlier
Essentially removed the script function component and replaced it with what I term "standard" code
Ran it on a 1 min chart of MSFT and it does yield different results.

Code:
# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Five_Min;
input agg2 = AggregationPeriod.Ten_Min;
input agg3 = AggregationPeriod.Fifteen_Min;
input agg4 = AggregationPeriod.Thirty_Min;
input agg5 = AggregationPeriod.Hour;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
        then Round(UP / tickSize(), 0) * tickSize()
        else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
                    then double.nan
                    else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
         then Round(UP2 / tickSize(), 0) * tickSize()
         else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
                     then double.nan
                     else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
                               then color.green
                               else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
         then Round(UP3 / tickSize(), 0) * tickSize()
         else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
                    then double.nan
                    else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
         then Round(UP4 / tickSize(), 0) * tickSize()
         else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
                     then double.nan
                     else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
                               then color.green
                               else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
         then Round(UP5 / tickSize(), 0) * tickSize()
         else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
                    then double.nan
                    else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
           then double.nan
           else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
                        SecondAgg and
                        ThirdAgg and
                        FourthAgg and
                        FifthAgg
                     then color.green
                     else if !FirstAgg and
                             !SecondAgg and
                             !ThirdAgg and
                             !FourthAgg and
                             !FifthAgg
                          then color.red
                     else color.black);
# End Code ST MTF
 
D

diazlaz

Well-known member
2019 Donor
VIP
Folks, given the recent interest in the MTF SuperTrend, I have modified the study that @SmellyCat posted earlier
Essentially removed the script function component and replaced it with what I term "standard" code
Ran it on a 1 min chart of MSFT and it does yield different results.

# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Five_Min;
input agg2 = AggregationPeriod.Ten_Min;
input agg3 = AggregationPeriod.Fifteen_Min;
input agg4 = AggregationPeriod.Thirty_Min;
input agg5 = AggregationPeriod.Hour;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
then double.nan
else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then color.green
else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
then Round(UP2 / tickSize(), 0) * tickSize()
else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
then double.nan
else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then color.green
else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
then Round(UP3 / tickSize(), 0) * tickSize()
else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
then double.nan
else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then color.green
else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
then Round(UP4 / tickSize(), 0) * tickSize()
else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
then double.nan
else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
then Round(UP5 / tickSize(), 0) * tickSize()
else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
then double.nan
else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
then double.nan
else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then color.green
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then color.red
else color.black);
# End Code ST MTF
thanks - I think the issue is the "[1] in the Fundamental(Fh, period = agg3)[1];" lines - can you try the it without [1]. the displacer I think it's what is causing the mismatch. the first agg never had any displacer in the original script.
 
MBF

MBF

Active member
2019 Donor
@diazlaz can you direct me to the original script all are talking about? I use one quite often but I have many. I wanted to see if the script I use is the one you guys are talking about. The one above I posted. Thanks
 
T

tomsk

Well-known member
VIP
@MBF the tos.mx link you posted above does not have any script() function embedded in the code, so is a non issue in your case
 
  • Like
Reactions: MBF
D

diazlaz

Well-known member
2019 Donor
VIP
@MBF the tos.mx link you posted above does not have any script() function embedded in the code, so is a non issue in your case
@diazlaz can you direct me to the original script all are talking about? I use one quite often but I have many. I wanted to see if the script I use is the one you guys are talking about. The one above I posted. Thanks
Hi @MBF, its the same script as above :) - I was troubleshooting the use of agg when leveraging the thinkscript function keyword "script". Best!
 
  • Like
Reactions: MBF
horserider

horserider

Well-known member
VIP
@MBF If your study does not have the code as shown below with the agg condition inside the script brackets it will not have this problem.

script Superfast {
input useCurrentAggPeriod = yes;
input AggPeriod = AggregationPeriod.FIVE_MIN;
 
  • Like
Reactions: MBF
S

SmellyCat

New member
Folks, given the recent interest in the MTF SuperTrend, I have modified the study that @SmellyCat posted earlier
Essentially removed the script function component and replaced it with what I term "standard" code
Ran it on a 1 min chart of MSFT and it does yield different results.

# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Five_Min;
input agg2 = AggregationPeriod.Ten_Min;
input agg3 = AggregationPeriod.Fifteen_Min;
input agg4 = AggregationPeriod.Thirty_Min;
input agg5 = AggregationPeriod.Hour;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
then double.nan
else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then color.green
else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
then Round(UP2 / tickSize(), 0) * tickSize()
else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
then double.nan
else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then color.green
else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
then Round(UP3 / tickSize(), 0) * tickSize()
else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
then double.nan
else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then color.green
else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
then Round(UP4 / tickSize(), 0) * tickSize()
else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
then double.nan
else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
then Round(UP5 / tickSize(), 0) * tickSize()
else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
then double.nan
else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
then double.nan
else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then color.green
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then color.red
else color.black);
# End Code ST MTF

tomsk - Yes, your code now plots accurately as far as I can tell. Thanks for clarifying it! Very nice and helpful.
 
MBF

MBF

Active member
2019 Donor
@MBF If your study does not have the code as shown below with the agg condition inside the script brackets it will not have this problem.

script Superfast {
input useCurrentAggPeriod = yes;
input AggPeriod = AggregationPeriod.FIVE_MIN;
Thank you!
 
H

HighBredCloud

Active member
VIP
Folks, given the recent interest in the MTF SuperTrend, I have modified the study that @SmellyCat posted earlier
Essentially removed the script function component and replaced it with what I term "standard" code
Ran it on a 1 min chart of MSFT and it does yield different results.

# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Five_Min;
input agg2 = AggregationPeriod.Ten_Min;
input agg3 = AggregationPeriod.Fifteen_Min;
input agg4 = AggregationPeriod.Thirty_Min;
input agg5 = AggregationPeriod.Hour;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
then double.nan
else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then color.green
else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
then Round(UP2 / tickSize(), 0) * tickSize()
else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
then double.nan
else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then color.green
else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
then Round(UP3 / tickSize(), 0) * tickSize()
else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
then double.nan
else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then color.green
else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
then Round(UP4 / tickSize(), 0) * tickSize()
else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
then double.nan
else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
then Round(UP5 / tickSize(), 0) * tickSize()
else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
then double.nan
else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
then double.nan
else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then color.green
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then color.red
else color.black);
# End Code ST MTF
@tomsk Interesting...is this particular study ONLY suppose to work on anything less than 10 min timeframe? Seems when put that on a 15 min and up timeframe nothing shows...just want to make sure that's how it's suppose to be. ALSO what I noticed...For example when I was on a 3 min time frame and I changed to the first AGG input from 5 min to 3 min...followed by changing the second AGG to 5 min...the third AGG to 10 etc...The issue was that the first AGG that was set to 3 min gave readings as if it was on the 5 min...Raising a question if anything below 5 min timeframe will show up correctly when the AGG times are changed from 5m 10m 15m and so on...
 
T

tomsk

Well-known member
VIP
@HighBredCloud - You have to respect the manner in which the secondary aggregation is being defined. I have modified the input values for the various secondary aggregations. Load the following on a 15 min chart of AAPL

Code:
# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Fifteen_Min;
input agg2 = AggregationPeriod.Thirty_Min;
input agg3 = AggregationPeriod.Hour;
input agg4 = AggregationPeriod.Two_Hours;
input agg5 = AggregationPeriod.DAY;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
then double.nan
else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then color.green
else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
then Round(UP2 / tickSize(), 0) * tickSize()
else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
then double.nan
else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then color.green
else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
then Round(UP3 / tickSize(), 0) * tickSize()
else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
then double.nan
else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then color.green
else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
then Round(UP4 / tickSize(), 0) * tickSize()
else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
then double.nan
else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
then Round(UP5 / tickSize(), 0) * tickSize()
else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
then double.nan
else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
then double.nan
else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then color.green
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then color.red
else color.black);
# End Code ST MTF
 
horserider

horserider

Well-known member
VIP
I believe you can only set th secondary aggs to time frames higher than the chart time frame, otherwise it will be messed up. That it seems is what he is telling you.
 
H

HighBredCloud

Active member
VIP
@HighBredCloud - You have to respect the manner in which the secondary aggregation is being defined. I have modified the input values for the various secondary aggregations. Load the following on a 15 min chart of AAPL


# SuperTrend Multiple Time Frames
# Mobius with mods by tomsk to replace the script() function for secondary aggs with "standard" code
# V03.01.2016
# 11.4.2019

declare lower;

input agg1 = AggregationPeriod.Fifteen_Min;
input agg2 = AggregationPeriod.Thirty_Min;
input agg3 = AggregationPeriod.Hour;
input agg4 = AggregationPeriod.Two_Hours;
input agg5 = AggregationPeriod.DAY;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = hl2 + (AtrMult * ATR);
def DN = hl2 + (-AtrMult * ATR);
def S = if close < S[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
def FirstAgg = if close > S then 1 else 0;
plot FirstAggPlot = if isNaN(cl)
then double.nan
else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then color.green
else color.red);
AddChartBubble(x, 1, (GetAggregationPeriod()/1000/60) + " min", color.white, yes);

# SecondAgg
def h2 = Fundamental(Fh, period = agg2)[1];
def l2 = Fundamental(Fl, period = agg2)[1];
def c2 = Fundamental(Fc, period = agg2)[1];
def hl2 = Fundamental(Fhl2, period = agg2)[1];
def ATR2 = MovingAverage(AvgType, TrueRange(h2, c2, l2), nATR);
def UP2 = hl2 + (AtrMult * ATR2);
def DN2 = hl2 + (-AtrMult * ATR2);
def S2 = if c2 < S2[1]
then Round(UP2 / tickSize(), 0) * tickSize()
else Round(DN2 / tickSize(), 0) * tickSize();
def SecondAgg = if c2 > S2 then 1 else 0;
plot SecondAggPlot = if isNaN(cl)
then double.nan
else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then color.green
else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);

# ThirdAgg
def h3 = Fundamental(Fh, period = agg3)[1];
def l3 = Fundamental(Fl, period = agg3)[1];
def c3 = Fundamental(Fc, period = agg3)[1];
def hl3 = Fundamental(Fhl2, period = agg3)[1];
def ATR3 = MovingAverage(AvgType, TrueRange(h3, c3, l3), nATR);
def UP3 = hl3 + (AtrMult * ATR3);
def DN3 = hl3 + (-AtrMult * ATR3);
def S3 = if c3 < S3[1]
then Round(UP3 / tickSize(), 0) * tickSize()
else Round(DN3 / tickSize(), 0) * tickSize();
def ThirdAgg = if c3 > S3 then 1 else 0;
plot ThirdAggPlot = if isNaN(cl)
then double.nan
else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then color.green
else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);

# FourthAgg
def h4 = Fundamental(Fh, period = agg4)[1];
def l4 = Fundamental(Fl, period = agg4)[1];
def c4 = Fundamental(Fc, period = agg4)[1];
def hl4 = Fundamental(Fhl2, period = agg4)[1];
def ATR4 = MovingAverage(AvgType, TrueRange(h4, c4, l4), nATR);
def UP4 = hl4 + (AtrMult * ATR4);
def DN4 = hl4 + (-AtrMult * ATR4);
def S4 = if c4 < S4[1]
then Round(UP4 / tickSize(), 0) * tickSize()
else Round(DN4 / tickSize(), 0) * tickSize();
def FourthAgg = if c4 > S4 then 1 else 0;
plot FourthAggPlot = if isNaN(cl)
then double.nan
else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);

# FifthAgg
def h5 = Fundamental(Fh, period = agg5)[1];
def l5 = Fundamental(Fl, period = agg5)[1];
def c5 = Fundamental(Fc, period = agg5)[1];
def hl5 = Fundamental(Fhl2, period = agg5)[1];
def ATR5 = MovingAverage(AvgType, TrueRange(h5, c5, l5), nATR);
def UP5 = hl5 + (AtrMult * ATR5);
def DN5 = hl5 + (-AtrMult * ATR5);
def S5 = if c5 < S5[1]
then Round(UP5 / tickSize(), 0) * tickSize()
else Round(DN5 / tickSize(), 0) * tickSize();
def FifthAgg = if c5 > S5 then 1 else 0;
plot FifthAggPlot = if isNaN(cl)
then double.nan
else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then color.green
else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
then double.nan
else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then color.green
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then color.red
else color.black);
# End Code ST MTF
@tomsk This works perfectly on 15 min now...I wanted to use this particular study as confirmation with a SuperTrend indicator I found in hopes that this study could avoid the repaint of the candles caused by the SuperTrend. So now I need to see IF this study repaints more or less than the SuperTrend that I am using. I only kept the 15 min AGG and turned off the rest...Just out of curiosity IF I were to delete the AGG's that I am not using from the code and only keep the 15 min would that somehow alter anything how the study is calculated? Or is it better just to uncheck the "show plot" ? Sorry I am not a coder...so I don't know such effects of actions. Here's what I had in mind.

 
Thread starter Similar threads Forum Replies Date
D Ultimate Moving Average 7MA Types MTF Questions 5
S TI_MarketPulse Indicator MTF Request Questions 22
H MTF Opening Price Labels? Questions 0
F MTF CCI? Questions 0
S Ichimoku MTF Indicator for ThinkorSwim? Questions 0
Top