BarsSinceEntry (Reserved Word)

image\trumpet2.gif Disclaimer

Returns the number of bars since a specified position was entered.

BarsSinceEntry(Num)

Where Num is a whole number (up to a maximum 10) representing positions ago.

Remarks

This function can only be used in the evaluation of strategies.  If no input is provided, the current position (0) is assumed.

Be aware that the behavior of BarsSinceEntry will be different depending on whether the strategy order was generated using the 'this bar' or 'next bar' order action.

For 'this bar' strategy orders:

The value of BarsSinceEntry is not updated at the close of the current bar but continues to return the bars ago of an existing strategy position.  For example, if no previous strategy position exists on the current bar (containing the 'this bar' strategy order code) BarsSinceEntry returns 0 if no previous strategy position exists or returns the number of bars since entry of an existing strategy position.  When recalculated on the next bar, BarsSinceEntry returns a 1 to indicate that the strategy position was established 1 bar ago.  For example, if the strategy is long and a "sell short this bar" order is executed, BarsSinceEntry will return the number of bars since the long position was initiated when the code runs on the bar of short entry.

For 'next bar' strategy orders:

The value of BarsSinceEntry returns a bars ago value of 0 at the close of the current bar (containing the 'next bar' strategy order code) and also reports a 0 on the next bar.  For example, if the strategy is long and a next bar order is executed in the current bar then, when the code runs at the close of the current bar, BarsSinceEntry will be 0 since 0 bars have passed since the short entry.

Example

Value1 = BarsSinceEntry(2);

In this example, Value1 might return a value of 68 if it has been 68 bars since the entry that occurred 2 positions ago.