# Edge Quant Turtle Portfolio for MT5

This Expert Advisor implements the breakout rules from the supplied HowToTrade PDF and includes two separate original-rule modes based on Curtis Faith’s rulebook. [HowToTrade PDF](https://howtotrade.com/wp-content/uploads/2024/10/The-Turtle-Trading-strategy.pdf) · [Curtis Faith’s Original Turtle Trading Rules](https://www.tradingwithrayner.com/wp-content/uploads/2014/11/OriginalTurtleRules.pdf)

| `InpMode` | Entry | Exit | Default unit sizing and additions |
|---|---|---|---|
| `PDF20_10` | Break above the previous 20 session highs or below the lows | Touch the opposite 10-session channel or the 2N protective stop | One position per symbol. One N targets 0.5% of allocated account equity, so the original 2N stop implies about 1% initial price risk before fees, gaps and slippage. |
| `FaithS1` | Two-sided 20-session breakout after a losing theoretical signal. After a theoretical winner, wait for the 55-session breakout. | Opposite 10-session breakout or each unit’s protective stop | One N targets 1% of allocated equity at each order by default. Add at 0.5N from the last actual fill, up to four units. |
| `FaithS2` | Two-sided 55-session breakout, unfiltered | Opposite 20-session breakout or each unit’s protective stop | Same as `FaithS1`. |

The PDF describes an ATR-based stop and typical 1–2% trade risk without giving the ATR period, exact multiplier, or pyramiding mechanics. The PDF implementation uses Wilder 20 and 2N to make it executable. Pyramiding is confined to the two original-rule modes. Those modes freeze N at entry, place each new stop at 2N from its actual fill, and move earlier unit stops by 0.5N. A gap can leave different units with different stops. `InpWeeklySizingSheet` approximates the original weekly refresh of N. `InpCapital=AnnualNotional` enables optional annual sizing and 20% notional reductions at successive 10% loss thresholds. The default uses current account equity.

1. In MT5, open **File → Open Data Folder**. Put `EdgeQuantTurtlePortfolio.mq5` in `MQL5/Experts`, open it in MetaEditor and press **F7**. The supplied `EdgeQuantTurtlePortfolio.ex5` targets X64 Regular. The original-rule modes need a hedging account for separate stops. The PDF mode also accepts a netting account. Keep the selected symbols separate from manual and other automated trading on a netting account.
2. Leave `InpBrokerSymbols` blank to run the chart symbol, or enter exact broker names separated by commas, for example `EURUSD,GBPUSD,US500,XAUUSD,BTCUSD`. Names often differ by broker. Configure same-direction correlation buckets with `InpCloseGroups` and `InpLooseGroups`, for example `XAUUSD,XAGUSD;US500,NAS100`. An empty group input leaves that cap unconfigured. The original-rule modes default to a four-unit symbol cap and a twelve-unit same-direction cap across the common magic. Configured close and loose buckets allow up to six and ten same-direction units. Different instances using the same magic must coordinate their symbol lists, group definitions, and settings. Use a separate magic for a separate system and avoid duplicate management of any symbol.
3. In Strategy Tester, choose **Every tick based on real ticks**, your broker’s symbols, and the intended deposit and currency, for example **100,000 EUR**. The EA obtains one-N profit/loss in deposit currency from `OrderCalcProfit`, rounds lots down, and checks broker stops, spread, and margin. Lot minimums can prevent otherwise valid trades. Confirm the broker’s historical sessions, tick coverage, commission, financing and contract sizes before comparing results.
4. Single-symbol charts consume their native tick events. A basket also samples the latest quote of each configured symbol on host ticks and a timer outside the tester. `InpUseTimerInTester` is optional and off by default because periodic callbacks are expensive on long tests. A sampled basket can miss intermediate ticks and impose the configured symbol order when several signals are visible together. This EA is separate from the Python research simulator and need not reproduce its intrabar assumptions, fills, financing or results.

Order actions outside Strategy Tester require `InpAllowOrdersOutsideTester=true` and MT5’s account and Algo Trading permissions. The EA uses completed broker D1 bars; a broker’s daily boundary can differ from the research feed. `FaithS1` initializes theoretical history from available daily OHLC, skips ambiguous historical days that touched both entry barriers without a gap direction, and then updates the filter from observed ticks. After a restart with missing campaign metadata, the EA keeps broker stops and channel exits but freezes additions until flat.

The source compiles in MetaEditor with zero errors and zero warnings. The compiled EA has not been run in the broker Strategy Tester for this release.
