The Supertrend line on Gold (XAUUSD) or any symbol is built from the candle midpoint, (high + low) / 2, plus or minus the ATR multiplied by a factor. Each band only moves in favour of the trend, and the trend flips when a candle closes on the other side of the active band. In an uptrend the line is green and sits below price, in a downtrend it is red and sits above price.
The arrow is drawn only after the flip candle has closed, never on the candle still forming, so an arrow you see on a closed bar stays there. Alerts follow the same rule: one alert for each closed candle with a flip, by popup, push notification or sound.
The line on the forming candle moves with price and can change side before the close. A Supertrend flip follows the trend, so it comes late in a range and gives back part of the move. Test the period and the multiplier on your symbol and timeframe before you trade it.

Any symbol, any timeframe. It draws two lines and two sets of arrows with standard indicator buffers and it never trades. Push notifications need your MetaQuotes ID set in the terminal options. Wrong inputs (ATR period below 1, multiplier of 0 or less) stop the indicator with a message in the log.
Run it on XAUUSD, XAGUSD, EURUSD, GBPUSD, US30 or NAS100 and compare M5, M15 and H1 with the same period and multiplier. A lower multiplier flips more often, a higher one stays longer in the trend. From an EA you can read it with iCustom: buffer 0 is the uptrend line, buffer 1 the downtrend line, buffer 2 the buy arrow and buffer 3 the sell arrow. The band and flip logic sits in one loop inside OnCalculate and the alert text in XP_Notify, both easy to lift into your own code. It is a good place to plug a session filter, a news filter, a higher timeframe trend check or support and resistance levels before you take the signal.
Open source. Use it as it is, adapt it, build your own version on top of it.
New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander
Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01
More tools on my profile: https://www.mql5.com/en/users/09151993a
Provided as is, use at your own risk.
London Breakout EA: simple and transparent/London Breakout Expert Advisor: simple and transparent
Free breakout EA: Asian range, London breakout, one trade a day, stop loss always set, lot size based on risk percentage. No grid, no martingale. / Free EA: Asian range breakout during the London session, one trade a day, stop loss always set, lot size based on risk percentage. No grid or martingale.
ReliableOutbox: persistent message queue with Telegram demo
Persistent MQL5 outbox with a Telegram demo and offline tests. An uncertain result is never retried automatically. Manual retry may duplicate a message; SENT means API acceptance, not a read receipt.
Accelerator Oscillator (AC)
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.
MACD Signals
Indicator edition for new platform.