ATR Multiple Detection from the Moving Average

ATR Multiple Detection from the Moving Average

1. Introduction

In technical analysis, one of the main challenges is to identify moments when the price of an asset deviates significantly from its average behavior, which can generate trading opportunities. To achieve this, we combine the use of the Average True Range (ATR) and a moving average (MA) to create an indicator that allows us to measure market volatility and detect potential points of reversal.

The ATR is a classic tool used to measure the volatility of an asset, and the moving average is widely known for its ability to smooth price and show the general trend. This indicator, which we will call “ATR Multiple Detection from the Moving Average”, is based on calculating the percentage gain or loss from a moving average and comparing it to the ATR value, also expressed as a percentage. From this, we can identify when the price has reached a significant multiple of the ATR relative to the moving average.

This approach allows traders to identify moments when the price is far enough from the moving average to anticipate a trend change, making it very useful for those looking to trade during high volatility moments.

2. Indicator Fundamentals

This indicator is based on three key elements:

Moving Average (MA)

The moving average is one of the most commonly used indicators in technical analysis. It is calculated by averaging the closing prices of a specified number of bars. In this case, we use a configurable moving average that allows you to adjust the period length (by default, 50 periods) and the type of moving average, whether simple, exponential, or any other type the user prefers.

Average True Range (ATR)

The Average True Range (ATR) is an indicator that measures market volatility. It is calculated as the average of the true ranges over a specified number of periods. The ATR gives us insight into how volatile the price of an asset is, which is useful for anticipating sharp market movements.

Price-to-MA Relationship

The indicator also calculates the percentage gain or loss from the moving average, giving us an idea of how far the current price is from its average. This relationship is expressed as a percentage and is later compared to the ATR.

3. Detection of ATR Multiples from the MA

The detection of ATR multiples is the core of this indicator. Essentially, this indicator compares the percentage difference between the current price and the moving average with the ATR value, and determines how many times the ATR is contained in that difference. If this multiple exceeds a value defined by the user (default: 10 times), the indicator flags a key point on the chart.

The calculation steps are as follows:

  1. Calculate the % Gain from the Moving Average:
    • The difference between the current price and the moving average is measured and expressed as a percentage. This tells us how much above or below the current price is relative to its moving average.
    • Formula: gainFromMA=round((close/ma-1)*100,2)
  2. Calculate ATR as a Percentage of Price:
    • The ATR is calculated as a percentage of the current price. This tells us how much the ATR represents in relation to the price.
    • Formula: pctATR=round(atr/close*100,2)
  3. Ratio of Gain to ATR:
    • Finally, the percentage gain relative to the moving average is compared to the ATR percentage to obtain a multiple. This multiple indicates how many times the ATR fits into the percentage difference between the price and the MA.
    • Formula: atrMultFromMA=round(gainFromMA/pctATR,2)

When this multiple exceeds the defined value (by default, 10 times the ATR), the indicator marks a visual point on the chart, indicating that the price has reached a significant deviation level relative to its moving average.

4. Indicator Configuration

The indicator includes three adjustable parameters that the user can configure based on their trading preferences:

  • matype (moving average type): This parameter allows you to choose the type of moving average to be used. The most common types are the simple moving average (SMA) and the exponential moving average (EMA), although ProRealTime offers several additional types.
  • maLength (moving average length): This parameter defines the number of bars used to calculate the moving average. The larger this value, the smoother the moving average will be, as it will include more historical data.
  • multipleAtr (ATR multiple): This parameter defines how many times the ATR value must exceed the ratio with the MA for a signal to be marked on the chart. A high value makes the indicator more sensitive to large price movements, while a lower value detects smaller movements.

These three parameters offer great flexibility to customize the indicator according to the user’s trading style, whether it’s a conservative or more aggressive approach.

5. Chart Visualization

The indicator provides a clear and concise visualization of key points on the chart, making data interpretation easier.

  • Detection Points: When the ATR multiple exceeds the set value, the indicator plots a point on the chart at the top of the current bar. This point appears in “fuchsia” color to visually highlight the moment of interest.
  • Informative Texts: In the lower-right corner of the chart, the indicator displays texts with detailed information about the current values:
    • % Gain from MA.
    • ATR in %.
    • ATR Multiple from MA.

These texts allow the user to have a clear idea of how the key metrics are behaving in real-time, without the need for additional calculations.

6. Conclusion

The “ATR Multiple Detection from the Moving Average” indicator is a powerful tool for detecting moments of high volatility and potential reversal points in the markets. By combining the ATR with a moving average, traders can effectively identify when the price has deviated significantly from its average, which can signal a trading opportunity. Additionally, its customization capabilities through various parameters make it useful for a wide variety of trading styles, from scalping to swing trading.

