OPEN-SOURCE SCRIPT
Updated Webhook Strategy Template - Connect Any Indicator [Atomik]

This is a free, open-source strategy template that turns any indicator on your chart into a complete, risk-managed strategy with webhook alerts.
Most indicators plot signals but don't manage a trade. This template adds the parts that are usually missing: entry rules, a stop, a target, an optional scale-out, a session filter, and a formatted alert message you can send to any webhook endpoint.
HOW IT WORKS
You point the template at your indicator's plot using the "Long signal" and "Short signal" inputs. Any value above zero fires an entry in that direction. The template then manages the position: it places a stop and target at fixed distances from the entry, optionally scales out half at a first target, and flattens at the end of your chosen session.
If you leave "Use external signals" off, the template runs a built-in EMA crossover instead. That is useful for testing your alert setup before wiring up your own indicator.
SETTINGS
Signal source - select the plots from your own indicator. Any value above zero is treated as a signal.
Session - restrict entries to a time window in a chosen timezone. Default is 09:30-11:00 New York. "Flatten at session end" closes any open position when the window closes.
Risk - stop and target can be set in ticks, percent, or as a multiple of ATR.
Partial exit - optionally close half the position at a configurable fraction of the full target.
Order size - the quantity used for entries, with an option to include it in the alert message.
ALERTS
Each order carries a JSON alert message built in Pine, for example:
{"action":"BUY","ticker":"MNQ1!","price":21450.25,"comment":"ENTRY"}
Entries send BUY or SELL. Exits send EXIT, with a comment of EXIT_50 for the partial close and EXIT_FINAL for the full close.
To use it, create a single alert on this script and put {{strategy.order.alert_message}} in the message box. Every order will then send its own correctly formatted payload. This works with Atomik or any other service that accepts a JSON webhook.
NOTES
Backtest fills are Pine's, based on bar data. Live fills come from your broker and will differ, particularly on stops and gaps. Treat strategy tester results as indicative, not as expected performance.
The template does not predict anything and has no signal logic of its own beyond the optional EMA crossover. Its purpose is trade management and alert formatting.
Open source under MPL 2.0.
Most indicators plot signals but don't manage a trade. This template adds the parts that are usually missing: entry rules, a stop, a target, an optional scale-out, a session filter, and a formatted alert message you can send to any webhook endpoint.
HOW IT WORKS
You point the template at your indicator's plot using the "Long signal" and "Short signal" inputs. Any value above zero fires an entry in that direction. The template then manages the position: it places a stop and target at fixed distances from the entry, optionally scales out half at a first target, and flattens at the end of your chosen session.
If you leave "Use external signals" off, the template runs a built-in EMA crossover instead. That is useful for testing your alert setup before wiring up your own indicator.
SETTINGS
Signal source - select the plots from your own indicator. Any value above zero is treated as a signal.
Session - restrict entries to a time window in a chosen timezone. Default is 09:30-11:00 New York. "Flatten at session end" closes any open position when the window closes.
Risk - stop and target can be set in ticks, percent, or as a multiple of ATR.
Partial exit - optionally close half the position at a configurable fraction of the full target.
Order size - the quantity used for entries, with an option to include it in the alert message.
ALERTS
Each order carries a JSON alert message built in Pine, for example:
{"action":"BUY","ticker":"MNQ1!","price":21450.25,"comment":"ENTRY"}
Entries send BUY or SELL. Exits send EXIT, with a comment of EXIT_50 for the partial close and EXIT_FINAL for the full close.
To use it, create a single alert on this script and put {{strategy.order.alert_message}} in the message box. Every order will then send its own correctly formatted payload. This works with Atomik or any other service that accepts a JSON webhook.
NOTES
Backtest fills are Pine's, based on bar data. Live fills come from your broker and will differ, particularly on stops and gaps. Treat strategy tester results as indicative, not as expected performance.
The template does not predict anything and has no signal logic of its own beyond the optional EMA crossover. Its purpose is trade management and alert formatting.
Open source under MPL 2.0.
Release Notes
Added Enable longs / Enable shorts toggles so one-directional indicators can switch off the unused side (previously the unused source's default of close could fire unwanted entries). Clarified in the header that signal sources must be plot() outputs from indicator scripts - strategy scripts do not appear in the source dropdown.Release Notes
v3 - UT Bot built inYou can now trade UT Bot signals without wiring anything. With "Use external signals" OFF, a new "Built-in signal" dropdown lets you choose between the simple MA cross and UT Bot, the popular ATR trailing-stop flip (based on the open-source UT Bot Alerts by QuantNomad). Set the Key Value and ATR Period to match your usual settings and the template enters on each flip, with your stop, target, session window and webhook alerts managed exactly as before. When UT Bot is selected, its trailing stop is drawn on the chart (green below price, red above) so you can see what is driving entries.
Nothing changes for existing users: the dropdown defaults to MA cross, external signal wiring works exactly as it did, and all other settings are untouched. Note that alerts are pinned to the script version they were created on, so recreate your alert after updating if you want it running v3.
Release Notes
v3: Signal source rebuilt around one "Source Mode" dropdown: Predefined: MA cross, Predefined: UT Bot (built-in ATR trailing-stop flip), External Crossover (A crosses B; A defaults to price, so a level plot such as a supertrend, trailing stop, moving average or band needs only B set) and External Trigger (Long/Short trigger plots read with a Trigger logic: Greater than 0, Not NA, Crosses 0). "Trade Direction" replaces the Enable longs/shorts toggles. A trigger left on its default is ignored, so an unwired side can never fire. Crossover detection is state-based, so a level that prints na on its flip bar is caught on the next bar instead of missed. Header rewritten to walk through every mode.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.