Skip to content

4. Adding crossovers

Ruben edited this page Mar 3, 2018 · 3 revisions

The cross method calculates the crossing points of two series.
The first two parameters povide the crossing and crossed columns respectively, the third one the new column name.
Two new (internal) columns called newColum+Up and newColumn+Down will be added to the dataset, containing the points where the first series cuts the second upwards and downwards respectively, so that info is available for further use.

To plot the crossing points just add the column name in the plot you want to append it.
By default, upward crossing is represented with green dots and downward crossing with red color.

In the following example the cross of ema50 over ema200 is calculated as "emaCrossing" and then plotted along the close, ema50 and ema200 series.

thales = yfm.fetcher().getTicker("HO.PA")
ticker = Stock(thales)\
    .append(ind.ema, "c", timeperiod=50, saveas="ema50")\
    .append(ind.ema, "c", timeperiod=200, saveas="ema200")\
    .cross("ema50", "ema200", "emaCrossing")\
    .show(["c", "ema50", "ema200", "emaCrossing"], interval=range(-500))

Which plots:

Clone this wiki locally