Turtle System EA
The Turtles' "N" is the 20-period ATR, used everywhere instead of a fixed pip distance: entry is a breakout of the InpEntryBreakoutBars-bar high or low, the stop is InpUnitStopN times N from a unit's entry, and additional units are added every time price moves InpUnitAddN times N further in favour, up to InpMaxUnits. All of it scales automatically with how volatile the symbol currently is. The one deliberate departure from a naive port is how the stop is managed once more than one unit is open. Pinning each unit's stop to its own entry price, independently, means the earliest unit - the one with the most room - gets stopped first on a pullback the position as a whole would have survived, while later, tighter units survive it. That inverts the published rule, where the pyramid is meant to exit together. This EA instead re-pins every open unit's stop to 2N below (or above, when short) the most recently added unit's entry, and reapplies it to the whole group each time a new unit is added, so the position always exits as one block, not unit by unit in the wrong order. Exit is on the opposite, shorter Donchian channel (InpExitBreakoutBars), never the same channel that triggered entry - using one channel for both would mean a winning trade gets closed by the same threshold that opened it, the moment price pulls back to retest the breakout level. Position sizing follows the Turtles' own method: with InpUseRiskSizing on, each unit risks InpRiskPercentPerUnit of equity against its 2N stop distance, computed from MODE_TICKVALUE and MODE_TICKSIZE so it prices correctly on any instrument, not assuming a fixed contract size. Notes and limitations - Does not implement the Turtles' "skip a breakout that follows a winning trade" filter from either published system. Every qualifying breakout is taken. - Each unit is sent as a separate market order; a broker rejection on one add leaves the others untouched rather than aborting the whole pyramid. - The group stop is applied with OrderModify after each add, which can briefly leave a newly-opened unit unprotected between the OrderSend and the modify succeeding - by design, since MQL4 cannot set the group stop in the same call that opens the order. - Signals are evaluated once per closed bar, not on every tick. - Requires AutoTrading enabled and IsTradeAllowed() true; if trading is disabled the EA logs it and skips the entry or add.
Expert advisor · MT4 · v1.0 · Free
About Turtle System EA
Turtle System EA is an expert advisor (trading robot) for MetaTrader 4 based on ATR. It can size trades from your balance and risk percent and trades breakouts. It has 13 settings, such as Entry breakout bars, Exit breakout bars and Atr period. MQL source code included.
Files in the download: TurtleSystemEa.ex4, TurtleSystemEa.mq4, TurtleSystemEa.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Entry breakout bars | 55 | Donchian breakout period for entry (the "N-day high/low") |
| Exit breakout bars | 20 | Donchian breakout period for exit (opposite channel) |
| Atr period | 20 | ATR period used as the Turtles' "N" (average true range) |
| Unit stop n | 2.0 | Stop distance from the last unit's entry, in N |
| Unit add n | 0.5 | Distance the market must move, in N, before adding a unit |
| Max units | 4 | Maximum number of pyramided units in one direction |
| Use risk sizing | true | Size each unit by percent risk (the Turtles' own method) |
| Risk percent per unit | 1.0 | Percent of equity risked per unit's 2N stop, when risk sizing is on |
| Fixed lots per unit | 0.10 | Lot size per unit when risk sizing is off, or as a fallback |
| Magic number | 20260707 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Breakout · ATR · Channels & Envelopes · Trend · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code