contains_cross_over#

contains_cross_over(series1, series2, lookback_period=2, must_return_index=False)[source]#

Detect if the first series has crossed over the second. To be used in decide_trades()

Parameters:
  • series1 (Series) – A pandas.Series object.

  • series2 (Series) – A pandas.Series object.

  • must_return_index (bool) – If True, also returns the index of the crossover.

  • lookback_period (int) –

Lookback_period:

The number of periods to look back to detect a crossover.

Returns:

bool. True if the series has crossed over the other series in the latest iteration, False otherwise. If must_return_index is True, also returns the index of the crossover. Note the index is a negative index e.g. -1 is the latest index, -2 is the second latest etc.

Return type:

bool