This script gives signal when the ATR% multiple from any chosen moving average is beyond the configurable threshold value. This indicator quantifies how extended the stock is from a given key moving average.
A lot of traders use ATR% multiple from 10DMA, 21EMA, 50SMA or 200SMA to determine how extended a stock is and accordingly sell partials or exit. By default the indicator takes 50SMA and when the ATR% multiple is greater than 7 then it gives the signal to take partials. You can back test this indicator with previous trades and determine the ideal threshold for the signal. For small and midcaps a threshold of 7 to 10 ATR% multiples from 50SMA is where partials can be taken while large caps can revert to mean even earlier at 3 to 5 ATR% multiples from 50SMA.
You can modify this script and use it anyway you please as long as you make it opensource on TradingView.