RealTest User Guide
RealTest User Guide

 

 

 

 

 

Factor Scan is a Trade Plot display type that batch-tests a whole list of setup-day indicators — “factors” — against a test’s trade list, and ranks them by how well each one would have filtered the trades. It automates what the Equal Count Bins and Equal Range Bins plots let you do one formula at a time: instead of typing an expression into the Formula field and eyeballing the bars, you tag any number of Trades-section formulas with {factor}, and one scan finds the most profitable cutoff for every one of them.

The intended workflow is to run a loosely-defined “backbone” version of a strategy — minimal filters, simple fixed sizing, as many trades as practical — then use Factor Scan to discover which conditions, applied at entry time, would most improve the average trade. Promising rows translate directly into EntrySetup conditions.

The idea for this feature came from Dave Mabe, and it is included in RealTest with his kind permission.

Tagging Factors

A factor is any numeric formula in a Trades section (in your strategy script, an included file, or the default Trades.rts) marked with the {factor} attribute:

Trades:
    Bars:           {#}             T.Bars
    PctGain:        {%-2}           T.NetPct
 
    f_rsi14:        {factor}        RSI(14)
    f_atr_pct:      {factor}        ATR(14) / C
    f_dist50:       {factor}        C / Avg(C, 50) - 1
    f_vol_ratio:    {factor}        V / Avg(V, 20)
    f_range252:     {factor}        (C - Lowest(L, 252)) / (Highest(H, 252) - Lowest(L, 252))

{factor} can stand alone or combine with format attributes: {factor, format: percent, places: 2}.

A {factor} formula is evaluated as of the trade’s setup — the last completed bar before the entry — everywhere it appears: in the scan, and as a Trades window column. No [1] or [T.Bars+1] offset is needed to avoid look-ahead.

Untagged Trades-section formulas keep their usual behavior: they see the trade’s exit bar as the current bar. To show both readings of the same indicator, define it twice — once tagged, once not.

Because tagged columns show exactly the values the scan used, the Trades window and its CSV export are the scan’s ground truth: a trade list saved with factor columns is a complete research dataset (outcomes plus setup-day factors) for outside analysis.

String-valued formulas are ignored by the scan.

Prefer scale-free factors — ratios, oscillators, percent distances, positions in range — over raw levels. A price-denominated factor (a moving average, a band, C itself) mostly measures share price, so a battery full of them will “discover” the same price effect many times over. The Ovlp column (below) exposes this, but a well-chosen battery avoids it.

Running a Scan

Open Trade Plots for a test as usual (right-click it in a Results Window and choose Show Trade Plots), then select the Factor Scan tab, press G, or choose it from the Plot menu or the Plot Type option.

The factors come from the currently active Trades section — the same source as the Trades window columns — not from the script that originally ran the test. This means you can apply any script containing tagged factors and immediately scan any test in your results list, including old ones: run the backbone test once, then iterate on the factor list freely. Applying a changed Trades section automatically rescans any open Factor Scan plots.

The first scan evaluates every factor for every trade (a progress message shows each factor; Esc stops early and keeps what finished). The values are then buffered for the window, so everything after that first pass — changing the trade value mode, clicking rows, adjusting options — is instant. Factors are only re-evaluated when the Trades section is re-applied.

If a trade’s symbol isn’t in the currently loaded data, or the factor has no value on the setup bar (for example, not enough history), that trade is skipped for that factor and counted in the title bar and log.

If the active Trades section has no {factor} items, or the test has too few trades to scan, the plot area simply says so — the window still opens and the other plot types work as usual.

Reading the Results

The left panel lists every factor, best first:

Column

Meaning

Factor

The formula’s name from the Trades section.

Dir

Which side of the cutoff is kept: >= keeps trades with values at or above the cutoff, <= at or below.

Cutoff

The factor value at the best split point found.

Pctl

The same cutoff as a percentile of the factor’s ranked values — 20% with <= means “keep the bottom fifth of trades by this factor.” This is the portable way to state a threshold; the raw value is just where that percentile landed in this sample.

Kept

Trades retained / trades that had a value for this factor. A trailing * means the cutoff is pinned at the retention floor (see Min Kept below): the average was still improving when the floor stopped it, so read the row as “more extreme is better, as far as could be measured,” not as a precise optimum.

Avg

Average gain per kept trade, in the current trade value mode.

Edge

Avg minus the baseline (the average over all of this factor’s evaluated trades). Rows are ranked by Edge — how much the filter improves on doing nothing.

OOS

An out-of-sample check: the cutoff is re-fit using only the first (chronological) half of the trades, then scored on the second half alone. A large Edge with an OOS near or below the baseline suggests the edge did not persist. n/a appears when either half has too few trades.

Ovlp

How much this row’s kept trades overlap the row ranked just above it. High overlap means the two factors selected largely the same trades — one finding echoed, not two independent ones.

Click a row — or press Up/Down — to show that factor’s cutoff profile in the plot pane. (In Factor Scan mode the arrow keys move the factor selection; in every other plot mode they move to the next or previous test as usual.)

The Cutoff Profile Plot

The plot shows the selected row’s whole story rather than just its single best number:

The green line traces the average gain of the kept trades at every possible cutoff. For a <= row, the value at x = 30 is the average gain of the bottom 30% of trades by that factor. At the keep-everything end the line meets the baseline average (also drawn as a dotted horizontal line).

The magenta bar marks the chosen cutoff from the table.

A smooth, gradual curve indicates a broad, well-behaved effect; a narrow spike at one threshold is more likely noise.

The Sort By (X axis) choice controls the horizontal scale:

Percentile (or Trade Number) — cutoffs from 0 to 100 percent of trades. Press I (or T).

Formula — the raw factor values. Press F. Note that a factor with outliers will compress most of the curve into one end of a value axis; that distortion is itself informative, and is why the percentile scale is the default view.

The crosshair (X) works in either mode.

The Scoring Metric

The scan maximizes the mean of whatever the Trade Value mode selects, so the metric is chosen the same way as in the other plot types:

Dollars ($) — net profit per trade after commission and slippage.

Trade Percent (%) — net profit as a percent of position size.

Alloc Percent (^) — net profit as a percent of account equity at entry.

The plot title names the metric in use (“average trade %gain”, “average alloc %gain”, “average $gain”). Changing it rescans instantly from the buffered values. Trade Percent is the usual choice for entry-filter research; note that Dollars can be dominated by a few large positions, and Alloc Percent weights trades by their allocation size.

Factor Scan Min Kept %

This plot option (default 20) is the retention floor: the smallest percentage of trades a cutoff is allowed to keep. It prevents the scan from “winning” by keeping a handful of lucky outliers, and it bounds how far the profile curve extends.

Rows marked * are clamped at this floor. Lowering the floor (say to 10 or 5) lets the scan chase more extreme cutoffs — often with dramatic effect on the rankings — and watching whether OOS holds up as you descend is a useful robustness test. The same floor governs the out-of-sample fitting, so the whole report stays consistent at whatever level you set.

Logging the Table

Press A (Log Analysis Stats) and refresh to write the full ranked table to the Log window. The log adds two columns not shown in the panel:

Plateau — the contiguous range of cutoff percentiles that retain at least 90% of the row’s edge. A wide plateau means the result is not sensitive to the exact threshold; a knife-edge plateau is a warning sign.

Skipped — trades that had no value for that factor.

The log table is tab-delimited and pastes cleanly into a spreadsheet.

Multi-Strategy Tests

Factor Scan works on multi-strategy tests: the strategy panel appears to the left of the factor panel (each panel edge has its own draggable splitter), and selecting a strategy — or Combined — rescans instantly, since the buffered factor values cover every trade. Keep in mind that in a combined test each trade’s size depends on what all strategies were doing at the time, so per-strategy scans are the cleaner read; the Combined view is best treated as a survey.

Using What You Find

A promising row converts directly into a strategy condition:

EntrySetup:  {existing setup conditions} and C / Avg(C, 50) - 1 <= -0.0675

Some suggestions for keeping the research honest:

Use the raw cutoff value in the condition, but judge the row by its percentile. “The bottom 20% by distance from the 50-day average” is the finding; -0.0675 is just where that percentile fell in this sample. The Pctl and Plateau columns tell you whether the threshold sits on a broad effect or a knife-edge; the raw value is simply how the rule gets written.

For thresholds that stay percentile-based, make the factor itself a rank. A factor defined as PercentRank(C / Avg(C, 50) - 1, 252) ranks each bar against the symbol’s own recent history, so the scan’s cutoffs are already percentiles and port into EntrySetup unchanged. #PercentRank does the same across the universe on each bar. (Each ranks against a different population than the scan’s pooled trade sample — all are legitimate, and rank-style factors are inherently scale-free, which makes them good battery material in general.)

Check OOS and the plateau before trusting Edge. A ranked list of many factors is a multiple-comparison exercise — something will always look good in-sample.

Watch Ovlp for echoes. Five highly-overlapped rows are one idea, not five confirmations.

Re-test properly. After adding a condition to the strategy, run the real backtest — with actual sizing, limits, and compounding — rather than assuming the scan’s average carries over.

Keyboard Summary (Factor Scan mode)

Key

Action

G

Switch to Factor Scan

Up / Down

Select the previous / next ranked factor

F / I / T

X axis: factor values / percentiles / percentiles

$ / % / ^

Scoring metric: dollars / trade percent / alloc percent

A

Log the ranked table on the next refresh

P

Show or hide the strategy panel (multi-strategy tests)

X

Crosshair

O

Options

See also Trade Plots and Analysis, Trades Section and Output Format Specification.

 

 

 

Copyright © 2020-2026 Systematic Solutions, LLC