A long-only dip buyer for stocks in an uptrend. It buys when the close is at least 4% below the 40-bar high and still above the 215-day SMA. It sells once the close rises above the previous bar's 40-bar high.
Best run of 31. Visa, Daily, from run stock2-queue:2026-09-15-Visa.tsv:11.
| 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 |
| lookbackPeriod Bars used for the recent high | 40 |
| dipFactor Entry when close is below this fraction of the recent high | 0.96 |
| trendPeriod Length of the long-term trend average | 215 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| VisaBest run | Daily | 8.77 | 68 | 86.76 | 31,547 USD | -3,129 |
| Broadcom | Daily | 8.04 | 90 | 90.00 | 51,312 USD | -5,014 |
| Alphabet | Daily | 7.43 | 47 | 85.11 | 22,541 USD | -3,200 |
| Palantir | Daily | 5.85 | 39 | 89.74 | 31,703 USD | -7,609 |
| S&P 500 | Daily | 4.71 | 131 | 83.97 | 38,622 EUR | -3,221 |
| ExxonMobil | Daily | 4.54 | 164 | 82.32 | 60,435 USD | -7,442 |
| AbbVie | Daily | 4.35 | 46 | 82.61 | 15,385 USD | -4,051 |
| Mastercard | Daily | 4.32 | 84 | 85.71 | 34,229 USD | -5,998 |
| Microsoft | Daily | 4.13 | 171 | 83.63 | 74,863 USD | -5,848 |
| Walmart | Daily | 4.01 | 192 | 77.60 | 93,711 USD | -9,059 |
| Cisco | Daily | 3.98 | 173 | 89.60 | 83,419 USD | -11,676 |
| Meta | Daily | 3.96 | 69 | 86.96 | 30,635 USD | -7,256 |
| Johnson & Johnson | Daily | 3.72 | 177 | 80.23 | 60,396 USD | -6,286 |
| Amazon | Daily | 3.48 | 148 | 81.76 | 75,529 USD | -8,103 |
| Coca-Cola | Daily | 3.48 | 187 | 79.14 | 59,599 USD | -9,389 |
| Eli Lilly | Daily | 3.46 | 214 | 79.44 | 71,777 USD | -6,194 |
| Oracle | Daily | 3.16 | 200 | 84.00 | 95,961 USD | -13,187 |
| Lam Research | Daily | 3.14 | 206 | 86.89 | 99,336 USD | -8,982 |
| Berkshire Hathaway | Daily | 3.08 | 85 | 83.53 | 23,801 USD | -5,440 |
| Nvidia | Daily | 3.02 | 167 | 84.43 | 89,184 USD | -8,960 |
| Chevron | Daily | 2.89 | 94 | 73.40 | 22,683 USD | -5,786 |
| Costco | Daily | 2.75 | 133 | 80.45 | 40,881 USD | -5,829 |
| Intel | Daily | 2.49 | 202 | 79.70 | 93,131 USD | -16,667 |
| Tesla | Daily | 2.38 | 91 | 76.92 | 37,743 USD | -10,363 |
| Applied Materials | Daily | 2.25 | 139 | 84.89 | 49,844 USD | -15,944 |
| JPMorgan | Daily | 2.19 | 211 | 79.15 | 57,462 USD | -8,477 |
| Caterpillar | Daily | 2.15 | 203 | 76.35 | 52,401 USD | -6,431 |
| Apple | Daily | 2.07 | 181 | 76.80 | 54,038 USD | -12,520 |
| Micron | Daily | 2.02 | 237 | 85.65 | 95,503 USD | -15,970 |
| AMD | Daily | 1.57 | 226 | 77.43 | 64,012 USD | -19,651 |
| Bank of America | Daily | 1.28 | 102 | 75.49 | 9,841 USD | -18,419 |
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.
// ============================================================ // Four Percent Dip // 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 lookbackPeriod = 40 // window for the recent high dipFactor = 0.96 // buy when price is 4% below that high trendPeriod = 215 // long-term trend filter length // --- Indicators --- positionSize = capitalPerTrade / close recentHigh = Highest[lookbackPeriod](high) trendMA = Average[trendPeriod](close)
15 more lines: the entry and exit rules.
Read this first
Questions
Yes, entries and exits are simple close-based rules. The code was rewritten after testing and has not been compile-checked, so run a backtest first.
Thirty daily charts of large US stocks plus the S&P 500, and all of them were profitable. Visa was best, with USD 31,546.96 net over 68 trades.
Each trade buys about 10,000 of stock (10,000 divided by the close). The Visa run had a max drawdown of USD 3,129.
It keeps the system out of stocks in a long downtrend, so it only buys dips inside an existing uptrend on daily bars.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.