Support

Equilla Formula Language

BarsSinceEntry

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

Inputs

Position
Numeric: (Optional) The position to examine. Omit this parameter or use zero (0) to indicate the current position.

Remarks

The Position parameter specifies the number of the referenced position relative to the current one. A value of zero (0) identifies the current position, a value of one (1) the previous one.

Examples

Exit a position after a number of bars has elapsed
Input: Price( Close ), Period( 10, 1 ), MaxBarsPerPosition( 5, 1 ); If Average( Price, Period ) Crosses Price Then Buy Next Bar at Market Else If Price Crosses Average( Price, Period ) Then Short Next Bar at Market; If MarketPosition <;>; MarketPositionFlat Then Begin If BarsSinceEntry() >; MaxBarsPerPosition Then ExitPosition Next Bar At Market; End;