OPEN-SOURCE SCRIPT
Distance From Moving Average

This indicator shows the distance between the current price and the Moving Average price.
Key Features:
Key Indicator Settings:
1. Distance Calculation
There are two ways to calculate the distance:
2. Moving Average Types
There are 5 different Moving Averages:
3. Highest High and Lowest Low
You can show or hide the Highest High and the Lowest Low plots of the series
4. Historic Highs and Lows
5. Current Values
You can show or hide current value labels
Key Features:
- Show the distance between price and Moving Average (Read Distance Calculation for more information)
- Show Historic Highs and Lows
- Show Highest High and Lowest Low
- Show current Highest High, current Lowest Low and current distance
Key Indicator Settings:
1. Distance Calculation
There are two ways to calculate the distance:
- Spread - Calculate the difference between the price and the moving average
- Percentage - Calculate the percentage change between the price and the moving average
2. Moving Average Types
There are 5 different Moving Averages:
- EMA
- SMA
- WMA
- VWMA
- HMA
3. Highest High and Lowest Low
You can show or hide the Highest High and the Lowest Low plots of the series
4. Historic Highs and Lows
- You can show or hide past Highs and Lows of the series
- Lookback Length - Let's you adjust the frequency of local highs and lows of the series
5. Current Values
You can show or hide current value labels
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.