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

Rank

The factor’s place in the ranking by Edge (1 = best). It stays with the factor when the panel is sorted by another column.

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.

Total

Total gain of the kept trades (Kept × Avg), in the current trade value mode. With fixed-size trades this is what the filtered trade list would have made. Sort by it for a different perspective: a cutoff with a high Avg may keep so few trades that it makes less in total than a milder one.

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.

Disc Avg

Average gain per discarded trade — the trades the cutoff leaves out — in the current trade value mode. It shows what the filter is throwing away: a Disc Avg well above zero means profitable trades go out along with the weaker ones. n/a appears when the cutoff keeps every trade.

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 factor’s kept trades overlap those of the factor ranked just above it (the next lower Rank). High overlap means the two factors selected largely the same trades — one finding echoed, not two independent ones. The top-ranked factor has no Ovlp value.

Click a column heading to sort the panel by that column, and click it again to reverse the order; shift-click another heading to add it as a secondary sort, as in the other list windows. Sorting by Factor is useful for comparing scans: run the same factors over different periods or strategy variations and see where each one ranks in each scan. Sorting by OOS brings the factors whose edge held up out of sample to one end. The sort stays in effect when the scan reruns and carries over to newly opened plot windows; each RealTest session starts in rank order.

Right-click the panel for Copy List to Clipboard, Copy Row to Clipboard and Save List as CSV File..., as in the other list windows. They copy or save the table as shown, in its current order; for the Plateau and Skipped columns as well, log the table (below).

Click a row — or press Up/Down — to show that factor in the plot pane: its cutoff profile, or its kept and discarded trades over time (see below). After a sort, the new top row is selected. (In Factor Scan mode the arrow keys move the factor selection, in the order shown; 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 — cutoffs from 0 to 100 percent of trades. Press I.

•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 usually the better read.

The third choice, Trade Number (press T), switches to the time view described next. The crosshair (X) works in every mode.

Kept vs Discarded Over Time

With Sort By set to Trade Number (the default), the plot shows the selected row’s split through time instead of across cutoffs. The trades are taken in the order they were entered, and three running totals of the scoring metric are drawn:

•The green line adds up the trades the row’s cutoff keeps.

•The red line adds up the trades it discards.

•The gray line adds up all of them (green plus red).

•A dotted blue line marks the split between the first and second half of the trade list — the same split the OOS column uses.

The X axis is labeled with entry dates. The gains are summed rather than compounded, like a fixed-size equity curve, which matches the scan’s average-trade objective.

This view answers a question the table can’t: when did the edge appear? Because the cutoff was chosen using all the trades, the green and red lines always finish apart — the ending gap proves nothing. What matters is the shape. A factor whose lines diverge early and keep diverging steadily is more trustworthy than one where they track each other for most of the test and separate only in one period. When choosing between rows with similar Edge, stepping through them with Up/Down and comparing these curves is often the quickest way to decide; the OOS column summarizes the same question with a single number.

The two groups usually differ in size: at the default Min Kept of 20%, the discarded group can have four times as many trades as the kept group. If the discarded trades are still profitable on average, the red line can then rise faster than the green one even though each discarded trade is worse.

To compare the groups on equal terms, press K, or turn on Factor Scan Scale to All Trades in the Plot menu or the options dialog. The green and red lines are then each multiplied by the total number of trades divided by their own group’s count, as if each group had as many trades as the whole list; the gray line is unchanged. Each line keeps its shape and only its height changes, so each one ends at its group’s average gain times the total number of trades, and the order of the line ends is the order of the averages: the green line ends above the gray one exactly when Edge is positive. The key at the bottom right shows each multiplier (for example Kept x5.00 and Discarded x1.25) and the title says “scaled cumulative”, so a scaled value is not read as actual profit.

Scaling magnifies a group’s ups and downs by the same multiplier: when the kept group is a fifth of the trades, one large trade makes a jump five times its size. That is a fair picture of how much less certain a small group’s average is, so a scaled green line that rises steadily is more convincing than one carried by a few jumps. The setting is remembered for new plot windows, and K switches it without rescanning.

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.

•R Multiple (#) — net profit in units of the trade’s initial risk (T.RMult); trades without an InitialRisk are left out.

The plot title names the metric in use (“average trade %gain”, “average alloc %gain”, “average $gain”, “average R-multiple gain”; “cumulative ...” in the time view, “scaled cumulative ...” when scaled). 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 table to the Log window, rows in the panel’s current order. 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 factor in the panel

F / I / T

X axis: cutoff profile by factor value / cutoff profile by percentile / kept vs discarded over time

K

Scale the kept and discarded lines to all trades (time view)

$ / % / ^

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