Resistance Breacher buys when price closes above the last confirmed swing high made while above the 47 SMA and 53 EMA, with Stochastic(8,3) above 45 and a gently rising 8 EMA. Shorts use the mirror image. Stops and targets are multiples of ATR(10), and every trade closes on the first bar of a new day.
Best run of 4. Brent Crude, 4 hours, spread 3, from run pf:2026-09-15-BRENT-4h.tsv:3.
| Period | Up to 2026-09-15 |
| Instrument | Brent Crude, 4 hours |
| Spread | 3 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-16 |
| baseSize Lots after a winning trade | 2 |
| afterLossSize Lots after one or two losing trades | 3 |
| afterThreeLossesSize Lots after three losing trades in a row | 2 |
| afterTwoWinsSize Lots after two winning trades in a row | 1 |
| afterSixLossesSize Lots after six losing trades in a row | 5 |
| afterSixWinsSize Lots after six winning trades in a row | 1 |
| stochPeriod Stochastic length | 8 |
| stochSmooth Stochastic smoothing | 3 |
| slopePeriod EMA used to measure the short-term slope | 8 |
| longStochLevel Longs need the stochastic above this | 45 |
| shortStochLevel Shorts need the stochastic below this | 65 |
| minSlope Minimum bar-to-bar EMA change ratio | 1.0002 |
| maxSlope Maximum bar-to-bar EMA change ratio | 1.0005 |
| smaPeriod Simple average used for swing tracking | 47 |
| emaPeriod Exponential average used for swing tracking | 53 |
| atrPeriod ATR length for stop and target | 10 |
| longStopAtr Long stop in ATR multiples | 3.5 |
| longTargetAtr Long target in ATR multiples | 12 |
| shortStopAtr Short stop in ATR multiples | 6.5 |
| shortTargetAtr Short target in ATR multiples | 3.5 |
| minStopDistance Skip trades whose stop would be smaller than this | 20 |
| skipLongDay Longs only on weekdays after this number (skips Monday) | 1 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| Brent CrudeBest run | 4 hours | 1.58 | 142 | 60.56 | 4,630 EUR | -1,654 |
| Gold | 1 min | 1.16 | 635 | 60.79 | 1,827 EUR | -653 |
| Dow Jones | 1 hour | 1.09 | 977 | 48.93 | 16,253 EUR | -13,477 |
| Nikkei 225 | 1 min | 1.05 | 1,346 | 46.51 | 20,011 USD | -17,262 |
Charts
Above 1.0 made money, below 1.0 lost money.
Longer history
Gold 1 minute had the full 1,000,000 bars, and profit shrank to EUR 553.40 from EUR 1,826.70 in the standard run because the older data alone lost EUR 1,273.30.
| Bars available | 1,000,000 |
| Net, standard 200,000-bar run | 1,826.70 EUR |
| Net, long run | 553.40 EUR |
| Net on the older data alone | -1,273.30 EUR |
The code
Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.
// ============================================================ // Resistance Breacher // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long & short // Timeframe tested: 4 hours // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 1000 // --- Parameters --- baseSize = 2 // lots after a winning trade afterLossSize = 3 // lots after one or two losing trades afterThreeLossesSize = 2 // lots after three losing trades in a row afterTwoWinsSize = 1 // lots after two winning trades in a row afterSixLossesSize = 5 // lots after six losing trades in a row afterSixWinsSize = 1 // lots after six winning trades in a row stochPeriod = 8 // stochastic length stochSmooth = 3 // stochastic smoothing slopePeriod = 8 // EMA used to measure short-term slope longStochLevel = 45 // longs need the stochastic above this shortStochLevel = 65 // shorts need the stochastic below this minSlope = 1.0002 // EMA must move at least this ratio bar to bar maxSlope = 1.0005 // and less than this ratio, so the move is not stretched smaPeriod = 47 // simple average for swing tracking emaPeriod = 53 // exponential average for swing tracking atrPeriod = 10 // ATR length for stop and target longStopAtr = 3.5 // long stop in ATR multiples longTargetAtr = 12 // long target in ATR multiples shortStopAtr = 6.5 // short stop in ATR multiples shortTargetAtr = 3.5 // short target in ATR multiples minStopDistance = 20 // skip trades whose stop would be smaller than this skipLongDay = 1 // longs only after this weekday number (skips Monday) // Swing state carried from bar to bar ONCE setupReady = 0 ONCE swingLow = 0 ONCE confirmedLow = 0 ONCE swingHigh = 0 ONCE confirmedHigh = 0 ONCE stopDistance = 0 ONCE targetDistance = 0 // --- Indicators --- stochK = Stochastic[stochPeriod, stochSmooth](close) slopeMA = ExponentialAverage[slopePeriod](close) smaFilter = Average[smaPeriod](close) emaFilter = ExponentialAverage[emaPeriod](close) atrValue = AverageTrueRange[atrPeriod] // Size up after losses and down after wins. positionSize = baseSize IF PositionPerf(1) < 0 THEN positionSize = afterLossSize ENDIF IF PositionPerf(1) < 0 AND PositionPerf(2) < 0 AND PositionPerf(3) < 0 THEN positionSize = afterThreeLossesSize ENDIF IF PositionPerf(1) > 0 AND PositionPerf(2) > 0 THEN positionSize = afterTwoWinsSize ENDIF IF PositionPerf(1) < 0 AND PositionPerf(2) < 0 AND PositionPerf(3) < 0 AND PositionPerf(4) < 0 AND PositionPerf(5) < 0 AND PositionPerf(6) < 0 THEN positionSize = afterSixLossesSize ENDIF IF PositionPerf(1) > 0 AND PositionPerf(2) > 0 AND PositionPerf(3) > 0 AND PositionPerf(4) > 0 AND PositionPerf(5) > 0 AND PositionPerf(6) > 0 THEN positionSize = afterSixWinsSize ENDIF
61 more lines: the entry and exit rules.
Read this first
Questions
Yes, it runs automatically including the streak-based sizing. Review the lot sizes (base 2, up to 5) against your account before going live.
Brent Crude 4 hours made 4,630.30 EUR with a profit factor of 1.58. Gold 1 minute, Dow Jones 1 hour and Nikkei 225 1 minute were positive but with profit factors between 1.05 and 1.16.
Brent Crude 4 hours had a max drawdown of 1,654.40 EUR with sizes between 1 and 5 lots and a 3 point spread. Dow Jones 1 hour reached 13,476.80 EUR.
Swing highs on 4 hour bars mark levels that other traders watch, and the ATR(10) stops are wide enough to avoid noise. That chart gave the best profit factor, 1.58.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.