A close above the 30-bar high arms a buy for the next 10 bars, but only while price is above the 200-day SMA. The position rides until a 90-bar low breaks, or a tighter 20-bar low once the trade is more than 2 x ATR(5) in profit, or price falls below the 200-day SMA.
Best run of 31. Apple, Daily, from run stock2-queue:2026-09-15-Apple.tsv:12.
| Period | Up to 2026-09-15 |
| Instrument | Apple, Daily |
| Capital per trade | 10,000 |
| Costs | Not recorded for this run. |
| Bars | Daily bars, full available history |
| Last tested | 2026-09-15 |
| capitalPerTrade Money committed to each trade | 10000 |
| channelPeriod Breakout above the highest high of this many bars | 30 |
| wideExitPeriod Default exit: lowest low of this many bars | 90 |
| tightExitPeriod Tighter exit once the trade is well in profit | 20 |
| trendPeriod Only trade above this moving average | 200 |
| atrPeriod ATR length for the profit test | 5 |
| atrMultiplier Profit in ATRs that switches to the tight exit | 2 |
| maxArmBars A breakout stays valid this many bars | 10 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| AppleBest run | Daily | 6.28 | 70 | 64.29 | 93,926 USD | -7,379 |
| Palantir | Daily | 9.02 | 7 | 42.86 | 28,465 USD | -9,612 |
| Alphabet | Daily | 5.88 | 27 | 59.26 | 16,092 USD | -2,370 |
| Nvidia | Daily | 4.34 | 52 | 51.92 | 79,222 USD | -16,336 |
| Tesla | Daily | 3.57 | 43 | 27.91 | 61,281 USD | -17,363 |
| Cisco | Daily | 3.35 | 71 | 49.30 | 52,801 USD | -10,850 |
| Micron | Daily | 3.18 | 80 | 33.75 | 96,446 USD | -16,281 |
| Amazon | Daily | 3.13 | 66 | 39.39 | 60,380 USD | -33,937 |
| AMD | Daily | 2.92 | 84 | 32.14 | 105,799 USD | -16,864 |
| Meta | Daily | 2.91 | 28 | 42.86 | 21,548 USD | -6,268 |
| Broadcom | Daily | 2.80 | 38 | 47.37 | 25,113 USD | -7,429 |
| Walmart | Daily | 2.78 | 110 | 33.64 | 57,900 USD | -12,857 |
| Mastercard | Daily | 2.62 | 41 | 43.90 | 20,947 USD | -5,245 |
| Lam Research | Daily | 2.58 | 70 | 47.14 | 62,987 USD | -16,277 |
| Microsoft | Daily | 2.47 | 89 | 42.70 | 47,028 USD | -12,582 |
| Applied Materials | Daily | 2.43 | 61 | 32.79 | 37,618 USD | -16,953 |
| S&P 500 | Daily | 2.40 | 125 | 42.40 | 26,657 EUR | -2,841 |
| Berkshire Hathaway | Daily | 2.38 | 71 | 42.25 | 19,658 USD | -5,515 |
| Visa | Daily | 2.28 | 38 | 34.21 | 12,889 USD | -4,096 |
| Oracle | Daily | 2.23 | 101 | 34.65 | 58,513 USD | -20,235 |
| AbbVie | Daily | 2.18 | 30 | 43.33 | 9,910 USD | -2,855 |
| Caterpillar | Daily | 2.00 | 134 | 29.10 | 47,133 USD | -8,763 |
| Costco | Daily | 1.88 | 83 | 43.37 | 19,972 USD | -6,690 |
| Johnson & Johnson | Daily | 1.83 | 130 | 35.38 | 22,992 USD | -6,301 |
| ExxonMobil | Daily | 1.78 | 120 | 30.83 | 24,076 USD | -6,020 |
| Eli Lilly | Daily | 1.59 | 132 | 36.36 | 23,066 USD | -13,292 |
| Coca-Cola | Daily | 1.44 | 145 | 33.10 | 16,236 USD | -8,964 |
| JPMorgan | Daily | 1.36 | 131 | 31.30 | 16,963 USD | -14,477 |
| Chevron | Daily | 1.15 | 81 | 32.10 | 3,747 USD | -10,348 |
| Bank of America | Daily | 0.54 | 42 | 28.57 | -10,081 USD | -15,787 |
| Intel | Daily | 0.00 | 3 | 0.00 | -10,833 USD | -10,833 |
Charts
Above 1.0 made money, below 1.0 lost money.
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.
// ============================================================ // Breakout Regime Filter // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long only // Timeframe tested: Daily // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- capitalPerTrade = 10000 // money committed to each trade channelPeriod = 30 // breakout above the highest high of this many bars wideExitPeriod = 90 // default exit: lowest low of this many bars tightExitPeriod = 20 // tighter exit once the trade is well in profit trendPeriod = 200 // only trade above this moving average atrPeriod = 5 // ATR length for the profit test atrMultiplier = 2 // profit in ATRs that switches to the tight exit maxArmBars = 10 // a breakout stays valid this many bars // --- Indicators --- positionSize = capitalPerTrade / close atrValue = AverageTrueRange[atrPeriod](close) channelHigh = Highest[channelPeriod](high)[1] wideExitLevel = Lowest[wideExitPeriod](low)[1] tightExitLevel = Lowest[tightExitPeriod](low)[1] regimeUp = close > Average[trendPeriod](close) ONCE inTrade = 0 ONCE armed = 0 ONCE armAge = 99 ONCE entryPrice = 0
34 more lines: the entry and exit rules.
Read this first
Questions
Yes, it runs in ProOrder on daily bars and sizes each trade as 10000 divided by the close. The rewritten code has not been compile checked yet.
It was tested on daily charts of large US stocks plus the S&P 500, and 28 of the 30 runs were profitable. Apple was best at USD 93,926.36 with a profit factor of 6.28, while Bank of America and Intel lost money.
With 10000 USD per trade, Apple had a maximum drawdown of USD 7,379.23. Other stocks went deeper, such as Tesla at USD 17,363.14.
The 200-day SMA filter and the 90-bar exit are built for multi week swings. On daily charts the system holds trends for weeks and trades only a few times a year.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.