BarsSinceCompare
- bars since comparision between past and present array values was true

Trading system toolbox
(AmiBroker 6.40)


SYNTAX BarsSinceCompare( past, comparison, current )
RETURNS ARRAY
FUNCTION For every bar in current array, go back in time and compare past array values with current bar value and get number of bars since comparison was true.

Parameters:

  • past - the array holding "past" values to compare to
  • comparison - string that defines comparison operator, available choices are ">", "<", ">=", "<="
  • current - the array holding "current" values to compare to

For more discussion about that function see: https://forum.amibroker.com/t/duplicate-bars-since-price-was-this-high-low/28355/14

EXAMPLE // get bars since close was last time higher than current close
BarsSinceCompare( Close, ">", Close );

// get bars since low was last time higher than current close
BarsSinceCompare( Low, ">", Close );

// get bars since low was last time higher than or equal than current close
BarsSinceCompare( Low, ">=", Close );

// get bars since high was lower than or equal than current low
BarsSinceCompare( High, "<=", Low );
SEE ALSO BarsSince() function

References:

The BarsSinceCompare function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.