OPEN-SOURCE SCRIPT
Double U Strategy with Webhook Alerts

Double U Strategy with Webhook Alerts
Double U Strategy is a trend-following strategy built around two independent ATR-based engines, one for long entries and one for short entries. The idea comes from the ATR trailing-stop approach commonly associated with UT Bot, but Double U uses a different implementation and trading structure. The reason for separating the two sides is simple: bullish and bearish moves often behave differently, so forcing both directions to use exactly the same ATR settings is not always useful.
The long and short engines each have their own sensitivity and ATR period. A long entry can occur when price crosses above the long ATR trail while remaining above the trend EMA, while a short entry can occur when price crosses below the short ATR trail while remaining below the same EMA. The EMA is therefore used as a regime filter rather than as an entry signal by itself.
The strategy also supports pyramiding. If another valid signal appears while a position in the same direction is already open, the strategy can add to that position until the pyramiding limit is reached. The default limit is three entries, but this can be changed from the Strategy Properties.
Exits use a separate mechanism instead of simply waiting for the ATR engine to reverse. The script compares the current close with the close a configurable number of bars earlier and counts consecutive moves in the same direction. Once the required sequence is reached, the current position is closed. This keeps entry and exit logic independent: ATR behavior decides when to enter, while the sequence logic decides when an extended move has progressed far enough to exit.
The default configuration was selected as a practical starting point for testing rather than as a claim of universal optimization. The current setup uses a long-term EMA filter together with different ATR settings for long and short trades, reflecting the asymmetric design of the strategy. Results can change significantly between instruments and timeframes, so the parameters should be tested rather than treated as fixed recommendations.
Webhook alerts
Webhook support is built directly into the strategy. Entry and exit orders generate structured alert messages automatically, so there is no need to manually create separate JSON messages for buys, sells, or closes.
When creating a TradingView strategy alert, the Message field should contain only:
{{strategy.order.alert_message}}
The strategy includes a platform selector and an optional symbol override. If the symbol field is left empty, the chart ticker is sent in the webhook message. If an external execution system requires a different symbol, the required ticker can be entered directly. This is useful not only for crypto, but also for futures, forex, indices, metals, or any case where the TradingView symbol differs from the execution symbol.
For example, a strategy can run on a continuous futures chart while the webhook sends the currently tradable contract instead. The trading logic remains attached to the chart, while the execution symbol can be changed without modifying the Pine code.
Statistics
A compact statistics table is displayed on the chart to make parameter testing faster. It shows net profit, number of closed trades, win rate, profit factor, test period, pessimistic profit factor, maximum intratrade drawdown, and Sharpe ratio.
The drawdown value in this table is intentionally different from TradingView's portfolio-level maximum drawdown. It shows the largest adverse movement experienced inside any closed trade, which makes it useful when comparing parameter combinations and estimating how much floating loss a trade may have experienced before closing.
The Sharpe ratio is calculated from monthly equity returns using a 2% annual risk-free rate and is annualized from monthly observations.
Backtesting notes
The strategy uses 10% of equity as the default order size, allows up to three pyramided entries, processes orders on bar close, and includes 15 ticks of slippage by default. Commission is not hard-coded because the script can be tested on instruments with very different pricing models. Users should set commission, margin, slippage, and other Strategy Properties according to the broker, exchange, and instrument they actually intend to trade.
Historical results are hypothetical and depend on the selected market, timeframe, data source, execution assumptions, and parameters. The purpose of Double U Strategy is to provide a transparent strategy that can be backtested, adjusted, and connected to webhook-based execution, not to predict future performance.
Double U Strategy is a trend-following strategy built around two independent ATR-based engines, one for long entries and one for short entries. The idea comes from the ATR trailing-stop approach commonly associated with UT Bot, but Double U uses a different implementation and trading structure. The reason for separating the two sides is simple: bullish and bearish moves often behave differently, so forcing both directions to use exactly the same ATR settings is not always useful.
The long and short engines each have their own sensitivity and ATR period. A long entry can occur when price crosses above the long ATR trail while remaining above the trend EMA, while a short entry can occur when price crosses below the short ATR trail while remaining below the same EMA. The EMA is therefore used as a regime filter rather than as an entry signal by itself.
The strategy also supports pyramiding. If another valid signal appears while a position in the same direction is already open, the strategy can add to that position until the pyramiding limit is reached. The default limit is three entries, but this can be changed from the Strategy Properties.
Exits use a separate mechanism instead of simply waiting for the ATR engine to reverse. The script compares the current close with the close a configurable number of bars earlier and counts consecutive moves in the same direction. Once the required sequence is reached, the current position is closed. This keeps entry and exit logic independent: ATR behavior decides when to enter, while the sequence logic decides when an extended move has progressed far enough to exit.
The default configuration was selected as a practical starting point for testing rather than as a claim of universal optimization. The current setup uses a long-term EMA filter together with different ATR settings for long and short trades, reflecting the asymmetric design of the strategy. Results can change significantly between instruments and timeframes, so the parameters should be tested rather than treated as fixed recommendations.
Webhook alerts
Webhook support is built directly into the strategy. Entry and exit orders generate structured alert messages automatically, so there is no need to manually create separate JSON messages for buys, sells, or closes.
When creating a TradingView strategy alert, the Message field should contain only:
{{strategy.order.alert_message}}
The strategy includes a platform selector and an optional symbol override. If the symbol field is left empty, the chart ticker is sent in the webhook message. If an external execution system requires a different symbol, the required ticker can be entered directly. This is useful not only for crypto, but also for futures, forex, indices, metals, or any case where the TradingView symbol differs from the execution symbol.
For example, a strategy can run on a continuous futures chart while the webhook sends the currently tradable contract instead. The trading logic remains attached to the chart, while the execution symbol can be changed without modifying the Pine code.
Statistics
A compact statistics table is displayed on the chart to make parameter testing faster. It shows net profit, number of closed trades, win rate, profit factor, test period, pessimistic profit factor, maximum intratrade drawdown, and Sharpe ratio.
The drawdown value in this table is intentionally different from TradingView's portfolio-level maximum drawdown. It shows the largest adverse movement experienced inside any closed trade, which makes it useful when comparing parameter combinations and estimating how much floating loss a trade may have experienced before closing.
The Sharpe ratio is calculated from monthly equity returns using a 2% annual risk-free rate and is annualized from monthly observations.
Backtesting notes
The strategy uses 10% of equity as the default order size, allows up to three pyramided entries, processes orders on bar close, and includes 15 ticks of slippage by default. Commission is not hard-coded because the script can be tested on instruments with very different pricing models. Users should set commission, margin, slippage, and other Strategy Properties according to the broker, exchange, and instrument they actually intend to trade.
Historical results are hypothetical and depend on the selected market, timeframe, data source, execution assumptions, and parameters. The purpose of Double U Strategy is to provide a transparent strategy that can be backtested, adjusted, and connected to webhook-based execution, not to predict future performance.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.