Can be used alone or in conjunction with StartDate or EndDate. The date window is resolved from whichever end is anchored, and EndDate takes precedence:
With any EndDate — a literal date, or Latest — the window is NumBars bars counting back from that date, and a StartDate is ignored however it was set. With a StartDate and no EndDate, it is NumBars bars counting forward from that date; StartDate: Earliest gives the first NumBars bars of the data file. With NumBars alone — no date settings at all — it is the most recent NumBars bars.
Since a ScanSettings section inherits the Settings section, a script whose test uses a dated StartDate and EndDate can still scan the most recent bars by putting EndDate: Latest and NumBars in ScanSettings — the usual daily-scan idiom.
When BarSize is Daily, NumBars is a count of market days. Otherwise it is a count of bars at that BarSize (weeks, months, quarters, or years).
Example
This is a convenient way to run a daily scan for live trading candidates: