OPEN-SOURCE SCRIPT

HMA 200 + EMA 20 Crossover Strategy

5 132
This strategy combines a long-term trend filter using the Hull Moving Average (HMA 200) with a short-term entry trigger using the Exponential Moving Average (EMA 20).

📈 Entry Logic:
Buy Entry: When price is above the HMA 200 and crosses above the EMA 20.

Sell Entry: When price is below the HMA 200 and crosses below the EMA 20.

The strategy closes the current position and reverses on the opposite signal.

⚙️ Strategy Settings (Backtest Configuration):
Position size: 10% of equity per trade

Commission: 0.1% per trade (to simulate broker fees)

Slippage: 2 ticks (to reflect realistic fill conditions)

✅ Purpose:
This script is designed to identify high-probability trades in the direction of the overall trend, avoiding whipsaw conditions. It is useful for traders looking for a dynamic crossover-based system that filters trades based on longer-term momentum.

🔎 Make sure to test across multiple assets and timeframes. For best results, apply this strategy to liquid trending markets like major FX pairs, indices, or high-cap stocks.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.