Portfolio Strategies

Your portfolio starts with $10,000 by default. If you don't specify a time range, it defaults to the last 3 years on a daily timeframe.

Buying

If you don't specify an amount, the default is to buy $1,000 worth of shares per trade.

Buy a fixed number of shares

Purchase exactly N shares of a stock at the current price.

Buy 10 shares of AAPL when RSI drops below 30

Buy a dollar amount

Invest a specific dollar amount — buys as many whole shares as that amount allows.

Buy $1,000 of NVDA when price crosses above the 50-day SMA

Buy a percentage of portfolio

Invest a percentage of your total portfolio value (cash + holdings).

Buy 25% of portfolio in QQQ when MACD crosses bullish

Buy with all available cash

Go all-in with remaining cash. If no amount is specified, defaults to buying as many shares as cash allows.

Buy TSLA when earnings growth exceeds 30%

Selling

If you don't specify how much to sell, the default is to sell all shares of that stock.

Sell all shares

Close the entire position in a stock.

Sell all AAPL when RSI crosses above 70

Sell a fixed number of shares

Sell exactly N shares.

Sell 5 shares of MSFT when price drops below the 200-day SMA

Sell a percentage of your position

Sell a fraction of what you hold — useful for scaling out of winners.

Sell 50% of my NVDA when it's up 20% from entry

Sell everything

Close all open positions across all stocks.

Sell all positions when the S&P 500 drops below its 200-day SMA

Short Selling

Short a stock

Bet against a stock by selling shares you don't own. You profit when the price falls.

Short 10 shares of GME when RSI is above 80 and volume is declining

Cover a short position

Buy back shares to close your short. You lock in profit if the price dropped since you shorted.

Short 10 shares of GME when RSI is above 80, cover the short when RSI drops below 30

Cover all shorts

Close your entire short position in a stock.

Short $2,000 of TSLA when price drops below the 200-day SMA, cover all my shorts when price closes back above the 50-day SMA

Scaling In (Doubling Down)

Add to an existing position

Buy more of a stock you already hold — only triggers if you have an open position.

From 2020-01-01 to 2025-01-01 (daily):
- Buy $1,000 of SPY when RSI drops below 30
- Double down on SPY if price drops another 5% from my last buy
- Sell all when RSI crosses above 70

Multiple scale-in levels

Chain multiple add-to-position rules for aggressive dip buying.

From 2022-01-01 to 2025-01-01 (daily):
- Buy $2,000 of QQQ when price drops 10% from 52-week high
- Double down if price drops another 5% from last entry
- Double down again if price drops another 5% from last entry
- Sell all when price recovers to the 50-day SMA

Scaling Out (Partial Exits)

Take partial profits

Sell a portion of your position at different profit levels.

From 2021-01-01 to 2025-01-01 (daily):
- Buy $5,000 of AAPL when RSI drops below 25
- Sell 25% of AAPL when it's up 10% from entry
- Sell 50% of AAPL when it's up 20% from entry
- Sell all AAPL when it's up 30% from entry

Position Sizing

Default: $1,000 per buy if no amount is specified. Default sell: entire position.

MethodExampleWhat it does
Fixed sharesBuy 10 shares of AAPLAlways buys exactly 10 shares
Dollar amountBuy $1,000 of AAPLBuys as many shares as $1,000 allows
Portfolio %Buy 25% of portfolio in SPYInvests 25% of total portfolio value
Cash %Buy 50% of available cash in MSFTUses half of remaining cash
All-inBuy AAPLUses all available cash

Order Sizes & Whole Shares

Equities trade in whole shares, so a dollar amount buys as many full shares as it covers and leaves the rest in cash — $1,000 of a $300 stock buys 3 shares and leaves $100. When the amount won't cover a share, the buy waits until enough cash has piled up, then takes one: a $100 weekly buy of a $550 fund buys nothing for five weeks, then a single share.

Worth knowing

That first purchase spends more than the amount you named — a $100 buy taking a $550 share — because there is no way to spend exactly $100 on a $550 share. It comes out of cash already in the portfolio, so it can never overdraw you, but a single buy can be far larger than the recurring amount suggests.

If the cash still won't cover one share, the buy is skipped and counted under Buys Skipped (out of cash), so a plan that has stopped buying says so rather than quietly tracking uninvested cash. Crypto and forex trade fractionally and always buy the exact amount.

Starting Capital

Default: $10,000. Name a different amount:

Start with $50,000. Buy $5,000 of AAPL when RSI drops below 30, sell all when above 70.

Adding & Withdrawing Cash

Fund the portfolio partway through a backtest or draw it down, on any schedule you describe. Deposits count as capital paid in, not profit, and withdrawals as money removed, not loss — so your return is always measured against what you actually put in.

Recurring contributions (dollar-cost averaging)

Say when the money arrives and when it gets invested. Without a contribution, a recurring buy just drains the starting balance — $500 a week exhausts $10,000 in twenty weeks.

From 2020-01-01 to 2025-01-01 (daily):
- Add $500 to the portfolio on the last trading day of each month
- Buy $500 of VOO on the last trading day of each month

Keep the buy above one share price, or the whole-share rule means the plan never trades at all. The schedule is a condition like any other, so the backtest still runs on daily bars — a monthly-funded plan can sit alongside rules that need daily data:

From 2021-01-01 to 2025-01-01 (daily):
- Add $1,000 to the portfolio on the last trading day of each month
- Buy $1,000 of QQQ when RSI(14) drops below 30
- Sell all QQQ when RSI(14) rises above 70

Withdrawals

A withdrawal can only take cash that isn't invested — the backtest won't sell your holdings to fund it, so a fully-invested portfolio has nothing to give. Raise the cash in the same rule, before the withdrawal:

From 2015-01-01 to 2025-01-01 (daily):
- Start with $500,000, all invested in SPY on the first day
- At the end of every quarter, sell 1% of my SPY and withdraw $5,000

Order matters within the rule: the sale has to settle before the withdrawal runs. Splitting the two across separate conditions leaves the same gap. Any shortfall shows up as Withdrawals Short (no cash) — if that figure isn't zero, the drawdown you tested isn't the drawdown you got.

What the summary reports

StatWhat it means
DepositedCash added mid-backtest — money paid in, never counted as profit
WithdrawnCash taken out mid-backtest — money removed, never counted as a loss
Withdrawals Short (no cash)Money a withdrawal asked for but couldn't take, because it was invested
Total ContributedAll capital put in: starting cash plus deposits, less withdrawals

Schedules can be weekly, monthly, quarterly, or annual, at the start or end of the period. They land on real trading days — a month-end deposit falls on the 30th, the 31st, or the preceding Friday, whichever the market was actually open.

Cooldowns

By default, a buy condition can trigger every single bar. Use cooldowns to prevent overtrading.

From 2020-01-01 to 2025-01-01 (daily):
- Buy $1,000 of SPY when RSI drops below 30 (wait at least 5 bars between buys)
- Sell all when RSI crosses above 70