OPEN-SOURCE SCRIPT
已更新 Xiznit EMA Cross Strategy

Xiznit EMA Cross Strategy is a robust, filtered trend-following trading system built in Pine Script v6 for TradingView. It improves upon classic EMA crossover signals by incorporating multiple confirmations to reduce whipsaws and fakeouts, while using dynamic risk management to protect capital and let winners run in strong trends.
Core Concept
The strategy enters trades on Exponential Moving Average (EMA) crossovers (fast EMA crossing above/below slow EMA), but only when the market shows sufficient trend strength and momentum confirmation. This helps focus on higher-probability setups and avoids choppy, range-bound conditions where simple EMA crosses often fail.
Key Features & Logic
Entry Signals (Filtered for Quality)
Long Entry: Fast EMA crosses above Slow EMA AND all filters pass:
ADX > user-defined threshold (default 25) — confirms a strong trend.
+DI > -DI — confirms bullish directional momentum.
Current volume > SMA(volume, length) × multiplier (default 1.5) — ensures volume surge backing the move (reduces low-conviction fakeouts).
Short Entry: Fast EMA crosses below Slow EMA AND:
ADX > threshold.
-DI > +DI (bearish momentum).
Volume surge condition.
Trades respect the selected direction mode: Long only, Short only, or Both (reversals allowed).
Position Management & Exits
Initial Stop-Loss: Placed at entry price ± ATR × multiplier (default 1.5× ATR(14)). Visualized as a short red dashed horizontal line for the first 10 bars after entry.
Trailing Stop (Chandelier Exit style): Dynamic ATR-based trail:
Longs: Trails below price at highest high since entry minus ATR × multiplier (default 3.0).
Shorts: Trails above price at lowest low since entry plus ATR × multiplier.
Updates every bar to move only in the trade's favor.
Visualized as a stepped line on the chart (green/teal for longs, red/maroon for shorts) — only shown while position is open.
Breakeven (BE) Move: When unrealized profit reaches RR × initial risk (default RR = 1.0), the stop-loss automatically moves to the exact entry price (breakeven).
Triggers a label ("SL → BE") near the current price.
Changes trailing line appearance: brighter color (lime for longs, fuchsia for shorts), thicker width, and solid style instead of dashed — clear visual cue that the trade is now risk-free.
Exit: Position closes only when price hits the trailing stop (market order at close). No opposite EMA cross exits — allows trades to capture larger moves in trending markets.
Visuals on the Chart (Clean & Informative)
Fast EMA (orange, thick) and Slow EMA (blue, thick).
Entry markers:
Green upward triangle below bar + "Long" label for valid longs.
Red downward triangle above bar + "Short" label for valid shorts.
Trailing stop line (dynamic, position-based).
Temporary initial SL dashed red line (fades after 10 bars).
Breakeven trigger label and trailing line style/color change.
ADX/DMI pane elements (overlaid but visually distinct):
ADX line (purple).
+DI (green) and -DI (red) lines.
Dashed red horizontal at ADX threshold.
Small diamond markers on +DI/-DI crossovers.
Background fill: light green when ADX > threshold (trending allowed), light gray when below (range-bound, signals blocked).
Overall chart background tint: subtle green/gray based on ADX condition for quick trend context.
Inputs (Fully Customizable)
Fast EMA & Slow EMA lengths (defaults 10 / 20).
Trade Direction: Long, Short, or Both.
ADX/DMI Length (default 14) and ADX Threshold (default 25.0).
Volume SMA Length (default 20) and Volume Multiplier (default 1.5).
ATR Length (default 14).
Trailing ATR Multiplier (default 3.0 — Chandelier distance).
Initial SL ATR Multiplier (default 1.5 — starting risk distance).
RR for BE Move (default 1.0 — reward:risk ratio to trigger breakeven).
Important Notes & Disclaimers
This is a trend-following strategy — performs best in trending markets (e.g., stocks, forex, crypto on higher timeframes like 1H, 4H, Daily). It may underperform or generate few signals in sideways/choppy conditions due to strict ADX + DMI + volume filters.
No guarantees of profitability — past backtest results do not predict future performance. Always forward-test, paper trade, and use proper risk management.
Designed for illustration and educational purposes only. Not financial advice. Trading involves substantial risk of loss.
Uses calc_on_every_tick=true for real-time responsiveness.
No pyramiding, fixed quantity sizing (uses strategy defaults — adjust in Settings/Properties tab).
Commission, slippage, and realistic fill assumptions should be set in the Strategy Tester for more accurate results.
Core Concept
The strategy enters trades on Exponential Moving Average (EMA) crossovers (fast EMA crossing above/below slow EMA), but only when the market shows sufficient trend strength and momentum confirmation. This helps focus on higher-probability setups and avoids choppy, range-bound conditions where simple EMA crosses often fail.
Key Features & Logic
Entry Signals (Filtered for Quality)
Long Entry: Fast EMA crosses above Slow EMA AND all filters pass:
ADX > user-defined threshold (default 25) — confirms a strong trend.
+DI > -DI — confirms bullish directional momentum.
Current volume > SMA(volume, length) × multiplier (default 1.5) — ensures volume surge backing the move (reduces low-conviction fakeouts).
Short Entry: Fast EMA crosses below Slow EMA AND:
ADX > threshold.
-DI > +DI (bearish momentum).
Volume surge condition.
Trades respect the selected direction mode: Long only, Short only, or Both (reversals allowed).
Position Management & Exits
Initial Stop-Loss: Placed at entry price ± ATR × multiplier (default 1.5× ATR(14)). Visualized as a short red dashed horizontal line for the first 10 bars after entry.
Trailing Stop (Chandelier Exit style): Dynamic ATR-based trail:
Longs: Trails below price at highest high since entry minus ATR × multiplier (default 3.0).
Shorts: Trails above price at lowest low since entry plus ATR × multiplier.
Updates every bar to move only in the trade's favor.
Visualized as a stepped line on the chart (green/teal for longs, red/maroon for shorts) — only shown while position is open.
Breakeven (BE) Move: When unrealized profit reaches RR × initial risk (default RR = 1.0), the stop-loss automatically moves to the exact entry price (breakeven).
Triggers a label ("SL → BE") near the current price.
Changes trailing line appearance: brighter color (lime for longs, fuchsia for shorts), thicker width, and solid style instead of dashed — clear visual cue that the trade is now risk-free.
Exit: Position closes only when price hits the trailing stop (market order at close). No opposite EMA cross exits — allows trades to capture larger moves in trending markets.
Visuals on the Chart (Clean & Informative)
Fast EMA (orange, thick) and Slow EMA (blue, thick).
Entry markers:
Green upward triangle below bar + "Long" label for valid longs.
Red downward triangle above bar + "Short" label for valid shorts.
Trailing stop line (dynamic, position-based).
Temporary initial SL dashed red line (fades after 10 bars).
Breakeven trigger label and trailing line style/color change.
ADX/DMI pane elements (overlaid but visually distinct):
ADX line (purple).
+DI (green) and -DI (red) lines.
Dashed red horizontal at ADX threshold.
Small diamond markers on +DI/-DI crossovers.
Background fill: light green when ADX > threshold (trending allowed), light gray when below (range-bound, signals blocked).
Overall chart background tint: subtle green/gray based on ADX condition for quick trend context.
Inputs (Fully Customizable)
Fast EMA & Slow EMA lengths (defaults 10 / 20).
Trade Direction: Long, Short, or Both.
ADX/DMI Length (default 14) and ADX Threshold (default 25.0).
Volume SMA Length (default 20) and Volume Multiplier (default 1.5).
ATR Length (default 14).
Trailing ATR Multiplier (default 3.0 — Chandelier distance).
Initial SL ATR Multiplier (default 1.5 — starting risk distance).
RR for BE Move (default 1.0 — reward:risk ratio to trigger breakeven).
Important Notes & Disclaimers
This is a trend-following strategy — performs best in trending markets (e.g., stocks, forex, crypto on higher timeframes like 1H, 4H, Daily). It may underperform or generate few signals in sideways/choppy conditions due to strict ADX + DMI + volume filters.
No guarantees of profitability — past backtest results do not predict future performance. Always forward-test, paper trade, and use proper risk management.
Designed for illustration and educational purposes only. Not financial advice. Trading involves substantial risk of loss.
Uses calc_on_every_tick=true for real-time responsiveness.
No pyramiding, fixed quantity sizing (uses strategy defaults — adjust in Settings/Properties tab).
Commission, slippage, and realistic fill assumptions should be set in the Strategy Tester for more accurate results.
版本注释
Xiznit EMA Cross Strategy is a robust, filtered trend-following trading system built in Pine Script v6 for TradingView. It improves upon classic EMA crossover signals by incorporating multiple confirmations to reduce whipsaws and fakeouts, while using dynamic risk management to protect capital and let winners run in strong trends.
Core Concept
The strategy enters trades on Exponential Moving Average (EMA) crossovers (fast EMA crossing above/below slow EMA), but only when the market shows sufficient trend strength and momentum confirmation. This helps focus on higher-probability setups and avoids choppy, range-bound conditions where simple EMA crosses often fail.
Key Features & Logic
Entry Signals (Filtered for Quality)
Long Entry: Fast EMA crosses above Slow EMA AND all filters pass:
ADX > user-defined threshold (default 25) — confirms a strong trend.
+DI > -DI — confirms bullish directional momentum.
Current volume > SMA(volume, length) × multiplier (default 1.5) — ensures volume surge backing the move (reduces low-conviction fakeouts).
Short Entry: Fast EMA crosses below Slow EMA AND:
ADX > threshold.
-DI > +DI (bearish momentum).
Volume surge condition.
Trades respect the selected direction mode: Long only, Short only, or Both (reversals allowed).
Position Management & Exits
Initial Stop-Loss: Placed at entry price ± ATR × multiplier (default 1.5× ATR(14)). Visualized as a short red dashed horizontal line for the first 10 bars after entry.
Trailing Stop (Chandelier Exit style): Dynamic ATR-based trail:
Longs: Trails below price at highest high since entry minus ATR × multiplier (default 3.0).
Shorts: Trails above price at lowest low since entry plus ATR × multiplier.
Updates every bar to move only in the trade's favor.
Visualized as a stepped line on the chart (green/teal for longs, red/maroon for shorts) — only shown while position is open.
Breakeven (BE) Move: When unrealized profit reaches RR × initial risk (default RR = 1.0), the stop-loss automatically moves to the exact entry price (breakeven).
Triggers a label ("SL → BE") near the current price.
Changes trailing line appearance: brighter color (lime for longs, fuchsia for shorts), thicker width, and solid style instead of dashed — clear visual cue that the trade is now risk-free.
Exit: Position closes only when price hits the trailing stop (market order at close). No opposite EMA cross exits — allows trades to capture larger moves in trending markets.
Visuals on the Chart (Clean & Informative)
Fast EMA (orange, thick) and Slow EMA (blue, thick).
Entry markers:
Green upward triangle below bar
Red downward triangle above bar
Trailing stop line (dynamic, position-based).
Temporary initial SL dashed red line (fades after 10 bars).
Breakeven trigger label and trailing line style/color change.
ADX/DMI pane elements (overlaid but visually distinct):
ADX line (purple).
+DI (green) and -DI (red) lines.
Dashed red horizontal at ADX threshold.
Small diamond markers on +DI/-DI crossovers.
Background fill: light green when ADX > threshold (trending allowed), light gray when below (range-bound, signals blocked).
Overall chart background tint: subtle green/gray based on ADX condition for quick trend context.
Inputs (Fully Customizable)
Fast EMA & Slow EMA lengths (defaults 10 / 20).
Trade Direction: Long, Short, or Both.
ADX/DMI Length (default 14) and ADX Threshold (default 25.0).
Volume SMA Length (default 20) and Volume Multiplier (default 1.5).
ATR Length (default 14).
Trailing ATR Multiplier (default 3.0 — Chandelier distance).
Initial SL ATR Multiplier (default 1.5 — starting risk distance).
RR for BE Move (default 1.0 — reward:risk ratio to trigger breakeven).
Important Notes & Disclaimers
This is a trend-following strategy — performs best in trending markets (e.g., stocks, forex, crypto on higher timeframes like 1H, 4H, Daily). It may underperform or generate few signals in sideways/choppy conditions due to strict ADX + DMI + volume filters.
No guarantees of profitability — past backtest results do not predict future performance. Always forward-test, paper trade, and use proper risk management.
Designed for illustration and educational purposes only. Not financial advice. Trading involves substantial risk of loss.
Uses calc_on_every_tick=true for real-time responsiveness.
No pyramiding, fixed quantity sizing (uses strategy defaults — adjust in Settings/Properties tab).
Commission, slippage, and realistic fill assumptions should be set in the Strategy Tester for more accurate results.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。