OPEN-SOURCE SCRIPT

EMA 9/21 GoldenX Pro-TSL

656
█ OVERVIEW

EMA GoldenX Pro-TS is a trend-following strategy built around the classic EMA crossover (Golden Cross / Death Cross), enhanced with multi-layer confirmation filters and dynamic risk management. It is designed for traders who want clean, rule-based entries while avoiding choppy, low-conviction signals.


█ HOW IT WORKS

ENTRY LOGIC
• A Long entry triggers when the Fast EMA crosses above the Slow EMA (Golden Cross), confirmed by rising volume OR rising price action, AND a trending market condition (ADX filter).
• A Short entry triggers when the Fast EMA crosses below the Slow EMA (Death Cross), confirmed by rising volume OR falling price action, AND a trending market condition.

POSITION FLIPPING
• When already in a position and the opposite EMA cross occurs, the strategy can instantly close and reverse (flip). The "Flip on EMA cross only" option lets you bypass the volume/ADX filters on reversal signals — useful for fast-moving markets where waiting for full confirmation may cause late entries.

STOP-LOSS MANAGEMENT
• A dynamic ATR-based trailing stop is calculated each bar.
• A hard percentage-based maximum stop loss acts as a safety net.
• The tighter of the two is always used, providing adaptive risk control that respects both volatility and absolute drawdown limits.


█ FEATURES

• Dual EMA Crossover — Configurable Fast (default 9) and Slow (default 21) EMA periods.
• ADX Trend Filter — Filters out entries during range-bound / low-momentum conditions (ADX threshold + DI spread).
• Volume Confirmation — Requires volume above its 5-bar SMA for fresh entries.
• Price Momentum Check — Validates price direction relative to a 5-bar SMA for additional confluence.
• ATR Trailing Stop — Volatility-adjusted stop that adapts to current market conditions.
• Max Stop Loss % — Hard cap on per-trade risk as a percentage of entry price.
• Trade Direction Control — Choose Long only, Short only, or Both.
• Instant Position Flip — Optionally reverses on EMA cross without waiting for all filters to align.
• Alert Conditions — Built-in alerts for Golden Cross (Long) and Death Cross (Short) signals.


█ SETTINGS

• Fast EMA (default: 9) — Period for the fast EMA line.
• Slow EMA (default: 21) — Period for the slow EMA line.
• Trade Direction (default: Both) — Restrict to Long, Short, or trade Both sides.
• ADX Length (default: 14) — Lookback period for the ADX/DMI calculation.
• ADX Threshold (default: 20) — Minimum ADX value to qualify as a trending market.
• ATR Length (default: 14) — Lookback period for the ATR calculation.
• ATR Multiplier (default: 2.0) — Distance of the ATR trailing stop from the current close.
• Max Stop Loss % (default: 1.0%) — Maximum allowable stop distance as a % of entry price.
• Flip on EMA Cross Only (default: true) — When enabled, position reversals only require the EMA cross, bypassing volume/ADX filters for faster flips.


█ VISUAL OUTPUTS

• Orange line — Fast EMA
• Blue line — Slow EMA
• Red line — Active trailing stop level (visible only while in a position)


█ USAGE NOTES

• Originally designed and tested on TFEX SET50 Index Futures but applicable to any liquid instrument.
• Best suited for trending markets on intraday to swing timeframes.
• Adjust EMA periods and ATR multiplier to match the volatility profile of your instrument.
• Backtest thoroughly on your target market before live deployment.


█ DISCLAIMER

This strategy is provided for educational and research purposes only. Past performance does not guarantee future results. Always manage your risk and trade responsibly.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.