OPEN-SOURCE SCRIPT
EMA and Dow Theory Strategies V2

📘 Overview
This strategy is an advanced evolution of the original EMA × Dow Theory hybrid model. V2 introduces true swing‑based trend detection, gradient trend‑zones, higher‑timeframe swing overlays, and dynamic exit logic designed for intraday to short‑term trading across crypto, forex, stocks, and indices.
The system provides precise entries, adaptive exits, and highly visual guidance that helps traders understand trend structure at a glance.
🧠 Key Features
🔹 1. Dual‑EMA Trend Logic (Symbol + External Index)
Both the chart symbol and an external index (OTHERS.D) are evaluated using fast/slow EMAs to determine correlation‑based trend bias.
🔹 2. Dow Theory Swing Detection (Real‑time)
The script identifies swing highs/lows and updates trend direction when price breaks them. This creates a structural trend model that reacts faster than EMAs alone.
🔹 3. Gradient Trend Zones (Visual Trend Strength)
When trend is up or down, the area between price and the latest swing level is filled with a multi‑step gradient. This makes trend strength and distance-to-structure visually intuitive.
🔹 4. Higher‑Timeframe Swing Trend (htfTrend)
Swing highs/lows from a higher timeframe (e.g., 4H) are plotted to show macro structure. Used only for visual context, not for filtering entries.
🔹 5. RSI‑Based Entry Protection
RSI prevents entries during extreme overbought/oversold conditions.
🔹 6. Dynamic Exit System
Includes:
Custom stop‑loss (%)
Partial take‑profit (TP1/TP2/TP3)
Automatic scale‑out when trend color weakens
“Color‑change lockout” to prevent immediate re‑entry
Real‑time PnL tracking and labels
🔹 7. Alerts for All Key Events
Entry, stop‑loss, partial exits, and trend‑change exits all generate structured JSON alerts.
🔹 8. Visual PnL Labels & Equity Tracking
PnL for the latest trade is displayed directly on the chart, including scale‑out adjustments.
⚙️ Input Parameters
Parameter Description
Fast EMA / Slow EMA EMAs used for symbol trend detection
Index Fast / Slow EMA EMAs applied to external index
StopLoss (%) Custom stop‑loss threshold
Scale‑Out % Portion to exit when trend color weakens
RSI Period / Levels Overbought/oversold filters
Swing Detection Length Bars used to detect swing highs/lows
Stats Display Position of statistics table
🧭 About htfTrend (Higher Timeframe Trend)
The higher‑timeframe swing trend is displayed visually but not used for entry logic.
Why? Strict HTF filtering reduces trade frequency and often removes profitable setups. By keeping it visual‑only, traders retain flexibility while still benefiting from macro structure awareness.
Use it as a contextual guide, not a constraint.
📘 概要
本ストラテジーは、V1 を大幅に拡張した EMA × ダウ理論 × スイング構造 × 上位足トレンド可視化 の複合型モデルです。 短期〜デイトレード向けに最適化されており、仮想通貨・FX・株式・指数など幅広いアセットで利用できます。
V2 では、スイング構造の自動検出、グラデーションによるトレンド強度の可視化、上位足スイングライン、動的な利確/損切りロジック が追加され、視覚的にもロジック的にも大幅に強化されています。
🧠 主な機能
🔹 1. 銘柄+外部インデックスの EMA クロス判定
対象銘柄と OTHERS.D の EMA を比較し、相関を考慮したトレンド方向を判定します。
🔹 2. ダウ理論に基づくスイング高値・安値の自動検出
スイング更新によりトレンド方向を切り替える、構造ベースのトレンド判定を採用。
🔹 3. グラデーション背景によるトレンド強度の可視化
スイングラインから現在価格までを段階的に塗り分け、 「どれだけトレンドが伸びているか」を直感的に把握できます。
🔹 4. 上位足スイングトレンド(htfTrend)の表示
4H などの上位足でのスイング高値・安値を表示し、 大局的なトレンド構造を視覚的に把握できます(ロジックには未使用)。
🔹 5. RSI による過熱・売られすぎフィルター
極端な RSI 状態でのエントリーを防止。
🔹 6. 動的イグジットシステム
カスタム損切り(%)
TP1/TP2/TP3 の段階的利確
トレンド色の弱まりによる自動スケールアウト
色変化後の再エントリー制限(waitForColorChange)
リアルタイム PnL の追跡とラベル表示
🔹 7. アラート完備(JSON 形式)
エントリー、損切り、部分利確、トレンド反転などすべてに対応。
🔹 8. 損益ラベル・統計表示
直近トレードの損益をチャート上に表示し、視覚的に把握できます。
⚙️ 設定項目
設定項目名 説明
Fast / Slow EMA 銘柄の EMA 設定
Index Fast / Slow EMA 外部インデックスの EMA 設定
損切り(%) カスタム損切りライン
部分利確割合 トレンド弱化時のスケールアウト割合
RSI 期間・水準 過熱/売られすぎフィルター
スイング検出期間 スイング高値・安値の検出に使用
統計表示位置 テーブルの表示位置
🧭 上位足トレンド(htfTrend)について
上位足スイングの更新に基づくトレンド判定を表示しますが、 エントリー条件には使用していません。
理由: 上位足を厳密にロジックへ組み込むと、トレード機会が大幅に減るためです。
本ストラテジーでは、 「大局の把握は視覚で、エントリーは柔軟に」 という設計思想を採用しています。
→ 裁量で利確判断や逆張り回避に活用できます。
This strategy is an advanced evolution of the original EMA × Dow Theory hybrid model. V2 introduces true swing‑based trend detection, gradient trend‑zones, higher‑timeframe swing overlays, and dynamic exit logic designed for intraday to short‑term trading across crypto, forex, stocks, and indices.
The system provides precise entries, adaptive exits, and highly visual guidance that helps traders understand trend structure at a glance.
🧠 Key Features
🔹 1. Dual‑EMA Trend Logic (Symbol + External Index)
Both the chart symbol and an external index (OTHERS.D) are evaluated using fast/slow EMAs to determine correlation‑based trend bias.
🔹 2. Dow Theory Swing Detection (Real‑time)
The script identifies swing highs/lows and updates trend direction when price breaks them. This creates a structural trend model that reacts faster than EMAs alone.
🔹 3. Gradient Trend Zones (Visual Trend Strength)
When trend is up or down, the area between price and the latest swing level is filled with a multi‑step gradient. This makes trend strength and distance-to-structure visually intuitive.
🔹 4. Higher‑Timeframe Swing Trend (htfTrend)
Swing highs/lows from a higher timeframe (e.g., 4H) are plotted to show macro structure. Used only for visual context, not for filtering entries.
🔹 5. RSI‑Based Entry Protection
RSI prevents entries during extreme overbought/oversold conditions.
🔹 6. Dynamic Exit System
Includes:
Custom stop‑loss (%)
Partial take‑profit (TP1/TP2/TP3)
Automatic scale‑out when trend color weakens
“Color‑change lockout” to prevent immediate re‑entry
Real‑time PnL tracking and labels
🔹 7. Alerts for All Key Events
Entry, stop‑loss, partial exits, and trend‑change exits all generate structured JSON alerts.
🔹 8. Visual PnL Labels & Equity Tracking
PnL for the latest trade is displayed directly on the chart, including scale‑out adjustments.
⚙️ Input Parameters
Parameter Description
Fast EMA / Slow EMA EMAs used for symbol trend detection
Index Fast / Slow EMA EMAs applied to external index
StopLoss (%) Custom stop‑loss threshold
Scale‑Out % Portion to exit when trend color weakens
RSI Period / Levels Overbought/oversold filters
Swing Detection Length Bars used to detect swing highs/lows
Stats Display Position of statistics table
🧭 About htfTrend (Higher Timeframe Trend)
The higher‑timeframe swing trend is displayed visually but not used for entry logic.
Why? Strict HTF filtering reduces trade frequency and often removes profitable setups. By keeping it visual‑only, traders retain flexibility while still benefiting from macro structure awareness.
Use it as a contextual guide, not a constraint.
📘 概要
本ストラテジーは、V1 を大幅に拡張した EMA × ダウ理論 × スイング構造 × 上位足トレンド可視化 の複合型モデルです。 短期〜デイトレード向けに最適化されており、仮想通貨・FX・株式・指数など幅広いアセットで利用できます。
V2 では、スイング構造の自動検出、グラデーションによるトレンド強度の可視化、上位足スイングライン、動的な利確/損切りロジック が追加され、視覚的にもロジック的にも大幅に強化されています。
🧠 主な機能
🔹 1. 銘柄+外部インデックスの EMA クロス判定
対象銘柄と OTHERS.D の EMA を比較し、相関を考慮したトレンド方向を判定します。
🔹 2. ダウ理論に基づくスイング高値・安値の自動検出
スイング更新によりトレンド方向を切り替える、構造ベースのトレンド判定を採用。
🔹 3. グラデーション背景によるトレンド強度の可視化
スイングラインから現在価格までを段階的に塗り分け、 「どれだけトレンドが伸びているか」を直感的に把握できます。
🔹 4. 上位足スイングトレンド(htfTrend)の表示
4H などの上位足でのスイング高値・安値を表示し、 大局的なトレンド構造を視覚的に把握できます(ロジックには未使用)。
🔹 5. RSI による過熱・売られすぎフィルター
極端な RSI 状態でのエントリーを防止。
🔹 6. 動的イグジットシステム
カスタム損切り(%)
TP1/TP2/TP3 の段階的利確
トレンド色の弱まりによる自動スケールアウト
色変化後の再エントリー制限(waitForColorChange)
リアルタイム PnL の追跡とラベル表示
🔹 7. アラート完備(JSON 形式)
エントリー、損切り、部分利確、トレンド反転などすべてに対応。
🔹 8. 損益ラベル・統計表示
直近トレードの損益をチャート上に表示し、視覚的に把握できます。
⚙️ 設定項目
設定項目名 説明
Fast / Slow EMA 銘柄の EMA 設定
Index Fast / Slow EMA 外部インデックスの EMA 設定
損切り(%) カスタム損切りライン
部分利確割合 トレンド弱化時のスケールアウト割合
RSI 期間・水準 過熱/売られすぎフィルター
スイング検出期間 スイング高値・安値の検出に使用
統計表示位置 テーブルの表示位置
🧭 上位足トレンド(htfTrend)について
上位足スイングの更新に基づくトレンド判定を表示しますが、 エントリー条件には使用していません。
理由: 上位足を厳密にロジックへ組み込むと、トレード機会が大幅に減るためです。
本ストラテジーでは、 「大局の把握は視覚で、エントリーは柔軟に」 という設計思想を採用しています。
→ 裁量で利確判断や逆張り回避に活用できます。
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.