When Bollinger Band width (22) drops to its lowest of the last 2 bars, the system places a buy stop at the upper band for the next bar. It holds the trade until the close falls below the 165-day SMA. This is a slow, long-only swing system tested on daily charts of large US stocks and the S&P 500.
Best run of 31. Amazon, Daily, from run stock2-queue:2026-09-15-Amazon.tsv:9.
| Period | Up to 2026-09-15 |
| Instrument | Amazon, 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 Bollinger Band length | 22 |
| squeezeBars Band width must be the lowest of this many bars | 2 |
| exitPeriod Exit SMA length | 165 |
Every run
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| AmazonBest run | Daily | 14.30 | 86 | 43.02 | 386,898 USD | -361,369 |
| Palantir | Daily | 16.65 | 20 | 40.00 | 94,451 USD | -31,293 |
| Cisco | Daily | 13.86 | 103 | 50.49 | 225,807 USD | -41,136 |
| Meta | Daily | 13.76 | 28 | 50.00 | 46,969 USD | -10,472 |
| Mastercard | Daily | 10.32 | 40 | 52.50 | 80,788 USD | -23,544 |
| Nvidia | Daily | 7.16 | 102 | 27.45 | 202,659 USD | -36,363 |
| Broadcom | Daily | 5.04 | 35 | 40.00 | 47,678 USD | -9,468 |
| Tesla | Daily | 4.11 | 64 | 40.62 | 62,570 USD | -28,438 |
| Alphabet | Daily | 3.79 | 29 | 37.93 | 19,069 USD | -5,070 |
| Oracle | Daily | 3.72 | 148 | 33.78 | 100,248 USD | -24,550 |
| Applied Materials | Daily | 3.60 | 98 | 37.76 | 74,042 USD | -30,687 |
| Microsoft | Daily | 3.54 | 125 | 31.20 | 84,446 USD | -34,568 |
| AMD | Daily | 3.22 | 186 | 44.09 | 124,415 USD | -24,881 |
| Costco | Daily | 3.17 | 100 | 44.00 | 39,134 USD | -6,597 |
| Berkshire Hathaway | Daily | 3.02 | 75 | 46.67 | 21,168 USD | -9,905 |
| Bank of America | Daily | 2.93 | 89 | 40.45 | 35,213 USD | -7,319 |
| Visa | Daily | 2.86 | 39 | 35.90 | 21,413 USD | -6,405 |
| AbbVie | Daily | 2.71 | 39 | 43.59 | 11,391 USD | -5,999 |
| Lam Research | Daily | 2.65 | 127 | 39.37 | 89,157 USD | -32,344 |
| Caterpillar | Daily | 2.52 | 189 | 35.98 | 51,732 USD | -10,618 |
| Eli Lilly | Daily | 2.40 | 186 | 37.63 | 49,760 USD | -14,648 |
| S&P 500 | Daily | 2.23 | 183 | 30.05 | 28,567 EUR | -6,839 |
| Walmart | Daily | 1.99 | 239 | 22.18 | 49,448 USD | -43,858 |
| Johnson & Johnson | Daily | 1.99 | 214 | 31.31 | 30,738 USD | -9,947 |
| JPMorgan | Daily | 1.90 | 196 | 37.76 | 34,834 USD | -8,919 |
| ExxonMobil | Daily | 1.59 | 235 | 24.68 | 23,697 USD | -10,693 |
| Chevron | Daily | 1.12 | 111 | 28.83 | 2,671 USD | -9,124 |
| Apple | Daily | 0.55 | 77 | 5.19 | -10,740 USD | -23,393 |
| Intel | Daily | 0.48 | 6 | 16.67 | -11,000 USD | -21,000 |
| Coca-Cola | Daily | 0.45 | 91 | 6.59 | -10,165 USD | -17,369 |
| Micron | Daily | 0.28 | 27 | 25.93 | -10,755 USD | -14,397 |
Charts
Top 10 of 31 runs. The full list is in the table above.
Above 1.0 made money, below 1.0 lost money.
The code
// ============================================================ // Bollinger Squeeze // ProRealAlgos Strategy Library | prorealalgos.com // Type: Volatility // Direction: Long only // Timeframe tested: Daily // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- capitalPerTrade = 10000 // money committed to each trade bandPeriod = 22 // Bollinger Band length squeezeBars = 2 // band width must be the lowest of this many bars exitPeriod = 165 // exit when the close drops below this SMA // --- Indicators --- positionSize = capitalPerTrade / close bandWidthValue = BollingerBandWidth[bandPeriod](close) upperBand = BollingerUp[bandPeriod](close) exitMA = Average[exitPeriod](close)
14 more lines: the entry and exit rules.
Setup
Questions
Yes. The buy stop is re-placed every bar while the squeeze holds, which ProOrder handles, but the rewritten code has not been compile-checked, so backtest it first.
Thirty daily charts, mostly large US stocks plus the S&P 500. Amazon gave the best run with a profit factor of 14.3 over 86 trades, while Apple, Intel, Coca-Cola and Micron lost.
Each trade buys about 10,000 of stock, calculated as 10,000 divided by the close. With no stop in place, the best run still saw a max drawdown of USD 361,368.9.
The exit uses a 165-day SMA, so the system is built for multi-week trends. Daily data gave the full available history for each stock.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.