PDA

View Full Version : BarsSinceEntry() Question and Trade-# all the same


daqu40
10-20-2009, 07:57 PM
My strategy is broken and the culprit is BarsSinceEntry(BarsArrayIndex, TradeName, EntriesAgo).

The release notes say this function is changed and now returns proper values relation to multi-series strategies which is the case I'm running.

So what exactly does this mean? The error I'm getting is indicating index out of range but I don't really see how since this was working fine in V 6.5.

One other data point. I've noticed all of my trades are 1 instead of the normal 1,2,3... Maybe this is contributing to the other problem.

Any input greatly appreciated.

NinjaTrader_Josh
10-21-2009, 07:57 AM
Not sure what you mean by trades being 1,2,3 vs 1. Please clarify.

Please provide the code snippet as to where you receive Index out of range.

daqu40
10-21-2009, 10:56 AM
In Trades tab for my backtest every trade # is 1, instead of the each one being in sequence as would be expected of 1, 2, 3, etc.

I'll post the code snipet on the BarsSinceEntry problem later when I'm in front of my development machine.

NinjaTrader_Dierk
10-21-2009, 11:01 AM
>> In Trades tab for my backtest every trade # is 1, instead of the each one being in sequence as would be expected of 1, 2, 3, etc.
That's a bug which we just fixed. Thanks for reporting though.

daqu40
10-21-2009, 03:29 PM
here is the code:

if ((Position.MarketPosition == MarketPosition.Long )
&& BarsInProgress == 1
&& ATR(BarsArray[1], SetSMATrapATRPeriod)[BarsSinceEntry(1, myStratTrade.TradeName, 0)] >= SetSMATrapATRBound
&& (CrossAbove(BarsArray[1], SMA(BarsArray[1],SetSMATrapSMAPeriod),1)
&& Closes[1][0] >= SMA(BarsArray[1],SetSMATrapSMAPeriod)[0] + SetSMATrapLongOffsetTicks)
&& Closes[1][BarsSinceEntry(1, myStratTrade.TradeName, 0)] <= SMA(BarsArray[1],SetSMATrapSMAPeriod)[BarsSinceEntry(1, myStratTrade.TradeName, 0)] + SetSMATrapLongOffsetTicks
)

It works fine in NT 6.5. BarsArray[1] is 60 minutes. I just realized that not all trades enter on a 60 min bar. Maybe this is why the error is thrown.