Join today
Strategies / Mean reversion / Dip In Uptrend

Dip In Uptrend Strategy

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.

Mean reversionLong onlySwingVisaDaily
5.49Profit factor
18,470Net profit USD
83.33%Win rate
54Trades
-3,117Max drawdown
342Avg trade

Best run of 31. Visa, Daily, from run stock2-queue:2026-09-15-Visa.tsv:7.

Entry rules, long

  1. Close is above the 220-day SMA
  2. Members only

Exit rules

  1. Members only
  2. No stop loss or target

Test conditions

PeriodUp to 2026-09-15
InstrumentVisa, Daily
Capital per trade10,000
CostsNot recorded for this run.
BarsDaily bars, full available history
Last tested2026-09-15

Parameters

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

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
VisaBest runDaily5.49 5483.3318,470 USD-3,117
PalantirDaily5.66 2483.3316,912 USD-2,959
CiscoDaily4.47 14579.3155,640 USD-4,596
WalmartDaily3.89 17962.0190,209 USD-7,997
BroadcomDaily3.81 8779.3131,304 USD-4,149
S&P 500Daily3.66 12083.3327,918 EUR-3,204
ExxonMobilDaily3.60 15074.0035,358 USD-2,863
Applied MaterialsDaily3.27 11681.9038,194 USD-3,910
MetaDaily3.15 6081.6719,993 USD-3,979
AlphabetDaily3.07 3974.3611,534 USD-3,597
MastercardDaily3.06 7378.0819,971 USD-5,605
Lam ResearchDaily2.89 16677.7160,349 USD-6,941
MicrosoftDaily2.87 14074.2933,711 USD-2,941
CostcoDaily2.64 13074.6230,557 USD-5,922
Berkshire HathawayDaily2.56 7178.8713,965 USD-3,418
OracleDaily2.50 17175.4451,071 USD-5,388
Johnson & JohnsonDaily2.43 15875.9530,950 USD-6,259
Eli LillyDaily2.30 17971.5136,990 USD-5,662
Coca-ColaDaily2.15 14073.5723,886 USD-4,682
CaterpillarDaily1.99 19372.5434,614 USD-5,872
ChevronDaily1.93 8467.8610,491 USD-2,749
IntelDaily1.88 21268.8754,246 USD-17,333
NvidiaDaily1.88 13468.6633,163 USD-14,132
JPMorganDaily1.69 16173.2923,616 USD-6,574
AmazonDaily1.65 10966.9717,664 USD-6,180
TeslaDaily1.57 6863.2412,690 USD-7,249
MicronDaily1.47 16673.4927,390 USD-13,305
AMDDaily1.46 19670.9233,193 USD-14,672
Bank of AmericaDaily1.40 9568.429,579 USD-6,236
AppleDaily1.34 14364.3413,935 USD-9,974
AbbVieDaily1.33 3756.762,507 USD-4,255

Charts

Results by run

Profit factor by run

Above 1.0 made money, below 1.0 lost money.

0.02.55.07.5101.0 = break-evenPalantir · Daily5.66Visa · Daily5.49Cisco · Daily4.47Walmart · Daily3.89Broadcom · Daily3.81S&P 500 · Daily3.66ExxonMobil · Daily3.60Applied Materials · Daily3.27Meta · Daily3.15Alphabet · Daily3.07Mastercard · Daily3.06Lam Research · Daily2.89Microsoft · Daily2.87Costco · Daily2.64Berkshire Hathaway · Daily2.56Oracle · Daily2.50Johnson & Johnson · Daily2.43Eli Lilly · Daily2.30Coca-Cola · Daily2.15Caterpillar · Daily1.99Chevron · Daily1.93Intel · Daily1.88Nvidia · Daily1.88JPMorgan · Daily1.69

Net profit against max drawdown

Net profitMax drawdown
0-20K-10K50K100KWalmart · DailyLam Research · DailyCisco · DailyIntel · DailyOracle · DailyApplied Materials · DailyEli Lilly · DailyExxonMobil · DailyCaterpillar · DailyMicrosoft · DailyAMD · DailyNvidia · DailyBroadcom · DailyJohnson & Johnson · DailyCostco · DailyS&P 500 · Daily

The code

ProBuilder, rewritten to house standard

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

Known weaknesses

  • There is no stop loss, so a dip that keeps falling is held until price recovers to the upper envelope.
  • The top run on Visa is based on only 54 trades, and Palantir only 24, so single outliers can shape the numbers.
  • Weaker names show the limits: AbbVie made USD 2,506.52 with a larger max drawdown of USD 4,255.21, and Apple had a profit factor of 1.34.
  • It is long only and depends on the long-term uptrend filter, so results come from a period when most of these stocks rose.

Indicators used

SMA

How to load it

  1. Copy the code with the copy button above the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Questions

About this strategy

Can I automate this in ProOrder?

Yes. The code sizes each trade as 10,000 divided by the close, so every position uses about the same capital.

Which stocks were tested?

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).

How much drawdown should I expect?

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.

Why daily bars?

The 220-day trend filter and 20-day envelope are built for daily swings in large stocks. Intraday bars were not tested.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Twelve Minus Two Momentum

Best run on the same market, Visa.

12.00 PF · 52 trades

Percent B Bollinger Trend

A similar profit factor.

5.43 PF · 3,202 trades

Want stock dip buying as part of a broader plan? Join the ProRealAlgos waitlist.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs