SuperTrend ++

Supertrend ++ is an HTF (HigherTimeFrame) Supertrend with an optional Volume Filter with adjustable value in the Settings. Signals are represented by Labels (Buy) to indicate a Long Entry or Labels (Sell) to indicate a Short Entry. There is 2 optional HTF with their Period and Multiplier. HTF is adjusted by default to 15M for the first HTF, 1 Day for the second and 1 Week for the last.

SuperTrend ++ in action on Dow Jones Index.

Screenshot taken from the Settings menu of SuperTrend ++.

Here is the complete list of features present in this indicator :

  • 1 Standard HTF (HigherTimeFrame) and 2 optional HTF
  • Period and Multiplier adjustable for each HTF
  • Volume Filter

All options have their original default settings. You need to be able to readjust them depending on the market instrument you want to analyze. Note that the script does not Repaint and that you have the option of placing a single Alert for all available Alerts. You have also the possibility to put individual alerts which will notify you when an indicator gives a new signal. When placing an Alert, be sure to choose the “once per bar” option each time you place an alert.

Rate this Indicator?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this Indicator.

5
(1)

Or copy / paste the source code into your pine editor :

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RickSimpson

//@version=4
study(title="Supertrend ++", overlay=true)

////////////////////////////
//       Supertrend       //
////////////////////////////

//Inputs

highertf1 = input(defval="15",  title="HigherTimeFrame 1",   type=input.resolution)
ehtf2     = input(defval=true,  title="HigherTimeFrame 2?",  type=input.bool)
highertf2 = input(defval="1D",  title="HigherTimeFrame 2",   type=input.resolution)
ehtf3     = input(defval=true,  title="HigherTimeFrame 3?",  type=input.bool)
highertf3 = input(defval="1W",  title="HigherTimeFrame 3",   type=input.resolution)
stperiod1 = input(defval=1440,  title="Supertrend Period 1", type=input.integer, minval=1)
stmult1   = input(defval=1.618, title="Multiplier 1",        type=input.float,   options=[.0146,.236,.382,.5,.618,.786,.901,1.,1.382,1.5,1.618,2,2.618,3,3.618,4.236,5.,6.18,7.86,10])
stperiod2 = input(defval=1440,  title="Supertrend Period 2", type=input.integer, minval=1)
stmult2   = input(defval=2.618, title="Multiplier 2",        type=input.float,   options=[.0146,.236,.382,.5,.618,.786,.901,1.,1.382,1.5,1.618,2,2.618,3,3.618,4.236,5.,6.18,7.86,10])
stperiod3 = input(defval=1440,  title="Supertrend Period 3", type=input.integer, minval=1)
stmult3   = input(defval=3.618, title="Multiplier 3",        type=input.float,   options=[.0146,.236,.382,.5,.618,.786,.901,1.,1.382,1.5,1.618,2,2.618,3,3.618,4.236,5.,6.18,7.86,10])
evol      = input(defval=false, title="Volume Analyzer?",    type=input.bool)
volfactor = input(defval=52,    title="Volume Factor",       type=input.integer, minval=1)

////////////////////////////
// Volume Filter Function //
////////////////////////////

volanalyzer(x) => rma(rsi(volume, 14), 20) > x
volumeanalyzer = volanalyzer(volfactor)

////////////////////////////
//       Calculation      //
////////////////////////////

