Gann HiLo System MT5
- Experts
-
Pol Lazaro Porta
Algorithmic trader with over 10 years of experience trading CFDs. - Version: 1.0
- Activations: 12
GHS (Gann HiLo System) is an expert advisor that trades the resumption of a trend after a pullback, using the Gann HiLo Activator as its directional reference. It does not chase price or try to anticipate reversals: it waits for the line to define a trend, waits for price to pull back against it, and enters only when the market clears the prior extreme of the move, confirming it wants to resume its direction.
The Gann HiLo indicator is calculated inside the advisor itself, so no external indicator needs to be installed.
This Expert Advisor is NOT for you if:
- You are looking for a system with no losing trades or guaranteed rapid account growth.
- You prefer flawless backtest curves, even if they are the result of overfitting.
- You are looking for high-frequency trading and find it uncomfortable when the system goes through periods without trading.
- You prefer martingale, grid, or averaging strategies.
- You do not consider risk management important.
This Expert Advisor may interest you if:
- You value a strategy based on objective, repeatable rules.
- You understand that losing trades are part of any trading system.
- You prioritize robustness over an artificially perfect backtest.
- You want to clearly understand why the system enters and exits the market on each trade.
- You value trading with proper risk management.
HOW IT WORKS
The system evaluates signals exclusively at the close of each candle, using closed candles only. It does not use data from the candle currently forming, so signals do not repaint and the Strategy Tester's behavior stays consistent with live trading.
The decision process has four stages:
- Trend definition. The advisor internally builds the Gann HiLo Activator from the averages of highs and lows, and determines on each bar whether the trend is up or down according to which side of that line price closes on. The trend is fully rebuilt on every bar over a window of history, so the system's state does not depend on anything previously stored.
- Pullback detection. While the trend holds, the system tracks the extreme reached by the move. When the line turns against it, that extreme is frozen as the reference: it is the level price must clear to confirm the trend is resuming.
- Entry order. The system places a pending order at the level that would confirm the trend resuming. If price never reaches that level, the order expires without being executed.
- Setup expiry. Every pullback has a limited lifespan. Once price reclaims the line, the order stays active for a configurable number of bars; if price remains on the other side without reclaiming it, there is also a configurable waiting cap. By default, the same pullback does not generate a new order once its trade has closed.
POSITION MANAGEMENT
- Stop loss with three available modes: structural beyond the pullback extreme with an ATR buffer, an ATR multiple, or fractal mode with configurable minimum and maximum ATR limits. All modes respect a minimum distance floor, also expressed in ATR.
- Four exit modes: no fixed take profit, letting the trailing stop manage the exit; take profit as a multiple of the trade's risk; take profit as an ATR multiple; or take profit at a multiple of risk with the trailing stop able to close the trade first.
- Break-even enabled by default, with activation and locked profit defined in ATR.
- Trailing stop enabled by default, with activation, distance, and minimum step defined in ATR.
- Optional time-based exit, closing the trade after a configurable number of bars in the market.
- Protection against opening gaps: if price opens with a significant gap against the position, the losing trade is closed.
- Scheduled daily close and close before the weekend, both enabled by default.
- Configurable maximum leverage cap, as an additional safeguard independent of the per-trade risk calculation.
Break-even and trailing thresholds are always calculated on ATR and never depend on the trade's live stop loss, so moving the stop to break-even does not distort subsequent calculations. The time-based exit reads the position's own opening time. Together, this means position management survives a terminal restart, a timeframe change, or a recompile with the trade open. Own positions are identified by symbol and magic number, which is relevant on hedging accounts if several advisors trade the same symbol.
RISK MANAGEMENT
Trade size is defined using three volume calculation modes:
- Fixed lot.
- Percentage risk on the current balance (compounding).
- Percentage risk on a fixed base capital.
Volume is always derived from the actual stop loss distance of that specific trade, not from a lot table.
It also includes a risk limiter. Before sending the order, the advisor recalculates the actual monetary risk and skips the entry if it exceeds the defined tolerance over the intended risk. Available free margin is also checked before trading.
Once the stop order is placed, its volume and stop loss are fixed at the moment the setup was armed, so the risk taken is exactly the one calculated and does not change while the order waits to be filled.
By default, the system holds only one trade at a time, with a waiting period between entries.
WHAT THIS ADVISOR DOES NOT DO
- It does not use martingale, averaging, grids, or loss-recovery techniques.
- It does not open opposite positions simultaneously.
- It does not rely on arbitrage, latency, or unusual execution conditions.
- It does not hold positions without a stop loss.
BROKER COMPATIBILITY
The advisor reads and respects the minimum stops level, the freeze level, the minimum and maximum volume and the volume step, the symbol's combined volume limit accounting for both positions and pending orders, the account's pending order limit, the supported filling modes, and the supported expiration modes. Volume is normalized to the symbol's volume step. When the symbol allows orders with expiration, the advisor adds an expiry date as a safeguard so no order stays active indefinitely if the terminal stops running.
It is suitable for both hedging and netting accounts.
INFORMATION PANEL
An on-chart panel shows the real-time state of the decision process: current direction of the Gann HiLo line, long setup detected, short setup detected, active pending orders, and operating status (searching, cooldown, waiting for fill, in market, out of session). The panel keeps updating even when trading is paused, so it never freezes.
Optionally, the advisor also draws the trigger and stop loss levels of the current setup on the chart.
Both elements are informational only and do not influence trading decisions. The panel automatically adapts to light and dark chart templates.
INCLUDED CONFIGURATION
The advisor's default parameters are prepared for XAUUSD on H1, trading long only. The advisor also supports short-only and both-directions trading, but that is not the delivered configuration.
For other instruments or timeframes, it is recommended not to change the configuration directly, but to validate any adjustment through a rigorous testing process before trading it live.
VALIDATION PROCESS
The configuration included for XAUUSD on H1 was developed through in-sample selection, out-of-sample confirmation, and an additional forward test on a later period not used during development.
The goal of this process is greater robustness of behavior, not fitting the system to a specific historical dataset.
REQUIREMENTS
- MetaTrader 5.
- Algorithmic trading enabled in the terminal and allowed on the account.
- Active connection to the broker's server.
- Extensive history on the symbol and timeframe being used, since the advisor rebuilds the trend over a window of bars on every evaluation.
- A broker providing tick value for the symbol, if volume is calculated as a percentage of risk.
- Sufficient free margin for the volume calculated for each trade.
HIGHLY RECOMMENDED
- Test on a demo account before trading on a live account.
- Test and fine-tune on a demo account using the actual capital you intend to trade with, since if the available capital is very small the system may not execute trades because the actual risk would exceed the configured limits, not because the EA is malfunctioning.
- Use this EA on XAUUSD on the H1 timeframe, although testing and validation on other symbols and timeframes is possible. The exact instrument name varies by broker (XAUUSD, GOLD, XAUUSD.m, among others); make sure to attach the EA to the chart corresponding to gold against the US dollar.
- Check the time offset of the broker's server relative to the schedule you want to apply, since the scheduled daily close, the Friday close, and the session filter are all calculated using the broker's server time, not the trader's local time.
- Use an account type with no commission per trade, although this is not mandatory.
- Use a VPS to keep the EA running continuously.
- Use a different magic number per chart if running several instances.
BEFORE BUYING
The free trial version can be run in the Strategy Tester. We recommend testing it on the instrument and broker you intend to trade with, and then on a demo account, adjusting risk to your available capital, before going live. Past results do not guarantee future results; trading financial products involves risk, and each trader is responsible for their own investment decisions.
For questions, parameter adjustments, or support, please use the MQL5 chat.
