Trend with volatility-scaled sizes
Size by risk instead of by dollars: each position's share of equity is inversely proportional to its volatility, so calm and jumpy stocks add similar risk. The trend rules are deliberately plain; the sizing is the point. Compare it with a fixed 5% size.
Strategies · volatility_sized_trend.rvw
language 1
strategy "Trend with volatility-scaled sizes" {
universe members("SYN500")
enter long when close > sma(close, 100) and roc(close, 60) > 0
rank by roc(close, 60) / volatility(60)
size weight risk_pct * 1% / volatility(60), max 15 positions
max position 15%
exit when close < sma(close, 100)
param risk_pct = 2 in 1..4 step 1
}
Functions it uses
sma, roc, volatility
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?