Fibonacci Retracement Algorithm Attempt: Please Evaluate

I tried to implement a Fibonacci retracement algorithm. I have limited knowledge in technical trading so I'm looking for someone to tell me if I managed to implement the strategy sufficiently, and if not, what I did wrong. I am not worried about returns or anything, just want to know if my strategy implementation is logical. Any help is greatly appreciated.

7 responses

Hi Mustafa,
I'm not very familiar with python, so i won't make any comments on the specifics of your coding, but i am familiar with Fibonacci (Fib) retracements, so i can say a bit about that. Basically, like lots of traditional technical analysis (TA) "indicators", they work SOMETIMES, usually just enough to get you interested, and plenty of people write books with the usual set of "a few well-chosen examples" to show how wonderfully well they work. The problem is that often they don't work. Several studies have been done & documented with histograms to investigate if 0.618, 0.382, etc retracements actually come up more frequently then any other arbitrarily chosen ratios. The finding is that they don't. So yes they "work" (when they work), but they aren't reliable as a stand-alone. If I'm trading (and I have been for > 30 years) and I am already looking for a reason to enter the market, and I see a nice bounce that has just occurred at exactly 0.618, then I usually think: "OK, that's likely to be a reasonably high probability entry point because lots of Fib "true believers" will see & act on it". So, in that sense, I do sometimes make good use of Fib retracements, but as for predicting turning points, no, its just not reliable. I know this doesn't actually answer your question about your code implementation, but at least it might give you some insight as to how worthwhile it is to pursue this specific topic. (I wasted years on it). Cheers, best regards, Tony.

Same thing for resistance lines btw, a fun exercise is to draw 10 lines at random on an intraday chart at the beginning of the week and then check back at the end of the week which lines acted as support or resistance.

Yep, if you put enough lines on a chart some will DEFINITELY work, just ask Mr. Gann ;-))

@Tony Morland thank you for the very helpful response. Do models like the Altman z score and Graham’s intrinsic value formula have more credibility than these technical indicators? I’m not great at finance or anything so I try to pick up on what I can.

Technical Analysis (TA) : That's all the purely price-related stuff.
Fundamentals: Altman's Z-score was designed to predict bankruptcy of companies. Obviously you would generally prefer not to hold long positions in those. It is a bit out of date now and there are newer and better methods, but it is still a good starting point for generating ideas. Warren Buffett's amazingly consistent success over decades is based very much on Benjamin Graham's ideas of fundamental value of companies, updated with the more modern idea of the importance of growth as well.

Some people like fundamentals and some people like technicals, but personally I think that trying to rely on only fundamentals or only TA is like trying to run with only one leg. It can be done (see https://en.wikipedia.org/wiki/Terry_Fox), but it's damn hard, so why not run with both legs, i.e. combine both TA (price data) and fundamentals. You can think of the fundamentals as telling you WHAT to buy or sell and the TA (price) part as helping with the timing, i.e. the WHEN part.

Thank you Tony that was very helpful!

Here's some info about the more modern successor to the Altman Z-score:
https://alphaarchitect.com/2011/07/23/stop-using-altman-z-score/