MG - Moving Average Offset Alert

The purpose of this indicator is to allow the user to get alerted when price gets within a certain threshold of an interesting moving average (which has a customizable length, type and source).

It can be used for a timely notification that the price is in an important area or used for alerts to trigger trades slightly above the moving average to provide a higher probability of getting an entry at a key level

Basic Example:
- A bullish impulse wave occurs
- You plan to join in the next wave as it bounces of the 50 SMA
- You would ideally like to do other things with your life than watch the screen all day but you would like some time beforehand to perfect your trade setup
- You therefore, could set an alert to let you know when price has dropped within 2% of the 50 SMA which would provide ample notice for a comfortable trade.

More interesting example - (Using autoview):
- A bullish impulse wave occurs late in the evening
- You would like to join in for the second wave but you are human and have to sleep
- You could identify sensible profit and stop loss targets beforehand
- You could then, in preparation:
- Set an alert at profit level to close any long positions
- Set an alert at stop level to close any long positions
- NOTE: If the alert is never reached, that is not a problem. You are simply closing a position (not applying the opposition action i.e. short)
- Once your targets are set up, you could add whatever offset you desire (if any), to your custom moving average and set a buy alert on that moving average.
- If the price bounces off the moving average, you have the whole trade set up and automatically put in to action whilst you're asleep!
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?