OPEN-SOURCE SCRIPT
Webhook Alert Strategy Template

Educational strategy shell that builds webhook-ready alert messages from strategy order fills.
Why this exists
Most traders can write an entry condition. The hard part is packaging a clean, risk-defined exit and a stable alert string that an external webhook receiver can parse. This template is a starting shell for that workflow.
What it does
- Demo entry: MA crossover (EMA/SMA/WMA/RMA selectable). Replace this with your own logic.
- Risk exits: ATR-based stop distance (or fixed pip distance), take-profit from risk:reward.
- Alert messages: attaches comma-separated command strings to strategy entries and exits using alert_message.
Message format examples
BUY,XAUUSD,VOL=0.01,SL=120.5,TP=241,TPSLTYPE=PIPS
SELL,XAUUSD,VOL=0.01,SL=120.5,TP=241,TPSLTYPE=PIPS
CLOSE,XAUUSD
How to use
1. Add the strategy to a standard chart (gold/forex/indices work well).
2. Set VOL, ATR stop, and RR in inputs.
3. Create one alert on this strategy.
4. Choose order fills and alert() function calls.
5. Set the alert message field to exactly: {{strategy.order.alert_message}}
6. Enable webhook URL notifications and paste your own webhook endpoint.
What this is not
This is not a signal service and not financial advice. Default MA entry is only a placeholder so the shell compiles and can be tested. Backtest results with the demo entry are not a performance claim.
Originality
The useful part is the combination of risk-defined strategy exits plus explicit webhook command string generation on fills, so users can learn alert_message plumbing without rebuilding exits from scratch.
Defaults used for this publication
- Symbol: XAUUSD (OANDA)
- Timeframe: 1D
- Initial capital: 10000
- Position size: 2% of equity
- Commission: 0.02%
- Slippage: 2 ticks
Why this exists
Most traders can write an entry condition. The hard part is packaging a clean, risk-defined exit and a stable alert string that an external webhook receiver can parse. This template is a starting shell for that workflow.
What it does
- Demo entry: MA crossover (EMA/SMA/WMA/RMA selectable). Replace this with your own logic.
- Risk exits: ATR-based stop distance (or fixed pip distance), take-profit from risk:reward.
- Alert messages: attaches comma-separated command strings to strategy entries and exits using alert_message.
Message format examples
BUY,XAUUSD,VOL=0.01,SL=120.5,TP=241,TPSLTYPE=PIPS
SELL,XAUUSD,VOL=0.01,SL=120.5,TP=241,TPSLTYPE=PIPS
CLOSE,XAUUSD
How to use
1. Add the strategy to a standard chart (gold/forex/indices work well).
2. Set VOL, ATR stop, and RR in inputs.
3. Create one alert on this strategy.
4. Choose order fills and alert() function calls.
5. Set the alert message field to exactly: {{strategy.order.alert_message}}
6. Enable webhook URL notifications and paste your own webhook endpoint.
What this is not
This is not a signal service and not financial advice. Default MA entry is only a placeholder so the shell compiles and can be tested. Backtest results with the demo entry are not a performance claim.
Originality
The useful part is the combination of risk-defined strategy exits plus explicit webhook command string generation on fills, so users can learn alert_message plumbing without rebuilding exits from scratch.
Defaults used for this publication
- Symbol: XAUUSD (OANDA)
- Timeframe: 1D
- Initial capital: 10000
- Position size: 2% of equity
- Commission: 0.02%
- Slippage: 2 ticks
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.