SMA Crossover Alert (Golden / Death Cross)
fetches candles, computes fast and slow simple moving averages, and sends a Telegram alert when the fast SMA crosses above (golden cross) or below (death cross) the slow SMA.
Config
- Trading pair (required): Symbol (e.g. BTC/USDT).
- Market type (optional, default: spot): Spot or perpetual.
- Kline interval (optional, default: 4h): Candle timeframe.
- Fast SMA period (optional, default: 10): Shorter MA period.
- Slow SMA period (optional, default: 30): Longer MA period.
- Binance API (required): Used to fetch OHLCV.
- Telegram (optional): If set, crossover alerts are sent to this chat.
Logic
- Read config and fetch enough OHLCV from Binance for both SMAs.
- Compute fast and slow SMA; compare current and previous values to detect golden cross (fast crosses above slow) or death cross (fast crosses below slow).
- If a crossover occurred and Telegram is configured, send one message with symbol, signal type, and indicator values.
- Finish with computed values and flags (goldenCross, deathCross, alertSent).
When it stops: After one run.
If something fails: Errors propagate; no retry.