internal1          = change(time(highertf1)) != 0
internal2          = change(time(highertf2)) != 0
internal3          = change(time(highertf3)) != 0
[factor1, period1] = supertrend(stmult1, stperiod1)
[factor2, period2] = supertrend(stmult2, stperiod2)
[factor3, period3] = supertrend(stmult3, stperiod3)
supertrendtf1      = fixnan(internal1 ? period1 : na)
supertrendtf2      = fixnan(internal2 ? period2 : na)
supertrendtf3      = fixnan(internal3 ? period3 : na)
baselinetf1        = supertrendtf1
baselinetf2        = supertrendtf2
baselinetf3        = supertrendtf3
baselinetf1color   = baselinetf1== -1 and baselinetf1[1] == -1 ? color.lime : baselinetf1== 1 and baselinetf1[1] == 1 ? color.red : color.gray
baselinetf2color   = baselinetf2== -1 and baselinetf2[1] == -1 ? color.blue : baselinetf2== 1 and baselinetf2[1] == 1 ? color.fuchsia : color.gray
baselinetf3color   = baselinetf3== -1 and baselinetf3[1] == -1 ? color.aqua : baselinetf3== 1 and baselinetf3[1] == 1 ? color.orange : color.gray
baselinetf1colorv  = baselinetf1== -1 and baselinetf1[1] == -1 and volumeanalyzer ? color.lime : baselinetf1== 1 and baselinetf1[1] == 1 and volumeanalyzer ? color.red : color.gray
baselinetf2colorv  = baselinetf2== -1 and baselinetf2[1] == -1 and volumeanalyzer ? color.blue : baselinetf2== 1 and baselinetf2[1] == 1 and volumeanalyzer ? color.fuchsia : color.gray
baselinetf3colorv  = baselinetf3== -1 and baselinetf3[1] == -1 and volumeanalyzer ? color.aqua : baselinetf3== 1 and baselinetf3[1] == 1 and volumeanalyzer ? color.orange : color.gray
baselinetf1c1      = evol ? baselinetf1colorv : baselinetf1color
baselinetf2c2      = evol ? baselinetf2colorv : baselinetf2color
baselinetf3c3      = evol ? baselinetf3colorv : baselinetf3color

////////////////////////////
//        Variables       //
////////////////////////////

var bool downward1 = na
var bool downward2 = na
var bool downward3 = na
var bool upward1   = na
var bool upward2   = na
var bool upward3   = na
var bool stshort1  = na
var bool stshort2  = na
var bool stshort3  = na
var bool stlong1   = na
var bool stlong2   = na
var bool stlong3   = na

////////////////////////////
//  Signals Calculations  //
////////////////////////////

stshort1  := nz(stshort1[1])
stshort2  := nz(stshort2[1])
stshort3  := nz(stshort3[1])
stlong1   := nz(stlong1[1])
stlong2   := nz(stlong2[1])
stlong3   := nz(stlong3[1])
stshort1  := evol ? baselinetf1==  1 and baselinetf1[1] ==  1 and volumeanalyzer : baselinetf1==  1 and baselinetf1[1] ==  1
stshort2  := evol ? baselinetf2==  1 and baselinetf2[1] ==  1 and volumeanalyzer : baselinetf2==  1 and baselinetf2[1] ==  1
stshort3  := evol ? baselinetf3==  1 and baselinetf3[1] ==  1 and volumeanalyzer : baselinetf3==  1 and baselinetf3[1] ==  1
stlong1   := evol ? baselinetf1== -1 and baselinetf1[1] == -1 and volumeanalyzer : baselinetf1== -1 and baselinetf1[1] == -1
stlong2   := evol ? baselinetf2== -1 and baselinetf2[1] == -1 and volumeanalyzer : baselinetf2== -1 and baselinetf2[1] == -1
stlong3   := evol ? baselinetf3== -1 and baselinetf3[1] == -1 and volumeanalyzer : baselinetf3== -1 and baselinetf3[1] == -1
downward1 := stshort1 == 1
downward2 := stshort2 == 1
downward3 := stshort3 == 1
upward1   := stlong1  == 1
upward2   := stlong2  == 1
upward3   := stlong3  == 1
stshort1  := upward1[1]  ? 1 : downward1[1] ? -1 : nz(stshort1[1])
stshort2  := upward2[1]  ? 1 : downward2[1] ? -1 : nz(stshort2[1])
stshort3  := upward3[1]  ? 1 : downward3[1] ? -1 : nz(stshort3[1])
stlong1   := upward1[1]  ? 1 : downward1[1] ? -1 : nz(stlong1[1])
stlong2   := upward2[1]  ? 1 : downward2[1] ? -1 : nz(stlong2[1])
stlong3   := upward3[1]  ? 1 : downward3[1] ? -1 : nz(stlong3[1])
stsell1    = (downward1[1] and nz(stshort1[1]) ==  1)
stsell2    = (downward2[1] and nz(stshort2[1]) ==  1)
stsell3    = (downward3[1] and nz(stshort3[1]) ==  1)
stbuy1     = (upward1[1]   and nz(stlong1[1])  == -1)
stbuy2     = (upward2[1]   and nz(stlong2[1])  == -1)
stbuy3     = (upward3[1]   and nz(stlong3[1])  == -1)

