OPEN-SOURCE SCRIPT
更新済 rj_temu_pair_trade

a simple "temu" implementation of a pair trade
see https://robotjames.substack.com/ for details.
see https://robotjames.substack.com/ for details.
リリースノート
A non-compounding, fixed-notional Bollinger-Band reversion strategy designed for pair trading. Includes MA-based exits, optional stop-loss + time-stop, synthetic Sharpe calculation, and on-chart performance table. Configured to align with TradingView’s Strategy Tester metrics.Overview
This strategy implements a fixed-notional, non-compounding Bollinger-Band reversion system suitable for pair trading. It is designed to operate on ratio charts (e.g., PLD/REXR) or any spread expression the user applies.
Trades are entered on the next bar following a band-cross signal, and exits can be triggered by a moving-average cross, an optional time-stop, or an optional stop-loss.
The strategy sizes each trade with a constant notional amount (e.g., $100,000), ensuring stable performance reporting across long histories and preventing unintended compounding.
Features
Entry Conditions
- Long entry when price crosses below the lower Bollinger Band.
- Short entry when price crosses above the upper Bollinger Band.
- Optional “close-only” mode to require the close to cross the bands.
Exit Conditions
- Moving-average cross exit.
- Optional time-stop (e.g., exit after 5 bars).
- Optional stop-loss based on percentage move relative to entry.
Trade Sizing
- Uses strategy.cash with fixed notional sizing per trade.
- Prevents compounding so results remain stable and comparable across instruments.
On-Chart Performance Summary
- Total PnL (%) based on strategy.netprofit.
- Average PnL per trade (%).
- Win rate.
- Annualised Sharpe ratio computed from synthetic daily returns.
- All statistics are aligned with TradingView’s Strategy Tester.
Visual Markers
- Entry/exit markers (L, S, C, TS, SL).
- Optional pre-cost PnL labels at closing bars.
Alert Triggers
- Open Long
- Open Short
- Close Long
- Close Short
These enable users to run the strategy on multiple symbols or pair charts and receive real-time entry/exit signals.
Intended Use
This script is provided for educational purposes and workflow automation.
It is not a trade signal service and makes no performance guarantees.
It is suitable for:
- Pair-trading / spread-trading setups
- Ratio charts (A/B) or synthetic spreads
- Testing fixed-notional mean-reversion systems
- Creating alerts for live monitoring or manual execution workflows
Disclaimer
This script is for educational purposes only and is not financial advice.
Trading involves risk, including possible loss of capital.
Past performance does not guarantee future results.
Users are responsible for verifying accuracy and suitability for their own circumstances.
リリースノート
v.1.1.1 - alerts on trade signalsオープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。