Adaptive ATR Limits

This indicator plots adaptive ATR limits for intraday trading. A key feature of this indicator, which makes it different from other ATR limit indicators, is that the top and bottom ATR limit lines are always exactly one ATR apart from each other (in "auto" mode; there is also a "basic" mode, which plots the limits in the more traditional way—i.e., one ATR above the low and one ATR below the high at all times—and this can be used for comparison).
█ FEATURES
- Provides an algorithm to plot the most reasonable intraday ATR top/bottom limits based on currently available information
- Dynamically adapts limits as the price evolves during the day
- Works correctly and consistently on both RTH and ETH charts
- Has a user-selected ADR mode to base the limits on ADR instead of ATR
- Option to include the current pre-market and previous day's post-market range in the calculation
- Configurable ATR/ADR averaging length
- Provides a visual smoothing option
- Provides an information box showing the current numerical ATR/ADR values
- Reasonable defaults that work well if the user changes nothing
- Well-documented, high-quality, open-source code for those interested
█ HOW TO USE
At a minimum, there is nothing that needs to be set. The defaults work well. The ATR top line (red, configurable) gives you the most reasonable move given the currently available information. The line will move away from the price as the price approaches it; that is normal—it is reacting to new information. This happens until the ATR bottom limit hits the lower of the daily low and the previous day's close (in ATR mode). The ATR bottom line (green, configurable) works the same way, with reversed logic.
There is an option to use ADR instead of ATR. The ATR includes the previous day's RTH close in the range, whereas ADR does not. Another option allows the user to add the current day's pre-market range or the previous day's post-market into the current day's range, which has an effect if either of those went outside of today's RTH range, plus yesterday's RTH close (in the default ATR mode). Pre-market and post-market range is not typically included in the daily true range, so only change it if you really know you want it.
█ CONCEPTS
Most traditional ATR limit indicators plot the top ATR limit one ATR above the current daily low, and the bottom ATR limit one ATR below the current daily high. This indicator can also do that (in "basic" mode), but its value lies in its default "auto" mode, which uses an algorithm to dynamically adapt the ATR limits throughout the day, keeping them one ATR apart at all times. It tries to plot the most sensible ATR limits based on the current daily ATR, in order to provide a reasonable visual intraday target, given the available information at that point in time.
"Auto" mode is actually a weighted average of two methods: midpoint and relative (both of which can also be explicitly selected). The midpoint method places the midpoint of the ATR limit equal to the midpoint of the currently established daily range. The relative method measures the currently established daily range and calculates the position of the current price within it (as a ratio between 0 and 1). It then uses that value as a weight in a weighted average of extreme locations for the ATR limits, which are: the ATR top anchored to one ATR above the daily low, and the ATR bottom anchored to one ATR below the daily high.
The relative method is more advanced and better for most of the day; however, it can cause wild swings in the early market or pre-market before a reasonable range (as a percentage of ATR) has been established. "Auto" mode therefore takes another weighted average between the two methods, with the weight determined by the percentage of the ATR currently established within the day, more strongly weighting the calmer midpoint method before a good range is established. Once the full ATR has been achieved, the algorithm in "auto" mode will have fully switched to the relative method and will remain with that method for the rest of the day.
To explain the effect further, as an example, imagine that the price is approaching the full ATR range on the high side. At this point, the indicator will have almost fully transitioned to the second (relative) method. The lower ATR limit will now be anchored to the daily low as the price hits the upper ATR limit. If the price goes beyond the upper ATR, the lower ATR limit will stay anchored to the daily low, and the upper limit will stay anchored to one ATR above the lower limit. This allows you to see how far the price is going beyond the upper ATR limit. If the price then returns and backs off the upper ATR limit, the lower ATR limit will un-anchor from the daily low (it will actually rise, since the daily ATR range has been exceeded, so the lower ATR limit needs to come up because the actual daily range can’t fit into the ATR range anymore). The overall effect is to give you the best visual indication of where the price is in relation to a possible upper ATR-based target. Reverse this example for when the price low approaches the ATR range on the low side.
Care was taken so that the code uses no hard-coded time zones, exchanges, or session times. For this reason, it can in principle work globally. However, it very much depends on the information provided by the exchange, which is reflected in built-in Pine Script variables (see Limitations below).
█ LIMITATIONS
The indicator was developed for US/European equities and is tested on them only. It is also known to work on US futures; in this case, the whole 23-hour session is used, and the "Sessions to include in range" setting has no effect. It may or may not work as intended on security types and equities/futures for other countries.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
or (made money using my indicators)
buymeacoffee.com/bruz
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
or (made money using my indicators)
buymeacoffee.com/bruz