Closed kasoob closed 2 months ago
As an enhancement, I'm wondering we could plot your chart patterns using lightweight-charts-python (https://github.com/louisnw01/lightweight-charts-python).
I had come across this library before. It's pretty nice with all the bells and whistles built in. I haven't tried it out yet though. It should not be a problem making this work with my code.
As for the plotting the lines, Matplotlib
uses a sequence like (point_A, point_B) where each point is a sequence x and y values. (date and price). I imagine its the same with Lightweight-charts-python
.
I'll consider it, after I have tried out the library. On first glance it certainly looks very developer friendly.
I'm also wondering if we can import your library and run the chart pattern scanners directly in a python code. We should develop this library into a module we can import using pip. This will truly take it to the next level.
The utils.py
is the core of Stock-Patterns, everything else is just a UI wrapper for users to interact with.
utils.get_max_min
function provides the pivot points required to check for patterns. utils.find_*
functions takes the DataFrame and pivots and returns a dict (if pattern is detected) else None.You can use the information to plot the results in any charting library of your choice.
I do have plans to publish it as a pip package. I want to add a few more patterns before finally publishing. This might involve changes to get_max_min
signature, standardizing the return values from the functions and adding documentation to make it easy to use.
Any updates on how this is going? Please keep us posted 🙏 When do you think it may be complete, do you have some sort of timeline?
Current priority is to fix the IEODFileLoader for intraday data. The issue pertains to the way Pandas resamples data.
For example, below is NSE data resampled from 1 min to 30 mins and 60min. Market starts at 9:15am.
First candle should be from 9:15am to 9:45am.
Same for 1HR
This is not an issue for 24/7 markets like Crypto and Forex.
Most of the issues have been fixed. So i hope to fix the rest, before end of this month.
If all goes well, I intend to start working on new patterns from next month. I am considering harmonic patterns or flags.
Harmonics are easy to implement and will readily fit within the framework of Stock-patterns.
Flags are a bit more challenging and will need more thought on implementation.
I don't have timelines for these yet. There are other commitments and my own trading that have taken priority lately. I will update further once i get started on the new patterns.
I should perhaps release a poll to see which patterns would be more popular among users. I have never used harmonics before but i am quite intrigued by it. Love to see how it performs in the market. Let me know your thoughts.
That's great, let us know when the fixes are done. I will keep following your progress.
I have read a lot about harmonics, there's many contradicting views, but it would for sure be amazing to add them to your library. Perhaps we can test their efficacy ourselves according to our trading style.
Flags & pennants are really interesting as well, from what I've seen they can be very reliable. What is it that poses as a challenge with their implementation? From what I gather, we need to detect a strong uptrend/downtrend (impulsive wave), followed by a corrective wave within support & resistance trendlines that are likely to be broken by another impulsive wave.
That doesn't sound very complicated in theory, but I am not the one writing the code, so I wouldn't know. Also, you do have pennants already implemented, and both flags & pennants work in a similar way as continuation patterns, right? In any case, let me know if I can be of help.
Perhaps, on the long term, we can also look on implementing Elliott waves. The theory behind it seem really interesting. They are quite promising. Let me know your thoughts.
Thanks for giving us an overview on your plans, keep us posted. Your project will definitely take off once its complete, and incorporated with the TV lightweight charts.
In my view, harmonic patterns are nothing but pullback structures. Its a complex pullback with multiple down legs that often trap pullback traders like me :stuck_out_tongue:.
If you see the approx Bat pattern below, If XABCD fails to match the bat pattern, i can repeat my search from C, since it is the next highest point. That's the essence of this library, looping through and finding all possible structures rather than find a pattern within a set window or time period.
Bat
A
/\ C <---- If patterns not matching, C become A and we continue search
/ \ /\
/ \/ \
/ B \/
/ D
X
For the flag, B must be a pivot higher than all recent pivots and A and B must be a certain distance to create the pole structure.
The problem is identifying the flag structure. Since a pivot is formed from 13 candles (6 before and after the pivot). At best, we will have B and maybe C. (A typical flag is 5 to 15 candles in length).
Either we need some custom code to identify the flag or reduce the bars required to identify the pivots. Either way, its not what the library excels at. There are many other scanners and screeners that do a decent job of identifying a flag. This is just my initial thoughts about flags.
Flag
B D
/\ /\
/ \/ \/
/ C E
/
/
/
/
A
As for TV lightweight charts, Mplfinance already does a fine job. It would be extra work trying to support both. Then again, it might turn out that TV lightweight outperforms Mplfinance. I'll give it a run when I'm free and see.
That's great. Harmonics and flags would all be excellent additions to your library. I am excited to try them out when you're done.
What about Eliott waves, what are your thoughts on them? I have read a lot about them, but haven't been able to test them out properly. They can be very reliable to predict future price movements though, and especially best when used with Fibonacci ratios. Eliott waves might be very tricky to implement, but would be valuable. What do you think?
What about Eliott waves, what are your thoughts on them?
I actually bought the book Elliot Wave Principle
some years back with great anticipation.
Unfortunately the book is just that -- Principles and theories behind Elliot Wave. I just couldn't find any actual implementation. By the second or third chapter, I gave up. Perhaps i bought the wrong book or someone could refer me to a better book.
I am closing this for now. I will start posting updates in the discussions once i start work. This repo is now mostly stable, apart for some documentation updates.
I will surely need your inputs once I start implementing.
Will certainly be thrilled to contribute. Please let me know when you start the work. Thank you
I started a discussion on Harmonics https://github.com/BennyThadikaran/stock-pattern/discussions/72#discussion-7243110
Just came across your work, looks very promising. Keep it up ;)
As an enhancement, I'm wondering we could plot your chart patterns using lightweight-charts-python (https://github.com/louisnw01/lightweight-charts-python).
This would make your library much more valuable, as it can be more readily utilized in a full algo trading system.
I'm also wondering if we can import your library and run the chart pattern scanners directly in a python code. We should develop this library into a module we can import using pip. This will truly take it to the next level.
Let me know your thoughts.