Walk-Forward Strategy with several pairs of optimized variables

Hello,

I have some doubts about how to approach a walk-forward test of a system with several variables which are not supposed to be optimized all at the same time. I have written a very simple system to raise my question in a easier way:

// --- Backtest settings --- 

SetOption("CommissionMode"  , 3);
SetOption("CommissionAmount", 0.005);
SetOption("InitialEquity", 10000);
SetOption("AllowPositionShrinking", True);
SetOption("MinShares", 1);
SetOption("HoldMinBars", 1);
SetTradeDelays(0, 0, 0, 0);
SetBacktestMode(backtestRegular);
SetOption("MaxOpenPositions", 5);

// --- Market Filter ---

MarketVariable1  = Optimize("MV1", 6, 2, 12, 2);
MarketVariable2  = Optimize("MV2", 24, 12, 36, 2);
IndexClose       = Foreign("$SPX", "Close");
LongMarketFilter = MA(IndexClose, MarketVariable1) > MA(IndexClose, MarketVariable2);

// --- Symbol Signals ---

SymbolVariable1  = Optimize("SV1", 6, 2, 12, 2);
SymbolVariable2  = Optimize("SV2", 24, 12, 36, 2);
LongSymbolSignal = MA(Close, SymbolVariable1) > MA(Close, SymbolVariable2);

// --- Position Sizing ---

SizingVariable1  = Optimize("ZV1", 5, 1, 10, 1);
SizingVariable2  = Optimize("ZV2", 15, 5, 25, 5);

PositionRisk     = SizingVariable1;
TradeRisk        = SizingVariable2;
PstSize          = 100 * PositionRisk / TradeRisk;

ApplyStop(stopTypeLoss, stopModePercent, TradeRisk, True);
SetPositionSize(PstSize, spsPercentOfEquity);

// --- Trading Rules --- 

Buy           = LongMarketFilter AND LongSymbolSignal;
Sell          = NOT LongMarketFilter OR NOT LongSymbolSignal;
BuyPrice      = Close;
SellPrice     = Close;
RoundLotSize  = 1;

The system consists of three parts: market filter, symbol signal and position sizing. Each of those have two optimizable variables, and each pair is optimized in an independent way. When I need to optimize one pair, I block the others. For example:

MarketVariable1  = Optimize("MV1", 6, 2, 12, 2);
MarketVariable2  = Optimize("MV2", 24, 12, 36, 2);

SymbolVariable1  = 6;  // Optimize("SV1", 6, 2, 12, 2);
SymbolVariable2  = 24; // Optimize("SV2", 24, 12, 36, 2);

SizingVariable1  = 5;  // Optimize("ZV1", 5, 1, 10, 1);
SizingVariable2  = 15; // Optimize("ZV2", 15, 5, 25, 5);

On the basis of the above, I am not sure if it is possible to do in a walk-forward test something similar to what I do manually, when I have to optimize the system by pairs. If not, what would you do instead?

Thank in advance for your answers.

Best regards.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.