OPEN-SOURCE SCRIPT
Price Outpaces Moving Average

With inputs for the moving average, Bullish overshoot percentage, and bearish overshoot percentage, this indicator is attempting to show market tops based on the difference between the current price of an asset and how far away it is from its moving average.
If you have the bullish overshoot percentage set to 1.5:
let's say price is currently at 20,000 and the moving average is around 6500.
The script calculates 20,000/6500 = 3.07
Then, there is a boolean comparison asking if 3.07 > 1.5.
Since it is, the script will create a "SHORT" flag above that candlestick.
A similar process happens for the "LONG" flags.
If you have the bullish overshoot percentage set to 1.5:
let's say price is currently at 20,000 and the moving average is around 6500.
The script calculates 20,000/6500 = 3.07
Then, there is a boolean comparison asking if 3.07 > 1.5.
Since it is, the script will create a "SHORT" flag above that candlestick.
A similar process happens for the "LONG" flags.
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.
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.
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.