Free lesson · Charts & patterns
Quantitative recognition V: calibrate, abstain and test the complete strategy
Open interactive lessonPractice calculationsExplore labs
Start with the idea
A pattern match describes resemblance. A trading decision needs a forecast of an executable outcome and its costs.
Symbols, units & horizon
- p: calibrated probability of a winning executed trade under the stated rule
- W,L: positive conditional mean win and loss in dollars before the separately listed cost
- c: mean round-trip cost in dollars
- e: expected net dollars per trade
- all payoffs: matching trade horizon and position size
When and why to use this
Use a calibrated outcome model as one component of a strategy, followed by position sizing, execution constraints and an auditable ledger.
- Choose the target first: shape label, next-horizon direction, volatility, or a specific trade’s net outcome. These are different tasks.
- Train a small head on template distances, embeddings and context. Calibrate an outcome probability on a separate chronological validation segment using a method such as logistic recalibration or isotonic regression.
- A confidence of .8 for “hammer” is not an .8 probability that the next trade wins. Evaluate the actual target of the probability.
- Predeclare train, calibration/selection and test windows. Purge training labels whose outcome intervals reach into evaluation; separate overlapping events when estimating uncertainty.
- Choose probability and risk thresholds before the test. Ranking every timestamp by confidence across a completed test period is retrospective; use a validation-fixed threshold or a strictly trailing policy in a live-style replay.
- Keep an abstain/no-trade region. Compare coverage, precision-recall, calibration and net expectancy as separate measurements.
- Condition payoff estimates on the same rule and market state. Include spread, slippage, fees, missed fills, borrow and capacity in the simulated execution ledger.
- Use calendar blocks for uncertainty, report the full model/threshold search, and reserve a final untouched period. Compare matched exposure and turnover so abstention is not mistaken for superior forecasting.
- Promotion requires stable incremental net value, operational limits and a paper-trading trace. A sophisticated recognizer can still deserve a no-trade conclusion.
Quantitative recognition V: calibrate, abstain and test the complete strategy
- Expand the loss term: e=pW−L+pL−c.
- Collect terms in p: e=p(W+L)−(L+c).
- Require e>0. Since W+L is positive, division preserves the inequality.
- For W=10,L=20,c=1, break-even p=21/30=.7. At p=.6, expectancy=6−8−1=−3.
At p=.75 under these synthetic payoffs, expectancy=7.5−5−1=$1.50. A probability-estimation error or different execution costs can remove that apparent edge.
Use the rule
- Define an executable target and a simple baseline.
- Fit, calibrate and select on separate permitted history.
- Replay once on the final test and attribute any gain to features, decisions or execution.
Before moving on
Submit the feature timeline, model comparison, calibration plot, cost sensitivity, uncertainty estimate and promotion decision.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
def decision_threshold(win,loss,cost):
if win<=0 or loss<=0 or cost<0: raise ValueError("Positive payoffs and nonnegative cost required")
return (loss+cost)/(win+loss)
def net_expectancy(p,win,loss,cost):
if not 0<=p<=1: raise ValueError("Probability in [0,1] required")
decision_threshold(win,loss,cost)
return p*win-(1-p)*loss-cost
print(decision_threshold(10,20,1),net_expectancy(.75,10,20,1))Continue learning
Candles, Structures & Pattern Research — all lessons- First principles: what a candle actually records
- Doji, hammer, shooting star and long-body bars
- Engulfing, inside bars and multi-candle sequences
- Trends, ranges, breakouts and chart structures
- Indicators as arithmetic: ATR, moving averages, RSI and bands
- Known strategy families: from chart idea to complete rules
- Pattern recognition: rules, features, shapelets and image models
- Quantitative recognition I: build a causal candle feature table
- Quantitative recognition II: shapelets and constrained dynamic time warping
- Quantitative recognition III: causal encoders and contrastive learning
- Quantitative recognition IV: GAF images, CNNs, transformers and visual-model audits
- Quantitative recognition V: calibrate, abstain and test the complete strategy
- Research review: what the evidence does and does not establish
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations