About Moving Average Deviation Rate (Kairi)
Unlike deviation rate tools that use fixed levels such as ±2% or ±10%, Moving Average Deviation Rate (Kairi) sets the levels from the chart's own past and shows them on the price chart as well as below it.
How it works
- Distance from the MA, in the unit you choose: Percent ((close − MA) ÷ MA × 100, the classic deviation rate), ATR ((close − MA) ÷ the ATR of the previous bar) or Pips (forex, gold and silver; price on other markets).
- Levels: the distances of the last 3,000 bars are ranked, bars above the MA and bars below it separately. Stretched is farther than 90% of them and Extreme farther than 98% (both settings). Each bar is compared only with the bars before it.
- Moving averages: SMA, EMA, SMMA (RMA), WMA, HMA and VWMA, on the chart timeframe or a higher one. A higher timeframe MA is built from its completed bars and the current price, so past bars show the MA as it was at that time.
- The Stretched and Extreme prices are solved for the current bar, including the move in the MA that the same close would cause.
On the chart
- The MA on the price chart: gray when normal, green when stretched above, red when stretched below, thicker when Extreme.
- Top right: the distance and its state, for example "0.41% above SMA 20", how it ranks against past bars, and the Stretched and Extreme prices.
- Dashed lines at the Stretched and Extreme prices, on the side of the MA the price is on now.
- Below the chart: the distance with the Stretched (dashed) and Extreme (solid) levels. The part beyond a level is filled.
- Colors can be changed. Every part can be turned off.
Alerts
Use the "Any alert() function call" condition. Stretched, Extreme, Back to normal and MA cross (the last two are off by default). Sent at bar close.
Notes
- The levels need 50 past bars on each side of the MA. Until then the summary says "Not enough past bars yet".
- With a higher timeframe MA, the MA and the distance move with the price until that timeframe's bar closes.
- VWMA needs volume.
How to add it
- 1Open the script page on TradingView with the button above (or here).
- 2Click “Add to favorites” on that page.
- 3On any chart, open Indicators, go to Favorites and click Moving Average Deviation Rate (Kairi) [Saikix].