Hi, I am trying to convert an AFL that is written for rotational backtesting to an AFL for regular backtesting. The end goal being both backtest results will be same. I have provided the both the code below (pad and align is done for both of them during analysis)
EnableRotationalTrading();
SetOption("WorstRankHeld",2000);
PositionSize = -100;
PositionScore = RSI();
ApplyStop(stopTypeProfit,stopModePercent,50,0,True,0);
ApplyStop(stopTypeTrailing,stopModePercent,10,0,True,0);
I tried to write an equivalent of the above for regular backtest as below.
wlnum = GetOption( "FilterIncludeWatchlist" );
List = CategoryGetSymbols( categoryWatchlist, wlnum ) ;
if ( Status("stocknum") == 0 )
{
StaticVarRemove( "values*" );
for ( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ )
{
SetForeign ( symbol );
values = RSI();
RestorePriceArrays();
StaticVarSet ( "values" + symbol, values );
_TRACE( symbol );
}
StaticVarGenerateRanks( "rank", "values", 0, 1224 );
}
symbol = Name();
values = StaticVarGet ( "values" + symbol );
rank = StaticVarGet ( "rankvalues" + symbol );
buy = rank == 1 ;
PositionScore = RSI();
sell = 0 ;
PositionSize = -100;
ApplyStop(stopTypeProfit,stopModePercent,50,0,True,0);
ApplyStop(stopTypeTrailing,stopModePercent,10,0,True,0);
Backtest was performed on both the above AFL on the same watchlist. Watchlist has much less than 2000 symbols. The results were not same, which means am overseeing something here. Any advise to make both the code equivalent to each other would be much appreciated. Thanks