Practical Guide: Finding Optimal Parameters for the Levy RSL System in AmiBroker
Available Data & Split
Total data available : 1995 - 2026
Split:
In-Sample (IS) : 01/01/1995 - 31/12/2015 (20 years)
Out-of-Sample (OOS): 01/01/2015 - today (11 years)
IMPORTANT: Do NOT look at OOS data until Step 6!
β OOS data is sacred - only used once at the very end
Step 1 β AmiBroker Settings
AA Window:
β Apply to : SP500 Watchlist
β Range : 01/01/1995 to 31/12/2015
β Periodicity : Daily
Settings β General Tab:
β Initial Equity : 1,000,000 USD
β Positions : Long only
β Allow same bar exit: OFF
Settings β Portfolio Tab:
β Max Open Positions : 10
β Limit trade size : 0 (no limit)
Settings β Trades Tab:
β Buy Delay: 1 Price: Open
β Sell Delay: 1 Price: Open
Step 2 β Robustness Analysis (Optimization)
Start the optimization:
AA Window β Optimize (dropdown arrow) β Settings:
β Method : Exhaustive
β Optimization Target : Ulcer Performance Index (UPI)
Parameters to optimize:
β LevyPeriod : Start 50, Stop 300, Step 10 (26 values)
β CastOutRank : Start 10, Stop 250, Step 10 (25 values)
β Total combinations: 26 Γ 25 = 650 β fast!
β Click Optimize
Step 3 β Plateau Analysis
After optimization is complete:
AA Window β Results Tab β
β Right-click β 3D Surface Chart
X-Axis : LevyPeriod
Y-Axis : CastOutRank
Z-Axis : UPI (Ulcer Performance Index)
What you are looking for:
β Flat plateau = robust parameters β
β Sharp peak = overfitting β
β Never pick the absolute peak value!
β Always pick the CENTER of the plateau
Manual stability check:
Test these 9 combinations individually:
LevyPeriod : 90 / 100 / 110
CastOutRank : 130 / 140 / 150
β UPI values similar across all 9 = robust β
β UPI values vary widely = fragile β
Example:
LevyPeriod=90, CastOutRank=130 β UPI 2.8
LevyPeriod=100, CastOutRank=140 β UPI 2.9 β peak
LevyPeriod=110, CastOutRank=150 β UPI 2.7
β all similar = plateau confirmed = robust β
Step 4 β Walk Forward Test
Settings in AmiBroker:
AA Window β Walk Forward Tab:
In-Sample Period : 10 years (120 months)
Out-of-Sample : 2 years (24 months)
Step : 2 years (24 months)
Anchored : NO (rolling window)
Optimization Target: UPI
How it runs:
IS: 1995-2005 β OOS: 2005-2007
IS: 1997-2007 β OOS: 2007-2009 β contains financial crisis
IS: 1999-2009 β OOS: 2009-2011
IS: 2001-2011 β OOS: 2011-2013
IS: 2003-2013 β OOS: 2013-2015
β OOS periods chained together = real forward test
What to evaluate:
Walk Forward Efficiency = OOS UPI / IS UPI * 100
70% = good β use these parameters β
50% = acceptable β use these parameters β
< 50% = overfitting β reject system β
Additionally check:
β Are OOS parameters stable across periods?
(not completely different every time)
β Is OOS equity curve profitable?
β No extended losing periods in OOS?
Step 5 β Select Final Parameters
From Walk Forward Report:
β Check which parameters were selected
most frequently across all OOS periods
Example:
OOS 2005-2007 : LevyPeriod=100, CastOutRank=140
OOS 2007-2009 : LevyPeriod=110, CastOutRank=150
OOS 2009-2011 : LevyPeriod=100, CastOutRank=140
OOS 2011-2013 : LevyPeriod=90, CastOutRank=140
OOS 2013-2015 : LevyPeriod=100, CastOutRank=130
β LevyPeriod 100 = most frequent β select 100
β CastOutRank 140 = most frequent β select 140
β These are your final parameters
Step 6 β Final OOS Test (once only!)
Now open the OOS data for the first time:
β Range: 01/01/2015 to today
β Run backtest with final parameters
β NO further adjustments allowed!
Evaluation criteria:
β OOS UPI similar to IS UPI = system is robust β
β OOS equity curve profitable = system is tradeable β
β OOS drawdown acceptable = system is safe β
β OOS Annual Return > 0 = system works forward β
Step 7 β Monte Carlo Simulation
AA Window β after final backtest β
Report β Monte Carlo Tab:
Settings:
β Simulations : 1,000
β Confidence : 95%
What to check:
Percentile 5% β Worst Case scenario
β Is drawdown still acceptable?
β Is return still positive?
Percentile 50% β realistic normal case
β this is your real expectation for live trading
Decision:
β Worst Case drawdown acceptable? β system ready β
β Worst Case drawdown too large? β reduce position size
Decision Tree Summary
Step 1: Robustness Analysis
β Flat plateau found?
NO β widen parameter range, repeat
YES β continue
Step 2: Walk Forward
β WF Efficiency > 50%?
NO β reject system, redesign
YES β continue
Step 3: OOS Test
β Profitable with acceptable drawdown?
NO β reject system, do not trade
YES β continue
Step 4: Monte Carlo
β Worst Case (5%) still acceptable?
NO β reduce position size to 5,000 USD
YES β system is ready for live trading β
Question to Experienced Trading System Experts
The workflow described above represents my current approach to developing and validating the Levy RSL momentum system in AmiBroker. I would greatly appreciate feedback from experienced systematic traders and system developers on the following questions:
- Is this workflow practical and complete?
Am I missing any critical validation steps before
going live with this momentum rotation system?
- Walk Forward settings
Is a 10-year IS / 2-year OOS rolling window
appropriate for a weekly momentum system?
Or would a different ratio be more suitable
given the weekly trading frequency?
- Optimization target
I am using UPI (Ulcer Performance Index) as
the optimization target. Would you recommend
a different metric for a momentum rotation
system with a long-only bias?
- Parameter space
With only 2 parameters (LevyPeriod and CastOutRank)
and 650 combinations, is Exhaustive optimization
sufficient or would you recommend
Smart Optimization (CMA-ES) regardless?
- Data split
Given data from 1995 to 2026, I am using
1995-2015 as IS and 2015-2026 as OOS.
Is this split appropriate or would you
recommend a different approach given that
market structure has changed significantly
since 1995?
- Crisis filter validation
The system uses SPY SMA5 > SMA200 as a
crisis filter. Should this filter also be
validated separately through its own
robustness analysis, or is it sufficient
to keep it fixed at these classic values?
- Live trading transition
After all validation steps are passed,
what additional precautions would you
recommend before committing real capital
to this system?
Any specific position sizing or drawdown
limits you would suggest for a system
of this type?
Any additional suggestions or alternative approaches from experienced practitioners would be highly valued. The goal is a robust, practically tradeable momentum system that performs consistently across different market regimes.