Harmonic Pattern Recognition With Python
HTML-код
- Опубликовано: 24 апр 2023
- In this video I show python code for pattern recognition of Harmonic Patterns. The code shown finds the Gartley, Bat, Butterfly, Crab, Deep Crab, Cypher, and Shark Harmonic Patterns. These are all XABCD patterns. The code is able to find any other XABCD pattern given the ratios. We backtest the harmonic patterns using hourly bitcoin data.
Chart Pattern Algorithms (directional change): • 3 Must-Know Algorithms...
Full Code: github.com/neurotrader888/Tec...
Patreon: / neurotrader
Links
en.wikipedia.org/wiki/Golden_...
en.wikipedia.org/wiki/Fibonac...
The content covered on this channel is NOT to be considered as any financial or investment advice. Past results are not necessarily indicative of future results. This content is purely for education/entertainment.
Your upload schedule is on point
Great video on Python trading!
very nice , as always , dude i am fan of your work
i want to say that this is some well written code and it is very accurate. I have generated all patterns detected in the btc csv file and am doing well so far. am working on a machine learning project to detect patterns and predict direction and possible stop points
Im doing the same thing right now. Im data scientist. Can you tell me how you did the feature engenieering?
What results?
Proving astrology is... astrology! Anyway amazing work! I'd like to see more performance evaluation metrics on results: sharpe, sortino and etc. since profit factor is very one-dimensional.
I can start showing more metrics, but I respectfully disagree. In my experience, the profit factor has some of the least bias. Often yielding better results for out of sample use (don't be dissuaded by its simplicity). It is my favorite criterion along with the martin ratio. As the amount of data used increases the performance criterion used tends to matter less.
I may make a video comparing different performance criterion's training bias in the future.
by the way you can use "Héron formula" to value the triangles ( you have many triangles in this harmonious paterns methos you provided here )
Hello..many thanks for such educational videos...do these patterns apply to binary option trading platform?
How do feel about G.W. Gann methods?
can u do the "dragon" and "black swan" and "white swan" and even the more hidden "wolfe" harmonic pattern?
I've never heard of any of these, I'll take a look. I know of wolfe waves. Whenever I return (some day but not today), I'll be making a video about wolfe waves.
Have you ever considered researching academic papers to build strategies?
imo you write your code in such a way that simply using numba will probably help increase the performance greatly without changing too much of the code itself
Interesting, I'll look into that. Most my coding experience is with C++, and it probably shows. My python isn't very "pythonic"
Looking forward in watching this video , neurotrader can you implement metalabelling on a simple strategy please
Yes. Great idea, and an important topic. I'll make video about this soon.
@@neurotrader888 when you make one regarding metabelling in the future, if possible, can you also explain the differences between adjusting signal threshold of the primary model/signal and metalabelling.
By that I mean most of the strategies existed today often comes with parameters to set. what are the result differences between 'Optimizing the params' and training a metalabel model to judge the primary signal.
Or another example would be a primary model itself could be a simple ML model trained with MACD signals.
What are the differences between 'adjusting the decision threshold' of the primary model verses using metalabelling.
thanks a lot.
@@playeryin Roughly speaking. The primary model typically seeks to maximize recall. While the meta model seeks to maximize precision.It's difficult to prioritize both of these with one model. The combination of both typically improves the F1 score. But there is quite a bit more to say. I'll try to think of a good ways to explain.
en.wikipedia.org/wiki/Confusion_matrix
@@neurotrader888 First of all, thanks for you reply. I understand what you are saying.
The first model is to maximize signal occurrence, regardless of the True or False. And meta would try to filter out False signals.
but let say the primary model is also a ML model, supervised trained, that has a last neuron using softmax as activation to give buy signal. typically > 0.5 yield to buy signal.
we could adjust the the buy signal threshold to > 0.7 to yield less signal in general, and probably left with more accurate signal.
so the first time I mentioned metalabelling to my friend, he asked me how useful could metalabelling be while he could just adjust the threshold of the primary model? potentially leading to the same goal.
I didn't know the answer to that lol.
@@playeryin Ok I get you, I've wondered the same thing. Continuing with your softmax example..
If the primary model is concerned with learning the side to trade. (Deciding whether to long or short). The primary model's recall will be maximized with a decision threshold of 0.5. Above 0.5 go long, below 0.5 go short. In my experience the features (model inputs) predictive of a successful long prediction are often different from the features predictive of a successful short prediction. Long and short asymmetry. The meta models accounts for the long/short asymmetries that the primary model misses, as the primary model is focused on learning whether to long or short.
But because the mentioned asymmetry, I usually build models that are specialized for a single side. A model that learns long trade setups for example. When doing this I've found it effective to optimize the decision threshold (achieving the same goal as meta labeling with less complexity). The extreme values of a model's output (and indicators) are almost always the most predictive. I have tried meta-labeling models on top of a side specialized model but have never found it effective.
I've mainly found meta labeling effective when the primary model is not a machine learning model. But rather a defined trading rule. Price crossing above some line, MACD, etc..
This topic is pretty in the weeds and I probably won't cover this in a meta labeling video. Hopefully this answers at least part of your question. Someone more knowledgeable than me may disagree with what I said. I'm just saying what I've experienced. Your mileage may vary.
I tried with 400 rows, and there were 8 patterns detected, one of which was found in rows 320 to 372. However, when I tried with the tail(100), that pattern was not detected. Thank you for your response.
The directional change algo needs sufficient data to "warm-up". It can be unstable at the very beginning of the data. The pattern may be from 320-372, but it needs data prior to that for the detection to work.
Thank you. How can I make this 10:06 pattern appear in the last row or in the last 2 rows?
n how to replace 2% to 0.1 % at 10:22
Can you test the methods outlined in the book "Complete Stock Market Trading And Forecasting Course" by Michael Jenkins? It uses Geometric Methods and Gann techniques and someone on Reddit claimed to have made a lot of money using it on BTC in various timeframes.
I'm not familiar with that book. While it is usually not effective, I do enjoy automating subjective trading tools. I'll take a look, if the method is not too vague I'll give it a shot. Never trust a redditor :)
I wouldnt conclude anything
- optimize zigzag retracement ratio
- try out different exit rules
These two can drastically change the result
For my whole life, I always thought Chart Patterns are subjective discretionary BS, until I saw this video!
Wayyyyyyyyyyyyy too intelligent! This shouldn’t free. #GodLevels! Can you do videos on convex optimization algorithms please!!!
Maybe, the only convex optimization I use regularly is least squared. Usually doing a SVD. I used to use quadratic programming for Markowitz style portfolio optimization, but I've never found it effective out of sample.
I have a whole system of fib trading that is based on 0.618 and I have seen serious accuracy in indian equity markets. The only thing is it is manual and I want to automate it. We can discuss about it if you are interested do reply !.
Whats fib trading?
could you elaborate?
Can you help find an upcoming Harmonic Pattern or a pattern that's just been made with this algorithm?
This program finds the harmonic patterns as they are made. Earlier detection could be done with modification, checking ratios not including the D point in the XABCD patterns.
@@neurotrader888 i tried implementing this code into my algorithm as a test but wasn’t able to do that successfully. Can we connect? Can you share your email?
Is there any way we can plot that on chart as well ?
replace
data = ohlc.iloc[pat.X - pad: pat.D + 1 + pad]
to :
data = ohlc
if you can make strategy about volume☺☺☺
I will eventually. Volume is pretty tricky. It often has a non-linear relationship with price (if any relationship). I have a half-way done video inspired by the Wyckoff effort-result rule. It still feels like its missing something though, so I'll publish it once I iron it out.
can you do a Elliot wave strategy
Maybe in the future. Elliot wave stuff is usually pretty vague. Hard to automate. But I've seen a few papers attempting to automate parts of the theory. Never tried them though
Trading view is doing that in case that helps
The self fulfilling prophecy explanation doesn't explain why Fibs also work on non tradeable charts like BTC dominance or DXY.
Interesting, I'll try the retracement script on dominance/dxy when I get a chance. Would be weird to see fib ratios on a non-tradeable.
Dude, goldbach
It’s funny that you don’t know WHY Fibonacci ratios work.
In trading we're always left in the dark. I do not know (with 100% confidence) why any strategy works. I can use statistics to gain confidence, but at the end of the day I can only theorize.