I am trying to use RegularRawMulti to perform a backtest. I am using a single security as a test via the Apply to *Current selection in the Analysis window.
What I am expecting is multiple entries on july 4, July6 and July 7 when testing from July 1.
What I get is entries on July 4 and July 12.
If I change the start date to July 5 I get entries on July 6 and July 12, so the entry logic is performing as expected but through some lack of understanding on my part the backtester is performing as if there was an Exrem in there. (The July 4 and 6 trades close on July 11)
This isn't a trading system; the objective is to generate a large number of trades via the custom backtester with RSI, ADX values at entry and then scan for useful entries with machine learning tools. The code is below
...
//v2.1 custom backtest code stripped out to test backtest regularRawMulti
//====================== System settings==========================
SetOption( "ExtraColumnsLocation", 1 );
//SetBacktestMode( backtestRegular ); //extra buy/sell signals removed
SetBacktestMode(backtestRegularRawMulti); //extra signals not removed, allow multiple positions per security
MaxPos = 200;//Optimize("MaxPos",20,1,50,1);
SetOption( "maxopenpositions", MaxPos );
SetOption( "initialequity", maxPos*10000);
SetPositionSize( 10000, spsValue );
SetOption ( "CommissionMode", 2 ); // $ per trade
SetOption( "CommissionAmount", 20 );
SetOption("ActivateStopsImmediately",0);
SetTradeDelays( 1, 1, 0, 0 );
BuyPrice = SellPrice = Open;
//==========end system settings==================================
//========================Connors RSI Function=====================
//Connor's RSI (Larry Connors). Code for function provided by Connors Research
//http://www.amibroker.com/library/detail.php?id=1418
paramLenRSI =3;//Optimize("RSI Closes Length", 3, 2, 10, 1);//this code not being used in v1.7 prior to 26/1/15. Recoded below
paramLenUD = 2;//Optimize("RSI UpClose Length", 2, 2, 5, 1); //values other tan 2 do not give good results
paramLenRank =105;//Optimize("PerecentRank Length", 130, 90, 150, 5);
r
function ConnorsRSI(lenRSI, lenUD, lenROC)
{
upDays = BarsSince(C <= Ref(C,-1));
downDays = BarsSince(C >= Ref(C,-1));
updownDays = IIf(upDays > 0, upDays, IIf(downDays > 0, -downDays, 0));
crsi = ( PercentRank(ROC(C,1), lenROC) + RSIa(updownDays,lenUD) + RSI(lenRSI))/3;
return crsi;
}
//==========================End Function=============================
Con=ConnorsRSI(paramLenRSI,paramLenUD,paramLenRank); //recoded to use variables instead of fixed values 3,2,100
MAPeriod=7;
Buy = Con < Ref(Con,-1) AND Close < MA(C,MAPeriod); //buy on droping Con (cRSI) want entry below exit MA
StopValue=Optimize("StopValue",25,5,50,5);
ApplyStop(stopTypeLoss,
stopModePercent,Stopvalue,ExitAtStop = 2);
ExitPeriod = 10;
ApplyStop(stopTypeNBar,stopModeBars,ExitPeriod,ExitAtStop = 2);
SellSig=Cross(Close,MA(C,MAPeriod)) ;
Sell=SellSig;
Equity(1);
//Buy=ExRem(Buy,Sell);
Thanks in advance for your assistance