Adaptive ATR-ADX Trend

v10.3
Adaptive ATR-ADX Trend

Constructs the trailing ATR stop above or below the price, and switches
directions when the source price breaks the ATR stop. Uses the Average
Directional Index ( ADX ) to switch between ATR multipliers. The higher
multiplier is used when the ADX is rising, and the lower ATR multiplier
is used with the ADX is falling. This ADX criteria further widens the gap
between the source price and the trailing ATR stop when the price is trending,
and lessens the gap between the ATR and the price when then price is not
trending.

The ATR-ADX stop is effectively a double adapative stop that trails the price,
by both adapting to the true range of the price, and the average directional
change. When the stop is below the price (long trade) the value never decreases
until the price intersects the stop, and it reverses to being above the price
(short trade). When the stop is above the price it will never increase until
it is intersected by the price. As the true range and ADX change, the stop
will move more quickly or more slowly.

First, if the ‘Above Threshold’ box is checked,the falling (smaller) multiplier
will be used regardless once the ADX rises above a certain threshold (default > 30).
The ATR will effectively rise faster once the price enters ‘very trendy’ mode.
Typically, ADX > 20/25 is used in classic ADX trading (which I have found
unprofitable through backtesting). The idea behind this extra multiplier criteria
is that once the price starts trending ‘very’ well, a top/bottom is likely near,
and when that top comes the price will quickly rebound. Experienced traders know
exactly what I am describing. Play around with an ADX/DI indicator using this
stop system in tandem and it will be found that many successful trades are entered
when the market is not trending (i.e. < ADX < 25), and exited once/if the price
enters ‘very trendy’ mode above 30 and the ATR changes (stopped out).

Second, heiken-ashi bars can be introduced to the ATR stop system. This is the same
thing as just switching the chart to Heiken Ashi mode, but without having to change
the plotting type. I find this useful, so that things like pivot lines can be
preserved to their correct calculations, while the benefit of heiken ashi bars can
still be enjoyed. Be advised that with each tinkering that extends the life of the
ATR trend, the odds of that same trend changing near the top/bottom are reduced,
so as always there is a trade-off to maximize the time spend in a trade and nailing
a top or bottom.

Third, Different source prices can be used. I have found that HLC3 is best because
it keeps the price from being stopped out in very key areas, set as the default.

Fourth, alert conditions are introduced so that the trader can be warned when the
ATR-ADX changes. These can be used by right clicking the strategy and clicking
“Add Alert…”. Reference the bottom of the script for the names of the alert
conditions.

(original code and description from its author: mortdiggiddy, all credits goes to him).

Code translated from TradingView (pinescript) code by a request in the english forum.

 

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. Pepsmile • 06/29/2018 #

    Thanks Nicolas !

  2. Demon • 06/29/2018 #

    Merci beaucoup pour cette contribution au catalogue des stops.

  3. stefou102 • 06/29/2018 #

    Thx Nicolas! trying to test this indicator in an automated strategy but I’m becoming crazy because when I call the indicator and then simply Graph it in the chart result, there is a discrepency in the value of the indicator vs it’s “called” version in the strategy. How is that possible? In the strategy I’m calling it via the command

    • Nicolas • 06/29/2018 #

      In this case, I suggest to add the indicator’s code directly into your strategy.

  4. stefou102 • 06/29/2018 #

    mystoploss=call “Adaptative ATR-ADX”(MedianPrice)
    GRAPH mystoploss as “Adapt”

  5. schilds • 06/29/2018 #

    Nicolas, Could you explain lines 35, 37 and 38 please. Unless I’m missing something they can result in a division by zero attempt.

    • Nicolas • 06/29/2018 #

      Should not if adxlen variable is superior to 0.

  6. AussieTrader • 06/29/2018 #

    Nicolas, Can you explain the numerator logic – e.g. Line 35 is (sTR[1] – sTR[1]) which would appear to be either null or zero.

    • Nicolas • 06/29/2018 #

      You are right, this is useless. Since I converted it from another programming language, I assume it was in the original code…

  7. Ass13 • 06/29/2018 #

    bonjour nicolas j’aime bcoup votre indicateur

  8. bharatjai • 06/29/2018 #

    Script ‘Adaptive ATR’ has been saved
    line 24: no viable alternative at input ‘lr’

    Getting above error. Please help to resolve the same.

    • Nicolas • 06/29/2018 #

      download the itf file and import it into your platform.

  9. Francis3332 • 14 days ago #

    Bonjour à tous,
    J’aime beaucoup cet indicateur et j’aimerais pouvoir l’utiliser sur la dernière version de prorealtime V12 avec l’option “Utiliser une autre pèriode” cad pouvoir, par exemple, visualiser l’indicateur en 3mn sur un graph 2mn.
    Quelqu’un pourrait-il m’aider ?
    Merci d’avance.
    Bonne journée.
    Fran6

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+20 more likes

