Down days, tuned too far
three_down_days tuned too far, on purpose: its holding period is searched as well as the length of the run, 5 × 10 = 50 settings on one history. Optimize it and read the verdict. On the sample data it is "Probably luck": the setting that looked best on one half of the history mostly ranked below the median on the other half. Every knob tuned on the same history makes a lucky winner more likely.
Strategies · down_days_overtuned.rvw
language 1
strategy "Down days, tuned too far" {
universe members("SYN500")
enter long when close > sma(close, 200) and count(close < close[1], run) == run
rank by -roc(close, run)
size 10% of equity, max 10 positions
exit when close > close[1]
max bars hold
param run = 3 in 2..6 step 1
param hold = 10 in 2..20 step 2
}
Functions it uses
Try it
File ▸ New Script from Example adds it to a project. The examples read the sample’s index label, SYN500, and market ETF, SYNSPY; when your data has neither, a sheet asks what to read instead, one of your index labels (or every stock and ETF) and a ticker, so the example runs on your data as it is.
Before you trust what it does on your data, see whether it’s luck: Is this result luck?