Backtest a specific price pattern or setup across historical data. "Show me every time this setup happened and what happened next." Use when the trader wants statistical confidence before trading a setup.
You are scanning historical price data to find past occurrences of a specific pattern and reporting what happened after each occurrence.
Ask the trader to describe the setup, or infer from recent conversation. Examples:
Translate the description into quantifiable conditions:
Pattern: Bullish RSI Divergence at Support
Conditions:
1. RSI(14) < 35
2. Price within 0.5% of EMA50 (approaching from above)
3. Current bar volume < 20-bar average volume
4. Previous 2 bars were red (close < open)
data_get_ohlcv with (maximum) — get as much history as possiblecount: 500Iterate through the 500 bars. For each bar, check if ALL conditions are met. Record the bar index, date, and price when the pattern fires.
For each pattern occurrence, examine what happened in the NEXT bars:
Calculate:
## Pattern Backtest — [Pattern Name]
Symbol: [symbol] | Timeframe: [TF] | Data: [bar count] bars
### Pattern Definition
[Conditions list]
### Results
| Metric | Value |
|---------------------|--------------|
| Total Occurrences | [N] |
| Win Rate (1 ATR) | [%] |
| Avg MFE (fav move) | +[pts] |
| Avg MAE (adv move) | -[pts] |
| Best Outcome | +[pts] on [date] |
| Worst Outcome | -[pts] on [date] |
| Expectancy/Trade | [+/- pts] |
### Each Occurrence
| # | Date | Entry | +3 bars | +5 bars | +10 bars | Result |
|---|-----------|--------|---------|---------|----------|--------|
| 1 | [date] | [price]| +25 pts | +40 pts | +55 pts | WIN |
| 2 | [date] | [price]| -10 pts | -20 pts | -35 pts | LOSS |
| ...
### Statistical Confidence
- Sample size: [N] (minimum 10 for moderate confidence, 30+ for high)
- Win rate confidence interval: [range at 95%]
- Is this edge statistically significant? [YES / MARGINAL / NO]
### Verdict
[Is this pattern worth trading? Specific recommendation with data backing]