Hello,
I am backtesting an inside day strategy, where previous bar (D) low is higher than day before, and high is less than high day before, enter next morning open, if open is less than close day before, sell if close is higher than 2 days ago.
I used 2 different codes, but with same logic, one uses defined variables and one uses just O,H,L,C data. Somehow, I am getting two different results.
Data source: IQFeed
Testing period: Daily
Amibroker version: 64-Bit / 6.40 version
1st code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////START
//Define starting capital and position size
SetOption("initialequity", 25000);
SetPositionSize(50,spsShares);
SetTradeDelays(0,0,0,0);
SetChartBkColor(colorwhite); // color of outer border
SetChartBkGradientFill(colorlightorange,colorPaleGreen,colorBlack); // color of inner panel
Plot( C, "Portfolio Equity", ColorBlend( colorBrightGreen, colorBlack ), styleGradient | styleLine, Null, Null, 0, -1 );
SetOption("AllowSameBarExit",true);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Buy = Ref(H,-1) < Ref(H,-2) AND Ref(L,-1) > Ref(L,-2) AND O < Ref(C,-1);
BuyPrice = Open;
Sell = C > Ref(H,-2);
SellPrice = Close;
results:
2nd code
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////START
//Define starting capital and position size
SetOption("initialequity", 25000);
SetPositionSize(50,spsShares);
SetTradeDelays(0,0,0,0);
SetChartBkColor(colorwhite); // color of outer border
SetChartBkGradientFill(colorlightorange,colorPaleGreen,colorBlack); // color of inner panel
Plot( C, "Portfolio Equity", ColorBlend( colorBrightGreen, colorBlack ), styleGradient | styleLine, Null, Null, 0, -1 );
SetOption("AllowSameBarExit",true);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
daybeforeH = Ref(H,-2);
daybeforeL = Ref(L,-2);
yesterdayH = Ref(H,-1);
yesterdayL = Ref(L,-1);
yesterdayC = Ref(C,-1);
InsideH = yesterdayH < daybeforeH;
InsideL = yesterdayL > daybeforeL;
insideday = insideH AND insideL;
Buy = (Ref(insideday,-1)) AND O < Ref(C,-1);
BuyPrice = Open;
Sell = C > Ref(H,-2);
SellPrice = Close;
results:
2nd code produced more trades, but it seems to me that I using the same inputs, can't figure what causes discrepancies in results?
Any ideas?
Thanks