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.

I don’t know if this goes anywhere really, I tried using the Even Better Sine Wave indicator and noticed the note in the docs about the logic. So I made the function below based off the code in the two links:

  1. prorealcode
  2. tradingview
import numpy as np
import pandas as pd
def testEBSW(close,length = 40,bars = 10):
    '''Just making the ebsw indicator from pro real code'''
    #Instance Variables
    lastHP = lastClose = 0
    filtHist = np.zeros(3)
    result = [np.nan]*(length-1)+[0]

    #Calculate constants
    angle = 2*np.pi/length
    alpha1 = (1-np.sin(angle))/np.cos(angle)
    ang = 2**.5*np.pi/bars
    a1 = np.exp(-ang)
    c2 = 2*a1*np.cos(ang)
    c3 = -a1**2
    c1 = 1-c2-c3

    for i in range(length,close.size):
        HP = 0.5*(1+alpha1)*(close[i]-lastClose)+alpha1*lastHP

        #Rotate filters to overwrite oldest value
        filtHist = np.roll(filtHist,-1)
        filtHist[-1] = c1*(HP+lastHP)/2+c2*filtHist[1]+c3*filtHist[0]

        #Wave calculation
        wave = np.mean(filtHist)
        rms = np.sqrt(np.mean(filtHist**2))
        wave = wave/rms

        #Update past values
        lastHP = HP
        lastClose = close[i]
        result.append(wave)
    return pd.Series(result, index=close.index)

The outputs are pretty different so this code could be bugged, either way I think the original code could be changed slightly to not calculate the constants on every loop as they don’t change. Sorry if this serves no purpose, I just signed up to post this so I don’t know how any of this works.

Figure_1

I realized after posting this graph is pretty ambiguous, but it’s the result of both indicator types on 100 days of EURUSD data I have saved to my computer. Blue line is the one in this library and the orange one is my test function.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rengel8commented, Aug 11, 2021

@Squigglez2 Thank you very much for providing the function of the EBSW. That made it easy to look into it.

With the data, @twopirllc provided, I made a comparison between TradingView and the updated version, which is now very close (despite some bars 4 to 6 decimal places are identical) to TradingView. TV offers a very fast pre-roll of only one bar probably with historical data under the hood. That is interesting, but the recent version in Pandas TA is now closely to TV with the advantage of providing the same results each time one bar earlier. TV offers a very fast pre-roll of only one bar probably with historical data under the hood. That is interesting, but the recent version in Pandas TA is now closely to TV with the advantage of providing the same results each time one bar earlier.

0reactions
twopirllccommented, Aug 29, 2021

Hello @Squigglez2,

Please test the updated version using by installing the development branch and let us know if it is working better.

$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development

Kind Regards, KJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ehlers Even Better Sinewave Indicator [CC] - TradingView
The Even Better Sinewave Indicator was created by John Ehlers (Cycle Analytics For Traders pgs 161-162) and this indicator works well when ...
Read more >
ebsw - Trading Strategy documentation
This indicator measures market cycles and uses a low pass filter to remove noise. Its output is bound signal between -1 and 1...
Read more >
Download EBSW Even Better Sine Wave For Amibroker (AFL)
EBSW Even Better Sine Wave - Largest database of free formulas, indicators, oscillators and trading systems for Amibroker (AFL), Metastock, eSignal (EFS), ...
Read more >
Even Better Sinewave Indicator - Optuma Client Support
The Even Better Sinewave Indicator works extraordinarily well when the market is in a trend mode. This means that the spectacular failures of...
Read more >
EBSW Even Better Sine Wave For Amibroker (AFL) - MQL5
This is a better version of original sine wave indicator : evenbettersinewave_v1. Some more information can be found here : download ebsw ......
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