Only stocks trading above their 220-day SMA qualify. The system buys when the close drops below an envelope set about 2.2% under the 20-day SMA, then sells when price closes above the matching upper envelope. Each trade is sized from USD 10,000 of capital.
Best run of 31. Visa, Daily, from run stock2-queue:2026-09-15-Visa.tsv:7.
| Period | Up to 2026-09-15 |
| Instrument | Visa, 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 |
| bandPeriod Envelope midline SMA length | 20 |
| envelopeDivisor Band offset is the midline divided by this (about 2.2%) | 45 |
| trendPeriod Long-term trend SMA length | 220 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| VisaBest run | Daily | 5.49 | 54 | 83.33 | 18,470 USD | -3,117 |
| Palantir | Daily | 5.66 | 24 | 83.33 | 16,912 USD | -2,959 |
| Cisco | Daily | 4.47 | 145 | 79.31 | 55,640 USD | -4,596 |
| Walmart | Daily | 3.89 | 179 | 62.01 | 90,209 USD | -7,997 |
| Broadcom | Daily | 3.81 | 87 | 79.31 | 31,304 USD | -4,149 |
| S&P 500 | Daily | 3.66 | 120 | 83.33 | 27,918 EUR | -3,204 |
| ExxonMobil | Daily | 3.60 | 150 | 74.00 | 35,358 USD | -2,863 |
| Applied Materials | Daily | 3.27 | 116 | 81.90 | 38,194 USD | -3,910 |
| Meta | Daily | 3.15 | 60 | 81.67 | 19,993 USD | -3,979 |
| Alphabet | Daily | 3.07 | 39 | 74.36 | 11,534 USD | -3,597 |
| Mastercard | Daily | 3.06 | 73 | 78.08 | 19,971 USD | -5,605 |
| Lam Research | Daily | 2.89 | 166 | 77.71 | 60,349 USD | -6,941 |
| Microsoft | Daily | 2.87 | 140 | 74.29 | 33,711 USD | -2,941 |
| Costco | Daily | 2.64 | 130 | 74.62 | 30,557 USD | -5,922 |
| Berkshire Hathaway | Daily | 2.56 | 71 | 78.87 | 13,965 USD | -3,418 |
| Oracle | Daily | 2.50 | 171 | 75.44 | 51,071 USD | -5,388 |
| Johnson & Johnson | Daily | 2.43 | 158 | 75.95 | 30,950 USD | -6,259 |
| Eli Lilly | Daily | 2.30 | 179 | 71.51 | 36,990 USD | -5,662 |
| Coca-Cola | Daily | 2.15 | 140 | 73.57 | 23,886 USD | -4,682 |
| Caterpillar | Daily | 1.99 | 193 | 72.54 | 34,614 USD | -5,872 |
| Chevron | Daily | 1.93 | 84 | 67.86 | 10,491 USD | -2,749 |
| Intel | Daily | 1.88 | 212 | 68.87 | 54,246 USD | -17,333 |
| Nvidia | Daily | 1.88 | 134 | 68.66 | 33,163 USD | -14,132 |
| JPMorgan | Daily | 1.69 | 161 | 73.29 | 23,616 USD | -6,574 |
| Amazon | Daily | 1.65 | 109 | 66.97 | 17,664 USD | -6,180 |
| Tesla | Daily | 1.57 | 68 | 63.24 | 12,690 USD | -7,249 |
| Micron | Daily | 1.47 | 166 | 73.49 | 27,390 USD | -13,305 |
| AMD | Daily | 1.46 | 196 | 70.92 | 33,193 USD | -14,672 |
| Bank of America | Daily | 1.40 | 95 | 68.42 | 9,579 USD | -6,236 |
| Apple | Daily | 1.34 | 143 | 64.34 | 13,935 USD | -9,974 |
| AbbVie | Daily | 1.33 | 37 | 56.76 | 2,507 USD | -4,255 |
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.
// ============================================================ // Dip In Uptrend // ProRealAlgos Strategy Library | prorealalgos.com // Type: Mean reversion // Direction: Long only // Timeframe tested: Daily // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- capitalPerTrade = 10000 // money committed to each trade bandPeriod = 20 // envelope midline length envelopeDivisor = 45 // band offset is the midline divided by this (about 2.2%) trendPeriod = 220 // long-term trend filter length // --- Indicators --- positionSize = capitalPerTrade / close midBand = Average[bandPeriod](close) bandOffset = midBand / envelopeDivisor upperBand = midBand + bandOffset lowerBand = midBand - bandOffset trendMA = Average[trendPeriod](close)
15 more lines: the entry and exit rules.
Read this first
Questions
Yes. The code sizes each trade as 10,000 divided by the close, so every position uses about the same capital.
Visa daily led with profit factor 5.49 and USD 18,469.84 over 54 trades. Every tested market was profitable, from Palantir (5.66) down to AbbVie (1.33).
With 10,000 per trade, Visa had a max drawdown of USD 3,117.24. Intel and AMD went deeper, at USD 17,333.32 and USD 14,672.40.
The 220-day trend filter and 20-day envelope are built for daily swings in large stocks. Intraday bars were not tested.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.