facioquo/stock-indicators-python

help: getting empty values with Williams Fractal

Waldi2130 opened this issue · 22 comments

Hello, very much in need of help, the third day I can not determine the cause, my indicators do not work, I pass to begin with information for 200 candlesticks, then the program adds each time new candlesticks, I do not get errors in the code, but when I try to get a fractal, they are always empty, the same with some indicators, let's say sma.
I am using Windows 10, NET 6.0 and NET 8.0, mono installed, Python 3.11.8.
The first 200 candles are recorded normally, then I add new ones like this:
1707408420 | 0.89531 | 0.89531 | 0.89531 | 0.89531

image
image

This may just be an interpretation problem with the results of Williams Fractal. The bull points and bear points are maintained in separate datasets because it's technically feasible that there'd be bear and bull event on the same date if the candle is long. If you plotted these two datasets, it'd look something like this these green/red dots:

image

This indicator is really for identifying localized high/low pivots, which can be decent trigger points if they were timely. The problem with this indicator though is that it repaints and will never identify this pivot until after window_span (default: 2) periods have elapsed (possibly too late to act). I think this one is best used for visual charting, rather than algo trading.

If you're really looking for trend reversals, take a look at stop and reverse indicators too.

Just another guy's mac has them working fine, that's why I'm trying to figure it out. and the code is the same as mine.

Just another guy's mac has them working fine, that's why I'm trying to figure it out. and the code is the same as mine.

It does seem odd that you're parsing these differently with os.name. Are you stuck on simply parsing quotes into a usable set? It'd be helpful to see more about your raw quote sources. Can you try to print them to console, without complicating it with the extra fractal calculation, just to see if the quotes themselves are loading okay?

Also, it looks like you're trying to convert to European style numbers with , instead of .. It's hard to tell, but maybe that's the problem?

image
I have now tried getting data from the Chandelier Exit indicator, as you can see in the console, it comes in and works out.

image
Also, I tried to remove os.name, when I did this, I stopped working and the rest of the indicators and the program no longer displays anything

image
This is my initial data I'm getting, it's about 200 lines of data.

I don't see anything weird with your CANDLES values.
image

What do your quotes look like after parsing them?

image

this is what you get when you record

image
the super trend indicator is also blank (

It is possible to get no results with a short quotes dataset on fractal and SuperTrend if there’s no identifying trend reversals. If you upload those quotes, I’ll take a closer look when I have some time.

I can upload you a csv file with 200 lines of candle data.
I also tested leaving the program running for a day to collect more than 200 lines, but when I checked, the data was always empty. I will try to do another test.
I just can't understand how the other guy's code can work and I can't.

other guy's code can work and I can't.

For clarity, is he using the exact same quotes dataset?

it was tested on these quote datasets too and everything was None.

I still haven't been able to find a solution to the problem.
Tell me, did you have time to check it out?
Thank you.

So far, I've done two things to rule out the core algorithm:

  1. Run these quotes through our manual calculations » Fractal.Calc.Issue346.xlsx
  2. Run these quotes through our core .NET library » https://dotnetfiddle.net/9l1AUR
  3. We also have passing unit tests in the Python library indicating the same

There are no issues there, but I think we already know that. For a quick check, I converted . to , in the spreadsheet and it produced bad results; but I expected that because I'm not running on European localization settings on my Windows PC.

Current hypothesis is kindof the same for me: it has something to do with the way you're converting quotes, and what the library understands. I'm now trying to figure out if there's some localization fixes we need to do in the Python library to accommodate localized number formats -- or, if this is just something in your conversion code. cc @LeeDongGeon1996

Before I spend more time on this, can you check to make sure you're mapping the fields with the correct index?

# what you provided
,timestamp,open,close,high,low
0,1707408960.0,0.8955,0.89622,0.89622,0.89536
1,1707409020.0,0.89622,0.89697,0.89699,0.89597
2,1707409080.0,0.89697,0.89644,0.89697,0.8964
...

If your sources include that index field, this would mean your field mapping should be:

...
  for candles in CANDLES:
    open = candle[2]
    close = candle[3]
    high = candle[4]
    low = candle[5]
...

The mapping you've shown above, for reference:

image

Hello, yes, I am mapping to the correct index, I have attached a screenshot, I also wrote the resulting data to csv to show it to you.
image

Sorry, but it's hard to understand where the payload_str came from, what PERIOD value is, and why CANDES 's indexing is starting from 0.

image
Oh, I didn't clarify that point, please forgive me.
I get this data directly from the graph via websocket and chromedriver. They are constantly updated and after a while they give me the last 200 candles and constant information about new candles.

Oh … I think I see what you were expecting. The current version of our library doesn’t yet support observable streaming use cases, it’s a basic static converter of quotes, so adding a new quote does not automatically generate a new indicator value unless you recalculate the full set by repeating results=indicators.get_fractal(quotes) after new quotes arrive.

Our next major version will focus on incremental and streaming data use cases, to more proficiently calculate subsequent increments.

From your provided static quotes, I’ve not had any bad results as you’re describing, so I don’t think there’s anything we need to fix in the library, other than perhaps improving our documentation or perhaps some localization issues with using commas instead of decimal points.

With that said, I’ll still do what I can to help you through this use case, but I suspect it’ll be more about reviewing your code and less about the library.

@Waldi2130 if you need more help here, let us know, or close this issue.

Hello, I still don’t understand why another person on a MacBook has a fractal working with the same code, I’ll look into it further.
I will close this ticket, thank you for trying to help me.