////////////////////////////
//        Plotting        //
////////////////////////////

plot(factor1, title="Supertrend ++ HTF 1 Baseline", color=baselinetf1c1, linewidth=1)
plot(ehtf2 ? factor2 : na, title="Supertrend ++ HTF 2 Baseline", color=baselinetf2c2, linewidth=1)
plot(ehtf3 ? factor3 : na, title="Supertrend ++ HTF 3 Baseline", color=baselinetf3c3, linewidth=1)
plotshape(stsell1, title="Supertrend ++ HTF 1 Sell", text="Sell", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.red,     size=size.tiny, transp=0)
plotshape(ehtf2 ? stsell2 : na, title="Supertrend ++ HTF 2 Sell", text="Sell", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.fuchsia, size=size.tiny, transp=0)
plotshape(ehtf3 ? stsell3 : na, title="Supertrend ++ HTF 3 Sell", text="Sell", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.orange,  size=size.tiny, transp=0)
plotshape(stbuy1,  title="Supertrend ++ HTF 1 Buy",  text="Buy",  textcolor=color.white, style=shape.labelup,   location=location.belowbar, color=color.green,   size=size.tiny, transp=0)
plotshape(ehtf2 ? stbuy2  : na, title="Supertrend ++ HTF 2 Buy",  text="Buy",  textcolor=color.white, style=shape.labelup,   location=location.belowbar, color=color.blue,    size=size.tiny, transp=0)
plotshape(ehtf3 ? stbuy3  : na, title="Supertrend ++ HTF 3 Buy",  text="Buy",  textcolor=color.white, style=shape.labelup,   location=location.belowbar, color=color.aqua,    size=size.tiny, transp=0)

////////////////////////////
//         Alerts         //
////////////////////////////

//Type 1

if stsell1
    alert("Supertrend ++ HTF 1 Sell!", alert.freq_once_per_bar)
if stbuy1
    alert("Supertrend ++ HTF 1 Buy!",  alert.freq_once_per_bar)
if stsell2
    alert("Supertrend ++ HTF 2 Sell!", alert.freq_once_per_bar)
if stbuy2
    alert("Supertrend ++ HTF 2 Buy!",  alert.freq_once_per_bar)
if stsell3
    alert("Supertrend ++ HTF 3 Sell!", alert.freq_once_per_bar)
if stbuy3
    alert("Supertrend ++ HTF 3 Buy!",  alert.freq_once_per_bar)

//Type 2

alertcondition(stsell1, title="Supertrend ++ HTF 1 Sell!", message='Supertrend ++ HTF 1 Sell!')
alertcondition(stsell2, title="Supertrend ++ HTF 2 Sell!", message='Supertrend ++ HTF 2 Sell!')
alertcondition(stsell3, title="Supertrend ++ HTF 3 Sell!", message='Supertrend ++ HTF 3 Sell!')
alertcondition(stbuy1,  title="Supertrend ++ HTF 1 Buy!",  message='Supertrend ++ HTF 1 Buy!')
alertcondition(stbuy2,  title="Supertrend ++ HTF 2 Buy!",  message='Supertrend ++ HTF 2 Buy!')
alertcondition(stbuy3,  title="Supertrend ++ HTF 3 Buy!",  message='Supertrend ++ HTF 3 Buy!')

The content covered on this website is NOT investment advice and I am not a financial advisor.