HalfTrend + RSI Trend Reversal Strategy | Full MT5 EA Source Code
Contents
1. Strategy Overview
This is a popular strategy originating from YouTube. Though the original creator has removed the source video, technical details can still be obtained through other reviewers’ content 86% win rate secret strategy | RSI + secret indicator. This strategy mainly uses the HalfTrend indicator for trend identification, paired with short‑period RSI(2) to catch extreme overbought and oversold conditions. In this article, I will break down the complete logic of this strategy and present an open‑source MT5 Expert Advisor (EA) ready for backtest.
2. Full Trading Rules
Core Indicators
- HalfTrend: Amplitude set to 4, Channel Deviation set to 2. It identifies the primary market trend and distinguishes between uptrend and downtrend.
- RSI: Period set to 2, with oversold and overbought thresholds at 10 and 90. Used to capture short‑term overbought and oversold market conditions.
Basic Rules
- Timeframe: All timeframes
- Assets: Precious metals, forex, energy, and others
Entry Rules
Long entry
- HalfTrend shows an uptrend
- RSI(2) enters oversold zone (<10)
- After RSI hits the oversold zone, wait for one bar close above the high of the previous bar

Short entry
- HalfTrend shows a downtrend
- RSI(2) enters overbought zone (>90)
- After RSI hits the overbought zone, wait for one bar close below the low of the previous bar

Exit Rules
Long Exit
- SL: Swing low
- TP: Fixed take‑profit, or exit when RSI enters the overbought zone
Short Exit
- SL: Swing high
- TP: Fixed take‑profit, or exit when RSI enters the oversold zone
Edge & limitations
HalfTrend reacts to trend shifts and can generate trend‑reversal signals relatively early. It performs better in strong trending market conditions. However, this feature also brings potential for misjudged trends. Especially in range‑bound market, HalfTrend toggles between trends repeatedly. Even minor pullbacks within a trending market may be misinterpreted as trend reversals, producing numerous false signals. On the other hand, RSI(2) uses a very short period and frequently enters overbought or oversold zones.
3.EA implementation
Core logic
It should be noted that HalfTrend is not included as a built‑in indicator inside MT5. I downloaded the free HalfTrend indicator from Half Trend indicator for MetaTrader 5 Download - Free and referenced this exact version inside the EA code.
The three entry conditions of this strategy trigger sequentially instead of needing to be satisfied simultaneously. For this reason, a finite‑state‑machine architecture is adopted for implementation. The EA runs with the following logic: it first reads the HalfTrend trend status. If trend conditions are met and RSI first hits overbought or oversold levels, the EA then waits for reversal signals. All signal checks are performed only on bar close.
For money‑management logic, swing lows are determined by looking back over N bars to set stop‑loss levels. Take‑profit is calculated with a fixed multiplier. During real‑world testing, I observed that RSI(2) is extremely sensitive and often flips to the opposite extreme zone immediately after an entry signal fires. The EA also enforces single‑position only trading.
Core code snippet:
1 | switch(g_state) |
Parameter Settings
| Parameter | Default Value | Description |
|---|---|---|
| MagicNumber | 12345 | EA magic number used to identify orders belonging to this EA |
| LotSize | 0.1 | Trading lot size |
| RsiPeriod | 2 | RSI period |
| RsiOversoldVal | 10 | Oversold threshold for long entries |
| RsiOverboughtVal | 90 | Overbought threshold for short entries |
| HtAmplitude | 4 | Amplitude parameter for the HalfTrend indicator |
| HtChannelDeviation | 2 | Channel deviation parameter for the HalfTrend indicator |
| TpMultiplier | 2 | Take‑profit multiple relative to stop‑loss distance |
| SlLookbackBars | 5 | Number of bars used for look‑back calculation of stop‑loss |
EA Source Code / Download
5. Limitations & Disclaimer
No backtest / forward‑test results provided. Users must verify robustness via personal backtest and demo forward‑testing before live usage.
Not financial advice. Forex trading involves substantial risk.