Writing Strategies

Your strategy prompt can be as simple or complex as you want. Use plain English with dashes to define conditions — Vertex Street interprets the logic and builds the backtest for you.

Basic structure

A strategy is a set of rules describing when to buy and when to sell. Use dashes to list conditions:

From 2020-01-01 to 2025-01-01 (daily):
- Buy AAPL when RSI(14) < 30 and price is above the 200-day SMA
- Sell when RSI(14) > 70 or price drops 5% from entry

Multiple conditions

Stack as many conditions as you need. All conditions on a single buy/sell line must be true simultaneously:

From 2019-01-01 to 2025-01-01 (daily):
- Buy SPY when:
  - RSI(14) < 30
  - Price is above the 200-day SMA
  - MACD histogram is positive
  - Volume is 1.5x above the 50-day average
- Sell all when RSI(14) > 70

Multi-asset strategies

You can trade multiple assets with different rules:

From 2018-01-01 to 2025-01-01 (daily):
- Buy AAPL when P/E ratio < 20 and revenue growth > 10%
- Buy MSFT when price crosses above the 50-day SMA
- Sell AAPL when P/E ratio > 35
- Sell MSFT when price crosses below the 50-day SMA

Doubling down on existing positions

Use "double down" or "add to position" to increase your stake without re-triggering the initial buy condition. This only fires if you already hold the asset:

From 2021-01-01 to 2025-01-01 (daily):
- Buy SPY when RSI(14) < 30 and price > 200-day SMA
- Double down on SPY if price drops another 5% from my last buy
- Sell all SPY when RSI(14) > 70

The double down rule is independent — it won't open a new position, it only adds to one you already hold. You can chain multiple levels:

From 2022-01-01 to 2025-06-01 (daily):
- Buy 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

Position sizing

Specify how much to invest per trade:

From 2020-06-01 to 2025-01-01 (daily):
- Buy $2,000 of NVDA when earnings growth > 25% and P/E < 40
- Buy 50% of available cash in TSLA when RSI < 25
- Sell half my NVDA when it's up 30% from entry
- Sell all TSLA when price breaks below 200-day SMA

Time-based conditions

Mix time and technical conditions:

From 2020-01-01 to 2025-01-01 (daily):
- Buy VTI on the first trading day of each month
- Sell all if the S&P 500 drops more than 3% in a single week
- Re-buy after 5 trading days if price is above the 20-day SMA

Funding the strategy

Add money to the portfolio on a schedule, or take it out. Deposits count as capital you paid in rather than as gains, so the return still reflects how the strategy performed. The schedule is just another condition, so the backtest keeps running on daily bars:

From 2020-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 VTI on the last trading day of each month
- Withdraw $2,000 at the end of every year

See Portfolio Strategies for withdrawals from a fully-invested portfolio and what the summary reports.

Date-anchored windows

Some questions aren't about a rule firing on a signal — they're about a kind of date. When does the price usually bottom out relative to a dividend? What happens either side of earnings? Ask for the timing around a set of dates and Vertex Street lines every one of them up on the same axis — trading day −10 through +10, where 0 is the event — and averages the path across all of them. You get one row per offset, plus the entry and exit that would have paid best across the whole sample.

The dates can come from a company's dividend history, its earnings announcements, or a list you type out yourself.

Around ex-dividend dates

For Coca-Cola over the last 10 years, what's the best time to buy relative to its ex-dividend dates?

The ex-dividend date is the one that matters — it's the day the price drops by roughly the dividend, and the last day you can buy and still be paid. Expect to see that drop in the table: it is mechanical, not a loss, because the money left the company and went to shareholders. Ask for total return if you want it netted back out.

Around earnings announcements

How does NVDA typically trade in the two weeks before and after an earnings announcement? Use the last 8 years.

Earnings reactions run longer than dividend ones, so a wider window is usually worth asking for. Name the window in trading days and it will be used as given.

Around dates you choose

Take SPY on 2024-01-16, 2024-06-11 and 2024-11-05. On average, when would the best time to buy have been around those three dates?

Any list of dates works — Fed meetings, product launches, the days you actually bought. Three dates describe those three dates and nothing more, though: with a handful of events the "best" window is mostly luck, which is what the summary's event count and t-statistic are there to tell you.

Reading the result

The best entry and exit are found by testing every pair of days in the window against the same history they are then scored on. That makes the headline return a description of the past, not a rule that repeats — a wide enough search will always find something. Three numbers on the summary card tell you whether it means anything:

  • Events Measured — how many dates went into the average. Ten is thin; forty starts to be worth reading.
  • Random-Day Baseline — what the same holding period returned starting on any day in the range. If the window barely beats it, the event isn't doing the work, the stock's general drift is. Edge vs Baseline is the difference.
  • t-stat — how large the average is next to how much it varied. Under about 2, the pattern is indistinguishable from noise however good the average looks.

Dates that don't have a full window either side — an event too close to the start or end of the price history — are left out of the average rather than filled in, and the count of what was skipped is reported alongside.

Combining fundamentals and technicals

From 2019-01-01 to 2025-01-01 (daily):
- Buy AMZN when:
  - Revenue growth > 15%
  - Free cash flow is positive
  - RSI(14) < 40
  - Price is within 10% of 52-week low
- Sell when P/E > 60 or price drops 15% from peak