I am quite puzzled by the following; hope someone can help.
I am designing a stock system that exits on the close one bar after an
established open position. Below is a non profitable mock up of what I am
trying to do.
The problem is when "AllowSameBarExit" is asssigned true or false. The results
in the backtester are significantly different using the same code but changing
"AllowSameBarExit" from false to true . My expectation is that the backtest
results should be identical since the exit is never on the same bar of entry.
Why am I getting different results and how can it be corrected?
Thank you,
Phil
Here is the code:
//////////////////////////////
SetTradeDelays(0,0,0,0);
PosQty=20;
PositionSize = -100/PosQty;
SetOption( "MaxOpenPositions",PosQty);
SetOption("AllowSamebarExit",False);
Short=High>Ref(High,-1);
ShortPrice=Max(Open,Ref(High,-1));
Cover=IIf(Ref(Short,-1),1,0);
CoverPrice=Close;
///////////////////////////////////