Smart Supertrend

Smart Supertrend

Here I leave an adaptation of the supertrend indicator.
We have the cloud, which shows us the price trend according to color.
On the other hand we have the adapted version of the supertrend, which can be used as a trailstop or confirmation.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Madrosat • 02/12/2024 #

    Hello Ivan
    You have interesting topics on indicators , smart supertrend, optimised trend tracker, end ema9-21 , but did you have some exemples of wining strategy with this indicators.
    Congratulations

  2. Iván • 02/12/2024 #

    Hi! thanks. All of these codes are translations requested in the forum. I’ve on mind to backtest all of them.

  3. Raspete01 • 02/12/2024 #

    Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Backtest para sacar estadística de funcionamiento real.
    Marqué orden de compra y venta en el siguiente punto, por favor, está correcto ?
    Muchas gracias
    src = open
    prd = 2 //PP period
    factor = 3//Atr factor
    Pd = 12//Atr period
    len = 12//Cloud length
    Adxlen = 24//Adx length
    th = 24//Adx treshold
    showsignals = 0//boolean
    colorcandle = 0//boolean
    /////////////////////////Indicators///////////////////////////////
    ////////CLOUD
    pi=2*asin(1)
    er = abs(src-src[len])/summation[len](abs(src-src[1]))

    fastlimit = er
    slowlimit = er*0.1

    if barindex<6 then
    mesaperiod = 0
    smooth = 0
    detrender = 0
    I1 = 0
    I2 = 0
    Q1 = 0
    jI = 0
    Q2 = 0
    phase = 0
    else
    mesaperiodmult = 0.075*mesaperiod[1] + 0.54
    smooth = (4*src + 3*src[1]+2*src[2]+src[3])/10
    detrender = (0.0962*smooth + 0.5769*smooth[2] – 0.5769*smooth[4]-0.0962*smooth[6])*mesaPeriodMult
    I1= detrender[3]
    Q1 =(0.0962*detrender + 0.5769*detrender[2] – 0.5769*detrender[4]-0.0962*detrender[6])*mesaPeriodMult
    jI= (0.0962*I1 + 0.5769*I1[2] – 0.5769*I1[4]-0.0962*I1[6])*mesaPeriodMult
    jQ = (0.0962*Q1 + 0.5769*Q1[2] – 0.5769*Q1[4]-0.0962*Q1[6])*mesaPeriodMult
    I2 = I1 – jQ
    Q2 = Q1 + jI
    I2 = 0.2*I2 + 0.8*I2[1]
    Q2 = 0.2*Q2 + 0.8*Q2[1]
    Re = I2*I2[1] + Q2*Q2[1]
    Im = I2*Q2[1] – Q2*I2[1]
    Re = 0.2*Re + 0.8*Re[1]
    Im = 0.2*Im + 0.8*Im[1]
    if Re 0 and Im 0 then
    mesaperiod=2 * pi/atan(Im/Re)
    endif
    if mesaperiod>1.5*mesaperiod[1] then
    mesaperiod=1.5*mesaperiod[1]
    endif
    if mesaperiod<0.67*mesaperiod[1] then
    mesaperiod=0.67*mesaperiod[1]
    endif
    if mesaperiod 50 then
    mesaperiod = 50
    endif
    mesaperiod = 0.2*mesaperiod+0.8*mesaperiod[1]
    if I1 0 then
    phase=(180/pi)*atan(Q1/I1)
    endif
    deltaphase = phase[1]-phase
    if deltaphase < 1 then
    deltaphase = 1
    endif
    alpha = fastlimit/deltaphase
    if alpha < slowlimit then
    alpha = slowlimit
    endif
    endif

    a = alpha
    b = alpha/2

    if barindex kama[1]
    Scloud = kama mdi and myadx > th //long trend
    sadx = pdi th //short trend

    /////////PRICE POSITION
    ////////pivothigh
    ph1 = high < high[prd]
    ph2 = highest[prd](high) highest[prd](high)[prd+1]

    if ph1 and ph2 and ph3 then
    pivotH = high[prd]

    else
    pivotH = pivotH

    endif
    ////////pivotlow
    pl1 = low > low[prd]
    pl2 = lowest[prd](low) > low[prd]
    pl3 = low[prd] < lowest[prd](low)[prd+1]

    if pl1 and pl2 and pl3 then
    pivotL = low[prd]

    else
    pivotL = pivotL

    endif
    ////////Trailing
    if barindex = 0 then
    center = 0
    lastpp = 0
    Tup=0
    Tdown=0
    Trend=0
    else
    if pivotH pivotH[1] then
    lastpp = pivotH
    center = (center*2+lastpp)/3
    BUY 10000 CASH AT MARKET NextBarOpen
    elsif pivotL pivotL[1] then
    lastpp = pivotL
    center = (center*2+lastpp)/3
    sell at market NextBarOpen
    else
    lastpp = lastpp[1]
    center = center[1]
    endif

    atr = averagetruerange[pd](close)
    Up = center-(factor*atr)
    Dn = center+(factor*atr)

    if close[1]>Tup[1] then
    Tup = max(Up,Tup[1])
    else
    Tup = Up
    endif

    if close[1] Tdown[1] then
    Trend = 1
    elsif close < Tup[1] then
    Trend = -1
    else
    Trend = Trend[1]
    endif
    if trend = 1 then
    Trailings1 = Tup
    else
    Trailings1 = Tdown
    endif
    endif
    //////////SIGNALS
    if showsignals then
    bsignal = Trend=1 and Trend[1]=-1
    ssignal = Trend=-1 and Trend[1]=1
    if bsignal and not Scloud then
    firstlong = Trailings1

    else
    firstlong = undefined

    endif
    if ssignal and not Lcloud then
    firstshort = Trailings1

    else
    firstshort = undefined

    endif

    secondlong = Lcloud and Ladx and trend=1
    secondshort = Scloud and Sadx and trend=-1

    long = secondlong and firstlong
    short = secondshort and firstshort

    once longshort = 0
    longlast = long and (longshort[1]=0 or longshort[1]=-1)
    shortlast = short and (longshort[1]=0 or longshort[1]=1)

    if longlast = 1 then
    longshort = 1
    elsif longshort = 1 then
    longshort = -1
    else
    longshort = longshort[1]
    endif

    lastlongcond = long and longlast
    lastshortcond = short and shortlast

    if (bsignal and not scloud) or (lastlongcond) then
    longplot = Trailings1

    //drawarrowup(barindex,low-0.10*atr)
    else
    longplot = undefined
    endif

    if (ssignal and not lcloud) or (lastshortcond) then
    shortplot = trailings1

    //drawarrowdown(barindex,high+0.10*atr)
    else
    shortplot = undefined
    endif

    if ssignal and lcloud then
    longstop = trailings1

    //drawtext("✘",barindex,high+0.10*atr)coloured(0,250,0)
    else
    longstop = undefined
    endif

    if bsignal and scloud then
    shortstop = trailings1

    //drawtext("✘",barindex,low-0.10*atr)coloured(250,0,0)
    else
    shortstop = undefined

    endif

    endif

    ///////////COLOR CANDLES
    if colorcandle then
    if Lcloud then
    rbar=0
    gbar=210
    bbar=0
    elsif Scloud then
    rbar=255
    gbar=0
    bbar=0
    endif

    ENDIF
    //return mama as "Cloud A" coloured(rcloud,gcloud,bcloud), fama as "Cloud B" coloured(rcloud,gcloud,bcloud), Trailings1 as "PP line" coloured(rcloud,gcloud,bcloud)
    //return a*src as "a*src",(1-a) as "1-a"

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Nicolas Merci dans ce cas d'ouvrir un sujet dans le forum ProScreener svp.
Andrea Hi Nicolas, thx for your code. Please i need your help to understand this part of your code:...
Nicolas the MA200 is ascending since 20 periods.
Regan2020 Hi, has anybody update the above code to enable on a 15m or 5m TF?
gigi64 ik heb de code op mijn pro realtime gezet , en bij indicator staat hij erbij maar komt niet ...
gigi64 I have put the code on my pro realtime, and it is on the indicator, but it does not appear o...
supertiti Thanks you so much Lucassen
dreif123 hi, copied the above code, not working on 10.3 the system says "return can only be used at ...
LUCASSEN Hallo , i have no problem , and i have the same versie 10.3, maybe you can ask Nicolas, tha...
Nicolas Indeed, if you are not willing to loose, you will always win. Averaging down losers can carr...
David You're always safer going Long especially with averaging down on an index as the probability...
Oskar Bergvall  I noted Davids and Nicolas remarks. Could it be possible to make an indicator for contraria...
Krallenmann Hallo Nicolas, kannst du mir die Regeln für den Halftrend Indikator sagen? Aus dem Code kann...
davefransman Dear Nicolas, i want set a alert on the "HalfTrend "custom moving average" met Heikin Ashi w...
Nicolas Please post the question in a new forum topic, that would need custom coding I believe.
Lyam Pareil ne marche pas dommage
ahmedbouaziz89 Bonjour, quand j'ajoute le code ou le fichier dans l'outils screeners de Prorealtime je ne v...
tyvix Bonjour le code marche bien c est juste qu'il n y a pas d opportunité au moment ou vous le...
verdi55 Is there such a thing as a free lunch ?
maceng Thanks Nicolas for this great work! I would like to understand the math behind it in order t...
Nicolas Sorry I have no time to provide assistance for python programmers. Have a good day.
Maz Hi all, firstly happy to know that this is helping you. I look into updating it for PRT11 wh...
Nicolas just use 3 times a linear regression channel code you will find in the library.
leederbyshire Here's the link to alternative linear regression channel indicator Nicolas is referring to t...
Wing Yes, investigate as much as you want. For more insight, you can view the linet1, linet2 etc....
CKW Hi Wing, Thanks for your sharing. I am still trying to breakdown & understand your code...
Wing Hello CKW. No, the parameter, 7 in this case, is used when calling the RSI indicator to ide...
Nicolas You need to have enough bars loaded on your chart for the indicator to compute completely th...
verdi55 Working with separately calculated supertrend indicators in backtests is usually somewhat pr...
Nicolas Very interesting Verdi. Would be a great addition to the library, your own modified version ...
Nicolas Je vais faire l'indicateur et expliquer comment en même temps dans un sujet de forum. Plus s...
gregus merci nicolas toute ma gratitude est pour toi sa sera bien pratique car je pense ne pas etre...
Nicolas Ok merci donc d'ouvrir un sujet spécifique pour cette demande donc :) 
algotrader This indicator looks coolBut on attempt to use it for a strategy dev'I get an error.."The in...
dajvop @algotrader if you at the bottom of the code add: RETURN Buffer1 as "up", Buffer2 as "down",...
Bateson Si cela peut servir, l'indicateur Sadukey a été créé en utilisant un générateur de filtre ap...
danhei Hi I am tryong to figure out how trist strategy works. I am new to pro real time. Can some...
Plop61 Hello,Thank you for sharing this beautiful strategy.Is it possible to indicate the code for ...
NoName Thank you very much for this fascinating trading system. It is still proving to be extremely...
DANY I did it on demo account; it's too dangerous for mea and I can not resist psychologically  ....
demoz How can a demo account be dangerous? Did you have it run live (on a demo account for exampl...
DANY Yes, I mean that I tried on a demo account for 2 months and it had work fine, like the BackT...
Nicolas
9 years ago
ALMA MACD
ALMA MACD
7
Indicators
Arnaud HALVICK Great indicator, thank you!
JMat45 Hi Nicolas, just reviewing this indicator and noticed that you have double assigned the vari...
Nicolas That would not make any difference because the code is read from top to bottom.
MikeGC I don't know if you have used the variables a and b to optimise the parameters for the Super...
gianpiero75 I have not optimized, I multiplied the parameters for 6 (5,8), to use them on the 4  hoursTF...
bertrandpinoy bonjour Mike j utilise TrendChaser V2.0 et quand il prend position cela ne programme pas le ...
eisi If i switch between different Markets, the Backgroundcolour will appear where it should not...
datageek How can I get alerts on colour change?
NAMBO40 Hello, I would like to add a 25 period SMA moving average. It's possible?
Fabio Anthony Terrenzio this strategy works only in a well defined trend
brosly Good afternoon I am trying to get the complete code of lex strategy made by adolfo since I s...
dreif123 hi Adolfo, is Alex Auto Trading Botindex working on DAX as well ? if so , can you post the...
Doctrading I forgot to write at the beginning :  a = 50 b = 50 These are intermediate levels Sorry
DerPat Thank you. This one could be an aid in my current research on stochastics.
Pelayo it is possible that in line 12 we should put seuilinf=-b, thaks for all
avatar
Anonymous We try to enter before that the market actually turn. We try to anticipate it. In which way ...
dwgfx David-1984 are you saying that you've already factored in the spread within the code?  If y...
avatar
Anonymous no, not in teh code... only in the backtest. The entry is only between 8/22 so the spread fo...

Top