Try using ApplyStop with stopTypeNBar. Otherwise, you will need to strip out 
redundant signals when working with Ref.

Basically, your problem is:

- Your Short logic will result in many redundant signals (e.g. consider 3 up 
bars in a row, you will have 3 Short signals in a row).

- Since your Cover is entirely dependent upon Short, you will also have many 
redundant Cover signals (e.g. 2nd and 3rd bars in example above will also have 
Cover signals since prior bar had a Short signal).

- When you have both a Short and a Cover on the same bar the AllowSameBarExit 
will have a real impact on whether your system is allowed to exit or not.

Mike

--- In [email protected], "palward" <palw...@...> wrote:
>
> 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; 
> ///////////////////////////////////
>


Reply via email to