How to generate CrossOver signal with "slowK and slowD" from TALIB and or BT Stochastic fonction ?
-
Hello gas !!!
I discover BT tool with Remroc.
Could you please help me to find out the solution to display CrossOver signal coming from "slowK and slowD" of TALIB Stochastic fonction ? -
In Unix everything is a file and in backtrader (mostly) everything is a lines object.
Both
Stochastic
indicators (own and fromta-lib
) declare lines.- Docs - ta-lib Indicator Reference :
slowK
andslowD
- Docs - Indicator Reference :
percK
andpercD
Lines are reachable under
lines
attribute as in:percK = Mystochastic.lines.percK
And backtrader contains an indicator to generate signals:
CrossOver
. There was a recent blog post using it (actually mixing with numbers).In the docs you can also see additional crosses from data feeds and sma
When no line is specified the 1st line of the object will be used.
It's finally so easy as:
crossover = bt.ind.CrossOver(line1, line2)
- Docs - ta-lib Indicator Reference :
-
See also this new sample - Blog - Plotting Date Ranges
-
Great it's working fine !
Thx ! -
How can I generated Stochastic signal from other line like "ema of (data)" in Backtrader ?
-
See the front page: https://www.backtrader.com
-
Sorry to bring up an old thread, but it would be nice if in the documentation https://www.backtrader.com/docu/indautoref.html , the parameters of
bt.ind.CrossOver
were defined. There is noparams
field, so I was not sure if it could be used along with other indicators. -
CrossOver
has no parameters. It takes data feeds which will generate a1
,0
or-1
depending if there is a cross-over to the upside, nothing or a cross-over to the downside.From the documentation:
This indicator gives a signal if the provided datas (2) cross up or down - 1.0 if the 1st data crosses the 2nd data upwards - -1.0 if the 1st data crosses the 2nd data downwards