Once price has swung more than 45 pips away from its last touch of the 8 EMA, the system places a limit order back near that average. It buys pullbacks after strong up swings and sells rallies after strong down swings. Every trade carries a 30 point stop and a 25 point target.
Best run of 5. Gold, 3 min, spread 0.6, from run pf:2026-09-15-GOLD-3m.tsv:1.
| Period | Up to 2026-09-15 |
| Instrument | Gold, 3 minutes |
| Spread | 0.6 points |
| Starting capital | 1,000,000 |
| Costs | Spread only. Commissions and overnight financing are not included. |
| Bars | Up to 200,000 bars, fewer where the instrument has less history |
| Last tested | 2026-09-15 |
| swingPeriod EMA length the swing is measured from | 8 |
| seedPeriod Bars used to seed the swing high / low on the first bar | 8 |
| swingTargetPips Swing size in pips that arms an entry | 45 |
| baseCapital Amount added to strategy profit before sizing | 3000 |
| riskFraction Share of capital used in the sizing formula | 0.02 |
| capitalPerContract Money per contract in the sizing formula | 30 |
| minPositionSize Minimum contracts per trade | 1 |
| stopLossPoints Protective stop in points | 30 |
| takeProfitPoints Profit target in points | 25 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| GoldBest run | 3 min | 1.26 | 253 | 60.08 | 1,894 EUR | -596 |
| Gold | 2 min | 1.23 | 209 | 59.81 | 1,350 EUR | -708 |
| Gold | 5 min | 1.19 | 285 | 58.60 | 1,516 EUR | -774 |
| Gold | 1 hour | 1.13 | 389 | 58.35 | 1,644 EUR | -1,199 |
| Gold | 1 min | n/a | 63 | 63.49 | 620 EUR | -350 |
Charts
Above 1.0 made money, below 1.0 lost money.
The code
// ============================================================ // EMA Swing Limit Entry // ProRealAlgos Strategy Library | prorealalgos.com // Type: Momentum // Direction: Long & short // Timeframe tested: 3 minutes // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = true DEFPARAM PreloadBars = 10000 // --- Parameters --- swingPeriod = 8 // EMA the swing is measured from seedPeriod = 8 // bars used to seed the swing high / low on the first bar swingTargetPips = 45 // swing size that arms an entry baseCapital = 3000 // added to strategy profit before sizing riskFraction = 0.02 // share of that capital put at risk capitalPerContract = 30 // money per contract in the sizing formula minPositionSize = 1 // never trade fewer contracts than this stopLossPoints = 30 // protective stop takeProfitPoints = 25 // profit target // --- Indicators --- ONCE swingHigh = Highest[seedPeriod](high) ONCE swingLow = Lowest[seedPeriod](low) swingMA = ExponentialAverage[swingPeriod](close) swingTarget = swingTargetPips * PipSize // Each touch of the EMA restarts the swing measurement. IF high > swingMA AND low < swingMA THEN touchBar = BarIndex touchPrice = swingMA swingHigh = swingMA swingLow = swingMA ENDIF IF low > swingMA THEN barsSinceTouch = max(1, BarIndex - touchBar) swingHigh = Highest[barsSinceTouch](high) swingLow = swingMA ENDIF IF high < swingMA THEN barsSinceTouch = max(1, BarIndex - touchBar) swingLow = Lowest[barsSinceTouch](low) swingHigh = swingMA ENDIF IF (swingHigh - touchPrice) > swingTarget AND swingHigh > swingMA THEN buySetup = 1 ENDIF IF (swingHigh - touchPrice) <= swingTarget THEN buySetup = 0 ENDIF IF (touchPrice - swingLow) > swingTarget AND swingLow < swingMA THEN sellSetup = -1 ENDIF IF (touchPrice - swingLow) <= swingTarget THEN sellSetup = 0 ENDIF // Limit orders sit one EMA slope beyond the EMA. slopeOffset = abs(round(swingMA - swingMA[1])) positionSize = max(minPositionSize, round(((StrategyProfit + baseCapital) * riskFraction) / capitalPerContract))
16 more lines: the entry and exit rules.
Setup
Questions
Yes. Entries are limit orders and the stop and target are coded, so it runs unattended once loaded.
Gold 3 minutes made 1,893.8 EUR over 253 trades. The 2 minute, 5 minute and 1 hour charts were also positive with profit factors between 1.13 and 1.23.
The worst drawdown on Gold 3 minutes was 596.1 EUR. Because size grows with profit, a drawdown late in a run can be larger than early on.
The 45 pip swing and 25 point target suit fast intraday moves in Gold. The 3 minute chart had the best profit factor of the timeframes tested.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.