Repaints Multi-timeframe Supertrend Chart Setup For ThinkOrSwim

Repaints

petertn

New member
Hello, I am trying to add a chime alert to this Mult-timeframe Supertrend spin-off of Mobius. This supertrend indicator is a bottom indicator and plots the supertrend for 5 different time periods. The top most line shows when all the supertrend on the different time frame aligns (show same direction) and I want an alert for when this happens . Here is a link to my charts http://tos.mx/tbP2m94. And here is the code to the indicator. Thanks!

RJHL01e.png


Code:
# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}
def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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
 
Hello, I am trying to add a chime alert to this Mult-timeframe Supertrend spin-off of Mobius. This supertrend indicator is a bottom indicator and plots the supertrend for 5 different time periods. The top most line shows when all the supertrend on the different time frame aligns (show same direction) and I want an alert for when this happens . Here is a link to my charts http://tos.mx/tbP2m94. And here is the code to the indicator. Thanks!

RJHL01e.png


Code:
# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}
def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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


this version has alert beeps.
a higher pitched beep for ups, and a lower beep for downs.


info on alerts
https://usethinkscript.com/threads/can-someone-help-me-setting-up-an-alert.10738/

https://readtheprospectus.wordpress...ng-alerts-using-thinkscript-in-think-or-swim/

Code:
# lower_dot_rows_super_trend_00

#https://usethinkscript.com/threads/can-anyone-add-a-chime-alert-to-this-multi-timeframe-supertrend-indicator-please.13844/
#Can anyone add a chime alert to this Multi-timeframe Supertrend indicator please?


# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);


# create formulas for up and down signals. use in plots and alerts
def up = (FirstAgg and SecondAgg and ThirdAgg and FourthAgg and FifthAgg);
def dwn = (!FirstAgg and !SecondAgg and !ThirdAgg and !FourthAgg and !FifthAgg);

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
Six.AssignValueColor(if up then color.green
  else if dwn then color.red
  else color.black);


# End Code ST MTF

# add lines top and bottom , to shift dot rows a little
plot z1 = 0.5;
z1.SetDefaultColor(Color.black);
z1.hidebubble();
plot z2 = 6.5;
z2.SetDefaultColor(Color.black);
z2.hidebubble();


# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(up, "crossed up" ,alert.BAR, sound.DING);
alert(dwn, "crossed down" ,alert.BAR, sound.bell);
# =====================================
#
 
this version has alert beeps.
a higher pitched beep for ups, and a lower beep for downs.


info on alerts
https://usethinkscript.com/threads/can-someone-help-me-setting-up-an-alert.10738/

https://readtheprospectus.wordpress...ng-alerts-using-thinkscript-in-think-or-swim/

Code:
# lower_dot_rows_super_trend_00

#https://usethinkscript.com/threads/can-anyone-add-a-chime-alert-to-this-multi-timeframe-supertrend-indicator-please.13844/
#Can anyone add a chime alert to this Multi-timeframe Supertrend indicator please?


# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);


# create formulas for up and down signals. use in plots and alerts
def up = (FirstAgg and SecondAgg and ThirdAgg and FourthAgg and FifthAgg);
def dwn = (!FirstAgg and !SecondAgg and !ThirdAgg and !FourthAgg and !FifthAgg);

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
Six.AssignValueColor(if up then color.green
  else if dwn then color.red
  else color.black);


# End Code ST MTF

# add lines top and bottom , to shift dot rows a little
plot z1 = 0.5;
z1.SetDefaultColor(Color.black);
z1.hidebubble();
plot z2 = 6.5;
z2.SetDefaultColor(Color.black);
z2.hidebubble();


# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(up, "crossed up" ,alert.BAR, sound.DING);
alert(dwn, "crossed down" ,alert.BAR, sound.bell);
# =====================================
#
[/c
[QUOTE="halcyonguy, post: 115312, member: 10697"]
this version has alert beeps.
a higher pitched beep for ups, and a lower beep for downs.


info on alerts
https://usethinkscript.com/threads/can-someone-help-me-setting-up-an-alert.10738/

https://readtheprospectus.wordpress.com/2009/12/08/thinkscript-tip-creating-alerts-using-thinkscript-in-think-or-swim/

[code]
# lower_dot_rows_super_trend_00

#https://usethinkscript.com/threads/can-anyone-add-a-chime-alert-to-this-multi-timeframe-supertrend-indicator-please.13844/
#Can anyone add a chime alert to this Multi-timeframe Supertrend indicator please?


# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);


# create formulas for up and down signals. use in plots and alerts
def up = (FirstAgg and SecondAgg and ThirdAgg and FourthAgg and FifthAgg);
def dwn = (!FirstAgg and !SecondAgg and !ThirdAgg and !FourthAgg and !FifthAgg);

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
Six.AssignValueColor(if up then color.green
  else if dwn then color.red
  else color.black);


# End Code ST MTF

# add lines top and bottom , to shift dot rows a little
plot z1 = 0.5;
z1.SetDefaultColor(Color.black);
z1.hidebubble();
plot z2 = 6.5;
z2.SetDefaultColor(Color.black);
z2.hidebubble();


# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(up, "crossed up" ,alert.BAR, sound.DING);
alert(dwn, "crossed down" ,alert.BAR, sound.bell);
# =====================================
#
'Preciate it ! I'll try it out tmorrow morning!

@halcyonguy Hiya friend!

The alerts works great thanks! Idk if you can do me another favor though? Are you able to code this indicator so that the entire screen lights up green/red depending on whether the Supertrend lines up/down on all time frame? Preferably a toggle on/off in the settings. Thanks!
I'm trying to make a custom 4x4 watchlist that will help me react faster.
 
Last edited by a moderator:
Are you able to code this indicator so that the entire screen lights up green/red depending on whether the Supertrend lines up/down on all time frame? Preferably a toggle on/off in the settings. Thanks!
I'm trying to make a custom 4x4 watchlist that will help me react faster.

Not sure what a 4x4 watchlist is. But be aware the ToS platform does not provide for the use of MTF indicators such as this one in watchlists, scans, conditional orders or any other part of the app that utilizes the Condition Wizard.

The following code can be appended to the end of your script to turn the whole chart green or red:
Ruby:
input paintscreen = yes ;
AssignBackgroundColor(
if !paintscreen then color.current else
if up then color.green else if dwn then color.red  else color.current);
 
this version has alert beeps.
a higher pitched beep for ups, and a lower beep for downs.


info on alerts
https://usethinkscript.com/threads/can-someone-help-me-setting-up-an-alert.10738/

https://readtheprospectus.wordpress...ng-alerts-using-thinkscript-in-think-or-swim/

Code:
# lower_dot_rows_super_trend_00

#https://usethinkscript.com/threads/can-anyone-add-a-chime-alert-to-this-multi-timeframe-supertrend-indicator-please.13844/
#Can anyone add a chime alert to this Multi-timeframe Supertrend indicator please?


# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);


# create formulas for up and down signals. use in plots and alerts
def up = (FirstAgg and SecondAgg and ThirdAgg and FourthAgg and FifthAgg);
def dwn = (!FirstAgg and !SecondAgg and !ThirdAgg and !FourthAgg and !FifthAgg);

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
Six.AssignValueColor(if up then color.green
  else if dwn then color.red
  else color.black);


# End Code ST MTF

# add lines top and bottom , to shift dot rows a little
plot z1 = 0.5;
z1.SetDefaultColor(Color.black);
z1.hidebubble();
plot z2 = 6.5;
z2.SetDefaultColor(Color.black);
z2.hidebubble();


# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(up, "crossed up" ,alert.BAR, sound.DING);
alert(dwn, "crossed down" ,alert.BAR, sound.bell);
# =====================================
#
does this repaints?
 
does this repaints?
All multi-timeframe (MTF) indicators present a type of repainting behavior.
Think about it. You have a 30-min overlay on a five-min chart. There is no way of predicting at what price that 30min candle is going to close until it closes. So for 30 minutes, it will continually repaint the 6 bars with the most recent 30min bar tick price.

Then, when the 30min candle finally closes, it will do a final repaint of the previous 6 bars with the 30min close price.

Read more:
https://usethinkscript.com/threads/...d.-,Multi-Timeframe,-REPAINTING-type Behavior
 
this version has alert beeps.
a higher pitched beep for ups, and a lower beep for downs.


info on alerts
https://usethinkscript.com/threads/can-someone-help-me-setting-up-an-alert.10738/

https://readtheprospectus.wordpress...ng-alerts-using-thinkscript-in-think-or-swim/

Code:
# lower_dot_rows_super_trend_00

#https://usethinkscript.com/threads/can-anyone-add-a-chime-alert-to-this-multi-timeframe-supertrend-indicator-please.13844/
#Can anyone add a chime alert to this Multi-timeframe Supertrend indicator please?


# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

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;

script ST{
input agg = AggregationPeriod.Five_Min;
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 h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, 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;
}

def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
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);


# create formulas for up and down signals. use in plots and alerts
def up = (FirstAgg and SecondAgg and ThirdAgg and FourthAgg and FifthAgg);
def dwn = (!FirstAgg and !SecondAgg and !ThirdAgg and !FourthAgg and !FifthAgg);

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
Six.AssignValueColor(if up then color.green
  else if dwn then color.red
  else color.black);


# End Code ST MTF

# add lines top and bottom , to shift dot rows a little
plot z1 = 0.5;
z1.SetDefaultColor(Color.black);
z1.hidebubble();
plot z2 = 6.5;
z2.SetDefaultColor(Color.black);
z2.hidebubble();


# =====================================
# alerts , sounds
# alert(condition, text, alert type, sound);
# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(up, "crossed up" ,alert.BAR, sound.DING);
alert(dwn, "crossed down" ,alert.BAR, sound.bell);
# =====================================
#
Hi halcyonguy,
Very good dashboard, Can you help if the code can be modified to the timeframes like 15mins, 30mins,1hr, 4hr, day, appreciate in advance, Thank you
 
If I want to scan for this (one filter each for each timeframe), is it possible to do so? If yes, would appreciate if you can let me know what part of the code would I need to extract and add to the filter on the scan for it to work.
 
If I want to scan for this (one filter each for each timeframe), is it possible to do so? If yes, would appreciate if you can let me know what part of the code would I need to extract and add to the filter on the scan for it to work.
The ToS platform does not support using MTF scripts in the scan hacker.
Here are the top 50 non-mtf supertrends sorted by popularity that you can use in the scan hacker:
https://usethinkscript.com/search/1...1&c[nodes][0]=3&c[title_only]=1&o=replies&g=1
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
558 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top