tsignals generating wrong single with more than 2 indicator in strategy
See original GitHub issueWhich version are you running? The lastest version is on Github. Pip is for major releases.
panda-ta=0.2.75b
Describe the bug tsignals indicator is giving few wrong trade entry/exits in case of using multiple indicators. I’ve tried to use MACD with two SMA. And results are varying as per the chart.
To Reproduce
#dump the attached csv file (it have close column)
dump_df #with strategy applied data
cnd = (dump_df['MACD_13_21_8'] >= dump_df['MACDs_13_21_8']) & (dump_df['close'] >= dump_df['SMA_13']) & (dump_df['close'] >= dump_df['SMA_21'])
dump_df.ta.tsignals(trend=cnd, append=True)
Expected behavior the column generated through np.where in attached sheet have a correct trade. tsignals should match the same value.
eg : since it's the AND condition. Thus,final signal (s) should be only valid if all the indicator signal are the same
s = (s_1 & s3 & s_3)
Additional context Note: Problem has experienced in case of more than 2 indicators in strategy. I’ve generated the actual signals through np. where with below condition and generated column s, which has been generated through s_0,s_1,s_2. column s_0,s_1,s_2 are respectively a signal for each indicator And it has an expected result.
dump_df['signal'] = np.where((dump_df['s_1'].astype(int) == dump_df['s_0'].astype(int)) & (dump_df['s_2'].astype(int) == dump_df['s_1'].astype(int)),test_dump_df['s_2'],0)
S* = 0 (No Trade)
S* = 1 (Buy Trade) #in tsignal terminology entry
S* = -1 (Short Trade) #in tsignal terminology exit
Thanks in advance !!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top GitHub Comments
@codesutras,
When writing my prior response I realized two things that are missing. 🤦🏼 I forget to include Barrier Signals (Exits when Target, Loss, or Time/Bars is hit) and as well as the two other conditions for Event Signals; I’ve implemented two of four conditions. I’ll send you the Notebook soon of what I currently have minus what I have forgotten and we can start from there.
I know there is some Barrier Signal code somewhere, so I will have to source and implement it or figure it out for the package. Trailing Stops are also a Single Barrier Events, so maybe that can be implemented as well. 🤷🏼♂️
KJ
Thank you Kevin. Much appreciated. I just started digging in to the project so I’m probably not the best person to contribute in other ways, but I will indeed do what I can. I will also encourage our devs and interns to assist wherever they are able for bug fixes, etc. so you can get back to the fun stuff. In the meantime, enjoy a coffee or half of a beer. each month on me. 😉