ATR Bands with Optional Risk/Reward Colors█ OVERVIEW
This indicator projects ATR bands and, optionally, colors them based on a risk/reward advantage for those who trade breakouts/breakdowns using moving averages as partial or full exit points.
█ DEFINITIONS
► True Range
The True Range is a measure of the volatility of a financial asset and is defined as the maximum difference among one of the following values:
- The high of the current period minus the low of the current period.
- The absolute value of the high of the current period minus the closing price of the previous period.
- The absolute value of the low of the current period minus the closing price of the previous period.
► Average True Range
The Average True Range was developed by J. Welles Wilder Jr. and was introduced in his 1978 book titled "New Concepts in Technical Trading Systems". It is calculated as an average of the true range values over a certain number of periods (usually 14) and is commonly used to measure volatility and set stop-loss and profit targets (1).
For example, if you are looking at a daily chart and you want to calculate the 14-day ATR, you would take the True Range of the previous 14 days, calculate their average, and this would be the ATR for that day. The process is then repeated every day to obtain a series of ATR values over time.
The ATR can be smoothed using different methods, such as the Simple Moving Average (SMA), the Exponential Moving Average (EMA), or others, depending on the user's preferences or analysis needs.
► ATR Bands
The ATR bands are created by adding or subtracting the ATR from a reference point (usually the closing price). This process generates bands around the central point that expand and contract based on market volatility, allowing traders to assess dynamic support and resistance levels and to adapt their trading strategies to current market conditions.
█ INDICATOR
► ATR Bands
The indicator provides all the essential parameters for calculating the ATR: period length, time frame, smoothing method, and multiplier.
It is then possible to choose the reference point from which to create the bands. The most commonly used reference points are Open, High, Low, and Close, but you can also choose the commonly used candle averages: HL2, HLC3, HLCC4, OHLC4. Among these, there is also a less common "OC2", which represents the average of the candle body. Additionally, two parameters have been specifically created for this indicator: Open/Close and High/Low.
With the "Open/Close" parameter, the upper band is calculated from the higher value between Open and Close, while the lower one is calculated from the lower value between Open and Close. In the case of bullish candles, therefore, the Close value is taken as the starting point for the upper band and the Open value for the lower one; conversely, in bearish candles, the Open value is used for the upper band and the Close value for the lower band. This setting can be useful for precautionally generating broader bands when trading with candlesticks like hammers or inverted hammers.
The "High/Low" parameter calculates the upper band starting from the High and the lower band starting from the Low. Among all the available options, this one allows drawing the widest bands.
Other possible options to improve the drawing of ATR bands, aligning them with the price action, are:
• Doji Smoothing: When the current candle is a doji (having the same Open and Close price), the bands assume the values they had on the previous candle. This can be useful to avoid steep fluctuations of the bands themselves.
• Extend to High/Low: Extends the bands to the High or Low values when they exceed the value of the band.
• Round Last Cent: Expands the upper band by one cent if the price ends with x.x9, and the lower band if the price ends with x.x1. This function only works when the asset's tick is 0.01.
► Risk/Reward Advantage
The indicator optionally colors the ATR bands after setting a breakpoint, one or two risk/reward ratios, and a series of moving averages. This function allows you to know in advance whether entering a trade can provide an advantage over the risk. The band is colored when the ratio between the distance from the break point to the band and the distance from the break point to the first available moving average reaches at least the set ratio value. It is possible to set two colorings, one for a minimum risk/reward ratio and one for an optimal risk/reward ratio.
The break point can be chosen between High/Low (High in case of breakout, Low in case of breakdown) or Open/Close (on breakouts, Close with bullish candles or Open with bearish candles; on breakdowns, Close with bearish candles or Open with bullish candles).
It is possible to choose up to 10 moving averages of various types, including the VWAP with the Anchor Period (2).
Depending on the "Price to MA" setting, the bands can be individually or simultaneously colored.
By selecting "Single Direction," the risk/reward calculation is performed only when all moving averages are above or below the break point, resulting in only one band being colored at a time. For this reason, when the break point is in between the moving averages, the calculation is not executed. This setting can be useful for strategies involving price movement from a level towards a series of specific moving averages (for example, in reversals starting from a certain level towards the VWAP with possible partial take profits on some previous moving averages, or simply in trend following towards one or more moving averages).
Choosing "Both Directions" the risk/reward ratio is calculated based on the first available moving averages both above and below the price. This setting is useful for those who operate in range bound markets or simply take advantage of movements between moving averages.
█ NOTE
This script may not be suitable for scalping strategies that require immediate entries due to the inability to know the ATR of a candle in advance until its closure. Once the candle is closed, you should have time to place a stop or stop-limit order, so your strategy should not anticipate an immediate start with the next candle. Even more conveniently, if your strategy involves an entry on a pullback, you can place a limit order at the breakout level.
(1) www.tradingview.com
(2) For convenience, the code for the Anchor Period has been entirely copied from the VWAP code provided by TradingView.
Stops
AIR Supertrend (Average Interpercentile Range)Supertrend (ST) is a popular stop loss and trend identification script. The simplicity of seeing a clean trend on a chart makes it attractive, yet it is restricted by only allowing the source, length and multiplier to be adjusted, & these tend to have a limited effect on the properties of the identified trend.
There is a wide variety of interesting ST scripts on TradingView that give the user more control, but none to my knowledge, based on measuring the statistical dispersion of Average Interpercentile Range (AIR).
Two more levels of control:
Normally, ATR Average True Range is used to calculate the range in ST. ATR is initially calculated using RMA to smooth out True Range. This script gives the user the option of changing the MA to some more interesting varieties & modifying their parameters.
The default range setting when you load the indicator on a chart will be AIR.
The real strength of the indicator, however, and the reason I am publishing it, is to release AIR. Play round with the percentile range setting. Lowering it will allow you to stay longer in a trade in a volatile market. Raising it will make it tighter.
For comparison, you can switch back the range setting to ATR and load up RMA to see how the original, classic ST plots.
Alerts are included in this version. Alway use a stop loss.
DISCLAIMER: None of this is financial advice.
Credits to these authors, whose hard work inspired parts of this script:
@ KivancOzbilgic - SuperTrend
@ KioseffTrading - Tillson T3 MA
@ cheatcountry - Hann Window Smoothing
@ mutantdog - Interquartile Range function in his 'Blaze' script
ATR BandsIn many strategies, it's quite common to use a scaled ATR to help define a stop-loss, and it's not uncommon to use it for take-profit targets as well. While it's possible to use the built-in ATR indicator and manually calculate the offset value, we felt this wasn't particularly intuitive or efficient, and could lead to the potential for miscalculations. And while there are quite a few indicators that plot ATR bands in some form or another already on TV, we could not find one that actually performed the exact way that we wanted. They all had at least one of the following gaps:
The ATR offset was not configurable (usually hard-coded to be based off the high or low, while we generally prefer to use close)
It would only print a single band (either the upper or lower), which would require the same indicator to be added twice
The ATR scaling factor was either not configurable or only stepped in whole numbers (often time fractional factors like 1.5 yield better results)
To that end, we took to making this enhanced version to meet all of the above requirements. While we were doing so, we decided to take this opportunity to also make some non-functional enhancements as well:
Updated the indicator to the most recent version of Pine
Updated the indicator definition to allow alternate (non-chart) timeframe usage
Made the input types explicitly defined to improve consistency
Updated the inputs with appropriate minimum values and step sizes where appropriate
Separated settings into logical groups
Added helptext to the indicator settings noting usage and common settings values
Explicitly titled the on-chart plots of the ATR bands so that they can more easily be identified and referenced in other indicators/scripts, as well as the Data Window
Food for thought : When looking at some of the behaviors of these ATR bands, you can see that when price first levels out, you can draw a "consolidation zone" from the first peak of the upper ATR band to the first valley of the lower ATR band that price will generally respect. Look for price to break and close outside of that zone. When that happens, price will usually (but not always) make a notable move in that direction, which can be used as either a potential trigger or as an additional confluence with other indicators/price action.
Finally, while we have made what we feel are some noteworthy updates and enhancements to this indicator, and have every intention of continuing to do so as we find worthy opportunities for enhancement, credit is still due to the original author: AlexanderTeaH
Trailing StopMost of the trailing stops on TradingView are made of using the lowest lows and the highest highs. Not many are based around what I called the volatile trailing stop.
This is where the trailing stop will move around according to a set percentage difference from the previous closing value. This allows you to say "If the current bar moves x percent, then stop". The script I've made here is a simple version of that with a few options for smoothing and setting the percent change.
Disclaimer: This is not financial advice, please do your own research before making any decisions.
Tiger's Stop - Objective Stoploss SettingTrading is a lot about risk management too. I created this script to help with setting and moving a proper stop-loss. It plots an area that is a result of adding and subtracting both average true range and something I call "false range".
►The Average True Range is calculated as the candle's high-low. If there is a gap, it is added to complete the result.
►My own False Range just candle bodies. It is calculated as an absolute value of (close-open).
Then, Rolling Moving Average is applied on both ATR and False Range to get an idea of how far the price tends to extend out of pure randomness. The resulting value is multiplied by a Multiplier.
The next step is an addition of the values to the higher part of the candle for short or a lower part of the candle for long. I prefer a special calculation instead of using Highs and Lows because it allows for more precise observation and stop-loss set up for less wicky symbols.
►►►Additional Functions
• Smoothing - applies moving average to candles from which range distance is calculated. This can achieve good smoothness but higher values will lead to using outdated price in the SL area calculation.
• Enable/Disable - if you know the direction you are going to trade in, it is good to disable either Long Stop-Loss Area or Short Stop-Loss Area. Just untick it in the settings.
►►►Actual Using
Before using the script to set your stop-loss, check the historical data and find a similar set-up. Is it engulfing you use as a trigger? Find a different one and see how effective the stop-loss based on the ATR*multiplier was. This will help you to optimize Multiplier value. A picture shows such research for a double top. You should find more similar situations to find an optimal value.
Ultimately, the indicator still gives you relatively a lot of freedom with your stop-loss settings (at least, that is with the default settings). You need to decide how loose stop-loss you want to set. Average True Range is the furthermost part which will make for a very large stop-loss, on the other hand, False Range might be triggered by a villainous wick unnecessarily. The choice should depend on the specific symbol you trade and perhaps, you will learn to set stops regardless of the indicator.
A little trick : 1. You can set the loosest stop-loss and set a TradingView alert for where the tightest stop-loss would be. When alerted, you will get the opportunity to reconsider the trade and take a loss if needs be or exit if a candle closes there. 2. Mostly for cryptocurrencies, you can set the tightest stop-loss to protect yourself from sudden spikes. If the price approaches it slowly enough, you can move the stop-loss to the further part of the channel. This is not the same as moving stop-loss indefinitely with hopes of reversal if you plan it from the beginning and a smaller stop is meant to protect you from spikes that are not always predictable and drive to both directions.
►►►Advantages of trailing stop-loss
I usually stick with my original stop-loss instead of moving to break even. If my entry area was functional support once, it may work again and is, therefore, still a good entry zone. But an alternative used to preserve as much of the profit as possible is trailing.
Trailing is setting a specific value in ticks or a calculation of how to move the stop-loss whenever the price moves in your favor. Tiger's Stop can be used this way. Whenever there is a new value as the candle closes and that value is closer to price than your current stop-loss, you can update it. However, if it moves further from your price, don't change the stop-loss. This can be a little tiresome if you do it manually but should be worth the effort.
I usually start trailing only after the price moves significantly in my favor that allowing it to return to the entry price would not make any sense.
►►►Feedback and optimization
The preview chart is chosen entirely at random and the values are not optimized for any specific symbol. If you opt to use it, let me know which values work for you the best, I'll add it to the description when I update it.
Furthermore, let me know if you think any sort of alerts would be useful with my script.
Good luck!
Stop Loss PanelHere is a label panel that shows the stop-loss number for Long or Short trades based on volatility using average true range and and a mult of that.
Trailing SL Alerts [QuantNomad]It's alerts version of my Trailing SL strategy:
Use "Once Per Bar" param when creating alerts.
Maximum True RamgePlots the the highest true range for the entire dataset.
Beneficial for determine an emergency stopp loss.
Market Adaptive Stop-LossI realized that the zone changes in the stoploss remained slow, so I couldn't make enough use of the characteristics of technical indicators when opening positions.
This pushed me to keep stop-loss under the influence of a dependent variable.
This script helped me a lot (everget) :
I've redesigned the stop-loss to be affected by intersections.
Therefore, this script is also suitable for adaptive moving averages, fractional periods.
Script features:
1.You can select calculation methods created by using various technical analysis methods from the scripts' settings:
-Moving Average Convergence Divergence ( Macd )
-Stochastic Oscillator ( Stoch )
-Stochastic Relative Strength Index (StochRSI)
-Stochastic Money Flow Index (StochMFI ) (More info : )
-Know Sure Thing ( KST )
-OBV ( On Balance Volume )
-SMA ( Simple Moving Average )
-EMA ( Exponential Moving Average )
-FISHERTRANSFORM ( Fisher Transform )
-AWESOMEOSCILLATOR( Awesome Oscillator )
-PSAR ( Parabolic Stop and Reverse - Parabolic SAR )
-HULLMA( Hull Moving Average )
-VWMA ( Volume Weighted Moving Average )
-RMA (Moving Average using in Relative Strength Index calculations.)
-COG (Center of Gravity )
-ACC-DIST ( Accumulation / Distribution Index )
2 - The region is determined according to the above calculation methods and if it is larger or smaller than the previous stop loss level.
And if the price in the negative zone is lower than the stoploss, it is the exact signal and is shown with more highlighted colors.
And, in the positive zone, where the price is greater than the stoploss, the trade zones are certain.
Shown with more highlighted colors.
If the zones are correct but stop-loss is not suitable for opening positions:
In other words, if the stop-loss is above/under the highest-lowest levels in the positive zone or if the stop loss is located in the lower zone in the negative zone, these zones are shown to be darker and dimmed so that they do not cause false movements.
*** SUMMARY : As a result, you can use this script with support and resistances,and trend lines to get good results.
I hope it helps in your analyzes. Best regards.
Kase Dev Stops The Kase Dev Stops system finds the optimal statistical balance between letting profits run,
while cutting losses. Kase DevStop seeks an ideal stop level by accounting for volatility (risk),
the variance in volatility (the change in volatility from bar to bar), and volatility skew
(the propensity for volatility to occasionally spike incorrectly).
Kase Dev Stops are set at points at which there is an increasing probability of reversal against
the trend being statistically significant based on the log normal shape of the range curve.
Setting stops will help you take as much risk as necessary to stay in a good position, but not more.
Average True Range Trailing Stops TFAverage True Range for trailing stops, can be set to any timeframe independently of currently-displayed timeframe
This indicator is derived from
but more customizable.
Many thanks to HPotter for the original version
ATR SL Visualization (on chart)This indicator plots 2 sets of dots (and lines) based on your chosen ATR multiplier (Average True Range).
Generally, when trading on the daily timeframe a good rule of thumb is to use the ATR * 1.5 (the default setting of this indicator).
I created this indicator to quickly test other indicators but I also find it helpful in live trading.
How to use this indicator:
Your trade system provides an entry signal. The red dot (can be connected line in options) would be used as the stop loss for either a long or short.
Then the dot on the other side would be your first 1:1 target.
The blue line is the same ATR multiplier as a target (default but can be modified).
Using an additional tool like the horizontal ray can be helpful to see the exact location the SL might be hit or where the target might hit.
When drawing your ray ensure you’re using the right entry candle.
For instance, in a long scenario you would typically be entering a trade after your signal candle closes. So draw the ray at the point in price on the next candle for both stop loss and target.
Also use these dots (lines) as guides provides an easy way to plot SL and targets if you want to use the Long or Short tool.
For my trade systems I don’t use price targets (I exit when structure or indicators reveal to exit) but I do find it helpful to graph when testing. When something moves in my favor either the ATR or the ATR * 1.5 I take profit and typically move up my stop loss to break even or trailing.
The other strategy that could be possible but have not tested is as long as the SL is making a new high moving up a hard stop to the ATR SL each day the trade goes in your favor.
This should be obvious but if you want to use just the true ATR edit the multiplier to be 1.0
Average True Range (ATR %) Stop Loss CalculatorThis indicator takes the average of a series of ATR to calculate what I would consider an optimum stop loss placement represented in percentage (read below for full overview).
While the data is plotted what is most helpful are the actual numbers presented and for my charts I remove most of the plotting.
This indicator is most helpful on the daily timeframe but can be used for all timeframes such as the 4HR, 1HR or even 15M.
This indicator should not be used alone. It should be used in conjunction with proper price action analysis. It’s also a great indicator if you chart using Value Channels. Ideally you want your stop placement to be below at least one core Value Channel boundary range. In addition to standard support and resistance and some key moving averages the market respects. This also works best when trading with the prevailing BIAS of the instrument (bull or bear).
Cryptos: Generally, that means you’re buying on retracements that fit the end of a structured move. The other option is using this in a clear up trending market where the pull backs are clearly being supported with buying.
FOREX: I built another indicator for FOREX search: ATRPIPS with SL
WTI: Helpful but I have different rules for when I trade WTI. I rely upon VCs and diagnal VCs much more when trading this.
Equities: Helpful but with the increase of volatility as well as uncertainty of Bias of the market-- this should be used as more of a guide than
What is most important is the actual percentage numbers but I've found graphing 1-3 of the actual ATRs is helpful. The rest just uncheck the checkbox in the options.
Indicator Overview:
Value 1 - 3 Period ATR (maroon)
Value 2 - 7 Period ATR (green)
Value 3 - 30 Period ATR (blue)
Value 4 - 90 Period ATR (blue, bold)
Value 5 - 1 Period ATR (green)
Value 6 - 1 Period ATR (red)
Value 6 – Prime Stop Loss Placement (maroon). This is the average of all above ATRs multiplied by 1.5
Value 7 - Move Left (red). Experimental value. This is the difference between (prime stop loss) and 1 day period move. Two ways to use this value. Use as a tighter stop loss placement. The other option is to use as a retrace target for purchase and using the Prime Stop Placement value as you’re stop loss.
All ATRs use the LOW price of the period. After testing both the low and close I’ve settled on the low to capture the most volatility you will typically experience.
Once again, this indicator should be used in conjunction with your proven trade system.
Also, by knowing what the values are within the indicator you could just eye ball what would be the best stop placement depending on the ATR or 1 or 2 ATRs you find most represent the volatility of what you are trading.
I will be expanding on this indicator by bringing in average measured moves as well as volume analysis and most likely with color changes and modifications.
Background:
While using and refining my trade system I've noticed that most moves happen in 3 periods. So we start there. The 7 period is good for a 24 hour market such as crypto (although weekend trading can be a hit or miss) and to some extent FOREX. The longer periods of 30 & 90 are to smooth out the data set. The final value of the 1 period is to bring a little more recency to the calculation.
Why multiply the average by 1.5? I've found in my own trading and system I built to be the best placement (in conjunction with VCs) to ensure you're stop isn't to close and is within the instrument you are trading volatility .
I'm looking at making this more intelligent as well as take into account volume and structured moves.
ATR Pips with Stop LossThis indicator shares ATR pips and a calculated 1.5 x stop loss calculation.
1st number is ATR.
2nd number is ATR x 1.5 (a typical SL when trading daily time frame).
The plot lines are really not that important- it's the actual numbers.
What I do is uncheck the plot line checkboxes (ATR & SL) so it doesn't show up, that way I can reduce the indicator window.
This script is a modified script by ATR Pips . Kept the BB section for now as it might be useful, but doubt it.
Future updates:
- editable the multiple for SL
- static daily numbers (right now this shows the timeframe you are viewing, I'd keep that but add a static daily ATR so you have both)
Position Size for ATR Trailing StopThis indicator will calculate your position size, short or long, based on the ATR Trailing Stop indicator of mine, and are needed to be used together. General risk management suggests risking just 1 percent of your equity and using low leverage.
ATR Trailing Stop Bands [R] This is based on the Average True Range Trailing Stops Strategy by Sylvain Vervoort, coded on TV HPotter. I have added Bands to see potential short and long stop loss zones before the indicator signals to switch itself, also changed color on the main Trailing Stop based on whether it is short or long, added increased stop loss hunt protection by combining with my Wickiness indicator to add Wick Protection, based on either Average or Maximum Wicks, to prevent your stop getting wicked out. Experiment with different timeframes according to your trading style and how long you like to hold a trade. This indicator does not intend to tell you when to take profit, just how to place your stop to give you the best chance of not getting stopped out too early and to minimise risk by trailing it safely.
May you all never be stop hunted again.
WickinessThis script measures the maximum and average length of upper and lower wicks. While this can be used as a volatility gauge and to see if there is more support or resistance, it's primary use is to not get wicked out on stops, by adding one of these numbers to the the Moving Average or S/R level that one is using for a Stop, plus maybe a few points of buffer.
Double EMA with stop loss indicatorThis is an updated version of my previous stop loss script.
I've added a double EMA line and modified the stop as below;
In an uptrend....
1. a yellow dot will appear once it's time to move your stop. The yellow dot will display at the level of the stop loss. Place your stop 1 pip below the dot.
2. The yellow dot will only appear if a new higher low has formed and has been confirmed. Also the current candle must have broken the high of a previous bullish candle or the dot will not appear.
3. The dot will also appear if there is a likely reversal of the current trend.
Also works in downtrends.....