question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsignals generating wrong single with more than 2 indicator in strategy

See original GitHub issue

Which 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 !!

test-signal.xlsx

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
twopirllccommented, Jun 26, 2021

@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

1reaction
eervin123commented, Jan 23, 2022

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. 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding Indicator Overlap - Don't get false signals! - YouTube
One of the first things traders should decide upon starting is what technical indicators to use to power their strategies.
Read more >
Signals getting generated multiple times - pine script
I have one strategy, which is working well. I want to convert it into study (indicator), while doing that I am facing issue...
Read more >
How to Avoid Using Similar Technical Analysis Indicators
This guide focuses on one of the most common mistakes technical traders ... They help traders confirm the signals from other indicators.
Read more >
False Signal Definition - Investopedia
In technical analysis, a false signal refers to an indication of future price ... that cancel out noise, traders can more effectively spot...
Read more >
Pine Script (TradingView) - A Step-by-step Guide
Pine script was designed to be lightweight, and in most cases, ... Testing strategies or creating indicators in other languages involves sourcing your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found