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.