pandas-ta icon indicating copy to clipboard operation
pandas-ta copied to clipboard

HiLo is not working perfectly, same numbers printing many time.

Open whatismyname21 opened this issue 3 years ago • 10 comments

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

import pandas_ta as ta
print(ta.version)

Do you have TA Lib also installed in your environment?

$ pip list

Did you upgrade? Did the upgrade resolve the issue?

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

Describe the bug A clear and concise description of what the bug is.

To Reproduce Provide sample code.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Thanks for using Pandas TA!

whatismyname21 avatar Apr 12 '22 12:04 whatismyname21

Hello @whatismyname21,

I can not help you as you have not completed the above form nor have you provided enough evidence (context, data, reproducible code, screenshots) to convince us that this is anything but a baseless claim.

Clearly not a lot of the same number printing many times: Screen Shot 2022-04-12 at 6 35 32 AM

Kind Regards, KJ

twopirllc avatar Apr 12 '22 13:04 twopirllc

Hi Kevin

I have used below code

HILO = ta.hilo(df["High"],df["Low"],df["Close"], high_length=2, low_length=4)

Price is moving but i am getting same result many time. Please find attached screenshot.

Thanks Aj

whatismyname21 avatar Apr 12 '22 17:04 whatismyname21

@whatismyname21,

Again:

  • What version of Pandas TA are you using?
  • What ticker and timeframe are you using?
  • Do you have csv of the offending ohlcv data so I can see what the problem is?
  • Do you have screenshots?

Thanks for providing the indicator and parameters that are not working.

KJ

twopirllc avatar Apr 12 '22 17:04 twopirllc

Hi Kevin

Please answer in line...

  • What version of Pandas TA are you using? -- 1.3.4
  • What ticker and timeframe are you using? - 5mins or 1day
  • Do you have csv of the offending ohlcv data so I can see what the problem is? - Getting data from yahoo
  • Do you have screenshots? - Please find attachment...

whatismyname21 avatar Apr 12 '22 18:04 whatismyname21

Screenshot 2022-04-12 at 11 12 59 PM

whatismyname21 avatar Apr 12 '22 18:04 whatismyname21

@whatismyname21

Thanks, we are getting there... What ticker/symbol?

There is no such Pandas TA version: 1.3.4

import pandas_ta as ta
print(ta.version)

twopirllc avatar Apr 12 '22 18:04 twopirllc

Sorry to bug you, but my main strategy is on Gann HiLo

Version - 0.3.14b0 Ticker name - AAPL Today's data Screenshot 2022-04-12 at 11 53 08 PM

whatismyname21 avatar Apr 12 '22 18:04 whatismyname21

@whatismyname21

Your small ma lengths can cause the conditional logic to repeat values until the close price either exceeds the previous high/low sma values.

You should add the sma's and compare for yourself that the logic is working as implemented.

df = # your ohlcv data
df.ta.sma(2, append=True)
df.ta.sma(4, append=True)
df.ta.hilo(high_length=2, low_length=4, append=True)
print(df)

HILO core logic:

def hilo(high, low, close, high_length=None, low_length=None, mamode=None, offset=None, **kwargs):
    """Indicator: Gann HiLo (HiLo)"""
    # Validate Arguments
    # ...

    high_ma = ma(mamode, high, length=high_length)
    low_ma = ma(mamode, low, length=low_length)

    for i in range(1, m):
        if close.iloc[i] > high_ma.iloc[i - 1]:
            hilo.iloc[i] = long.iloc[i] = low_ma.iloc[i]
        elif close.iloc[i] < low_ma.iloc[i - 1]:
            hilo.iloc[i] = short.iloc[i] = high_ma.iloc[i]
        else:
            hilo.iloc[i] = hilo.iloc[i - 1]
            long.iloc[i] = short.iloc[i] = hilo.iloc[i - 1]

    # ...

twopirllc avatar Apr 12 '22 18:04 twopirllc

Yahoo Finance: AAPL (1min) - HILO(2,4) + SMA(2) + SMA(4) yf-aapl-1m-hilo_2_4.csv

Screen Shot 2022-04-12 at 11 45 01 AM

twopirllc avatar Apr 12 '22 18:04 twopirllc

@whatismyname21,

Lately, I have been speeding up indicators on the development branch. When I get to this one, I'll double check it.

twopirllc avatar Apr 13 '22 16:04 twopirllc