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.

The stochastic indicator doesn't work for smooth_k = 1

See original GitHub issue

Which version are you running? The lastest version is on Github. Pip is for major releases. 0.3.2b0

Do you have TA Lib also installed in your environment? Yes

Did you upgrade? Did the upgrade resolve the issue? I upgraded but it didn’t help.

Describe the bug If you try to get the unsmoothed stochastic indicator it throws and exception because the SMA function on TA Lib doesn’t accept the value “1” as the length parameter.

To Reproduce

ta.stoch(df.High, df.Low, df.Close, k=14, smooth_k=1)

Expected behavior The calculation of a Stochastic series getting the same result as TradingView

Screenshots screenshot

Additional context In my installation I changed the line 29 (stoch.py file) from stoch_k = ma(mamode, stoch.loc[stoch.first_valid_index():,], length=smooth_k) to stoch_k = stoch if smooth_k==1 else ma(mamode, stoch.loc[stoch.first_valid_index():,], length=smooth_k) And apparently it worked: solved?

I also suggested this change but it seems it has been discarded.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KimWuWeicommented, Apr 22, 2022

Hello @KimWuWei,

I assume by no response that the solution provided was sufficient. Thus I will be closing this issue in a few days.

Kind Regards, KJ

Sorry, I didn’t see it. Yes, it was sufficient. Thanks!

1reaction
twopirllccommented, Mar 11, 2022

@KimWuWei,

No worries. I’m no Github master either… still learning new things.

Thanks for the quick fix you provided! 😎 Will let you know when it’s available.

KJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stochastic Oscillator: What It Is, How It Works, How To Calculate
A stochastic oscillator is a momentum indicator comparing a particular closing price of a security to a range of its prices over a...
Read more >
The Stochastic Indicator: When it Works, When it Doesn't & Why
How to Use Stochastic Indicator. http://www.financial-spread-betting.com/course/ stochastics - indicator.html PLEASE LIKE AND SHARE THIS VIDEO ...
Read more >
How Does the Stochastic Indicator Work in Trading?
The stochastic oscillator is a technical indicator that predicts trend reversals and helps to identify overbought and oversold levels. Learn more.
Read more >
Stochastic Oscillator - ChartSchool - StockCharts.com
According to an interview with Lane, the Stochastic Oscillator “doesn't follow price, it doesn't follow volume or anything like that. It follows the...
Read more >
What Is The Slow Stochastic Oscillator? - Fidelity Investments
Setting the smoothing period to 1 is equivalent to plotting the Fast Stochastic Oscillator. Chart 1: Slow Stochastic. How this indicator works. Generally,...
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