This indicator is especially recommended for traders looking to take advantage of sharp market moves, where volatility plays a key role in identifying opportunities.

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. P. Marlowe • 174 days ago #

    Muy bueno. ¿Podría hacerse para señalar extremos por el lado bajista? Lo mismo a la inversa. Las estrategias de reversión a la media son muy eficaces, gracias como siempre.

  2. Miro • 169 days ago #

    Esta es una versión del indicador, para ambos extremos.
    //———————————————//
    //PRC_ATR% multiple from MovingAverage
    //version = 0
    //24.10.2024
    //Iván González @ http://www.prorealcode.com
    //Sharing ProRealTime knowledge
    //———————————————//
    //—————Inputs————————//
    //———————————————//
    //matype=0
    //maLength=50
    //multipleAtr=10
    //———————————————//
    //————-Moving average——————//
    //———————————————//
    ma=average[maLength,matype](close)
    //———————————————//
    //————-Average True Range————–//
    //———————————————//
    atr=averagetruerange[14](close)
    //———————————————//
    //——-% Gain From Moving Average————//
    //———————————————//
    gainFromMA=round((close/ma-1)*100,2)
    gainFromMAb=round((ma/close-1)*100,2)
    //———————————————//
    //——-% ATR———————————//
    //———————————————//
    pctATR=round(atr/close*100,2)
    //———————————————//
    //——ATR % Multiple from Moving Average—–//
    //———————————————//
    atrMultFromMA=round(gainFromMA/pctATR,2)
    atrMultFromMAb=round(gainFromMAb/pctATR,2)
    //———————————————//
    //———–Multiple ATR Detection————//
    //———————————————//
    if atrMultFromMA>=multipleAtr then
    drawpoint(barindex,high+atr,2)coloured(“fuchsia”)
    endif
    if atrMultFromMAb>=multipleAtr then
    drawpoint(barindex,low-atr,2)coloured(“red”)
    endif
    //———————————————//
    //————-Data last candle—————-//
    //———————————————//
    if islastbarupdate then
    drawtext(“% Gain From MA = #gainFromMA#”,-200,100)anchor(bottomright,xshift,yshift)
    drawtext(“ATR% = #pctATR#”,-200,75)anchor(bottomright,xshift,yshift)
    drawtext(“ATR% Multiple from MA = #atrMultFromMA#”,-200,125)anchor(bottomright,xshift,yshift)
    endif

    return ma as “Moving Average” coloured(“blue”)

  3. P. Marlowe • 166 days ago #

    Muchas gracias ¡¡

avatar
Register or

Likes

avatar avatar avatar avatar
Related users ' posts
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.
julien1978 The ADR value that is plotted intraday does not match the value of the regular ATR indicator...
Fab666 I've tried to get a fix for this also but no luck, it doesn't print the correct data as far ...
Seabiscuit Hi! With the new PRT update, this indicator does not work anymore
Sofitech Ce code n'est valable que sur la V10.3 ? sur le 10.2 il y a une erreur de syntaxe dans le fi...
Nicolas Oui en effet, c'est un indicateur "10.3" à cause uniquement de la mise en forme des courbes ...
Nicolas En effet, c'est le cas si on copie/colle le code. Ces 2 variables sont inscrites en externes...
Salocin Hello Nicolas, my french is not that well. It occurs an error which can not be solved by cop...
Nicolas Just download the ITF file and import it into your platform, follow these easy steps: https:...
Nicolas
8 years ago
Holt EMA
Holt EMA
1
Indicators
robertanthonyuk Hi,What do the each colour represent? Rob
Nicolas You'll need to preload bars to get the good calculations of you indicators. I did not test i...
David Nicolas I tried DEFPARAM Preloadbars = 5000 And still the same drawn output of entries/exit...
marcara Hi, Thank you very much for the Moving Average Daily indicator, I am using it as indicator i...
Nicolas Je l'ai converti depuis un code pinescript. De mémoire il s'agit bien d'une variation d'une ...
Captain_Walker @Nicolas, I've copied your code into PRT indicator panel to create it. When I attempt to sav...
Nicolas Download the itf file and import it.
Nicolas Please post any question on forums, thanks.
Lavallette Bonjour Nicolas. J'utilise la version 11 et moi aussi j'ai une ligne horizontale malgré l'a...
Nicolas il faut modifier la ligne 20 avec: if adaptive=1 and averagePeriod > 1 and barindex>(...
dakaodo Hi, Wilko. Acc to the original FRAMA paper by Ehlers, Ehler's own code only takes inputs for...
dakaodo For reference, here is Ehlers' original paper: http://www.mesasoftware.com/papers/FRAMA.p...
dakaodo Here is the code with only SC included, per ETFHQ. pri=customclose //len>=4, even on...
Guibourse Hi ! I am asking once again for your help : would it be possible to use the ATR as a "take p...
Tradingrob Many thanks for the indicator, however if the price is below the indicator, then the indicat...
aldtrading Merci pour ton travail ! J'ai de bons résultats en utilisant cet indicateur
Nicolas The code is correct, don't know if the label and color are the same as other trading softwar...
peppe novellino Hi Nicolas, the settings of the alligators are not editable. How can I change it? Thanks in ...
pabo_swe I got very bad performance with this script, it was slow... it seems like if one breaks out ...
Nicolas Use the wrench of the price chart! Upper left of the window
Dymjohn The wrench shows options for the components of the indicator not how to show in the main cha...
Nicolas http://www.prorealcode.com/topic/overlapping-indicators/  
bluetime6 Hello Doctrading.   Can you ask you for something? Can you code a screener screen po...
gianlox I added a simple momentum indicator (MACD). I think much better results:   achat = 0v...
gianlox achat = 0 vente = 0 MACD12M = MACDline[12,26,9](close) MACD12S = ExponentialAverage[9](MA...
Nicolas Thank you for contribution. Please consider that advertising is tolerate as long as you cont...
triss1965@gmail.com  Hi, I cant make it work. And if you doing so much money. Why do you have to sell it? It don...
T-rader Eva... He dosen´t sell anything. He is just a nice guy that want to share on of his strategy...
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...
phili711 Bonjour Si la moyenne 100 est au dessus de la moyenne 20 le trend est baissier zlors pourqu...
Nicolas La comparaison se fait entre la valeur de la moyenne actuelle et telle qu'elle était il y a ...
Thomas007 we should definitely open a new thread for intraday trading - can we post the link once it's...
Denis Bonjour Nicolas, j'ai une question à propos de ce code, il faut que je la pose en anglais ca...
Nicolas En français pas de problème

Top