Writing an alert
The condition, the message, and when it may repeat.
alert "RSI bullish divergence"check: every 15mrepeat: once per barshow_on_chart: trueinput rsi_length = 14input lookback = 30momentum_now = rsi(close, rsi_length)lower_low = low < lowest(low, lookback)[1]higher_rsi = momentum_now > lowest(momentum_now, lookback)[1]when lower_low and higher_rsi and was(momentum_now < 30, within: 5 bars):notify "Bullish RSI divergence on {market.symbol}: RSI {momentum_now:0.0}"| Setting | What it does |
|---|---|
check | How often the condition is checked, such as every 1m. |
repeat | once, once per bar (the default), once per bar close or every time. |
cooldown | The shortest gap between two messages. |
expires | When the alert stops watching. |
show_on_chart | Marks the chart where it fired. |
notify sends the message. In version 1 it is delivered in the app and in AI chat. Testing an alert shows you the messages it would have sent and the ones its own settings held back.
Alerts that watch the account, not the chart
alert "Margin and exposure"check: every 5mrepeat: onceexpires: 30dwhen account.free_margin < 20% of account.equity or positions.len >= 8:notify "Free margin {account.free_margin:$0} with {positions.len} open positions"More: Daily risk guard, Intrabar spike, Tokyo open gap, Distribution shift.