Related users ' posts
AGTrader Interesante, muy visual Doc. Felicidades!!!
Andraxx simplemente impresionante Dom...te sigo en youtube. Me ha gustado tu canal. Gracias por comp...
Steven Hi im looking for some help to put a automated code together BUY ORDER If EMA 10/25 is...
Dwell Thank you! Great tool!
odin hi luisella, i think breadth indicators a not available in pro realtime, because you the cal...
4example Thank you
Gaby333 to good to be true dosent do anything))
Caribeengeek Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Mai...
Caribeengeek Les devises unité
Nicolas Merci d'utiliser le forum pour les demandes de programmation personnalisée
Toto le Heros Thanks Nicolas. I read somewhere that in the calculation, we should round the value of the A...
Nicolas aADX = round(adx[10])
jebus89 Big thanks for sharing this :) Seems to work as expected, good stuff.
swapping merci gabri, on va le mettre à l'essai ;)
GraHal Please forgive the daft question, but why is 3-bars-trailing-stop-williams-3.itf included a...
Kris75 Hi, Seems great but what would be the code for a stock ? Thanks, Chirs
oakenstream Paul, what is the best way in your opinion to know if I have over optimized?
Marc Boliart dear nicolas, tyvm for your indicators and strategies, i have this following error when i ch...
Nicolas Your picture is too small, but for sure the problem is about the fact you are still using v1...
Rory Dryden Thanks. This looks useful.
edocasa CIAO , SCUSA SE TI CONTATTO,VOLEVO SAPERE SE SEI UN PROGRAMMATORE,NELCASO SE SARESTI DI...
gabri Non sono un genio ma so fare qualcosa. Posso provare ad aiutarti ma se e' troppo complicato ...
Vinks_o_7 I looked at your page: It's written: Method 2: Current High less the previous Close (absolu...
gabri You are right, I will change it, Thank you!!
Vinks_o_7 Nope...I THANK YOU FOR ALL THE GOOD WORK YOU DID ;-)
WarningTrading Comment peut on la comparer ? comme ceci ? cela ne me donne plus le message d'erreur manque...
sally31120 Bonjour, je n'arrive pas à créer ce screener close > supertrend extended2[1] la réponse...
Nicolas voir ce sujet pour un screener basé sur Supertrend Extended: https://www.prorealcode.com/top...
gabri Agree. Many of those indicators are using very similar ideas. ADX is a very powerful and und...
Marcel But still it is a (lagging) derivation of price itself.
gabri All the indicators are lagging because they are all based on historical data.
flodefacebook Merci Nicolas pour cet indicateur. Très utile dans une technique de retournement.
HeikinAshi thank you for this very interesting indicator Nicolas! did you define a tradable setup fo...
JanWd Tried the code, nice concept, seems to work quit well for US/EUR 2hrs, Other markets seems n...
JR1976 Simple and nice code , congrats !!! Seems work well with TIme frame 1 h
phanz Hi all, Sorry revisiting an old post. This algo is simple, and simplicity is the ultimate ...
Mr_Balagan Bonjour, j'ai quelques questions concernant cette combinaison d'indicateurs qui à l'air inté...
larouedegann STE : Fonction statistique "erreur standard" de séries temporelles de N périodes pour le pri...
Mr_Balagan Merci pour ces informations précieuses larouedegann. J'y vois plus clair. Encore joli boulot
Kris75 Hi Gabri I launched a very simple strategy based on the 3 bars trailing stop that you cre...
TimDeCat Hi. Has anyone coded a version that you could alter it to say 5 bar trailing stop? ie make ...
Nicolas Please open a new topic in forums so we can code it there, thanks.

Top