Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save normanlmfung/fc4573e4a934e9358fb93d041d9acf50 to your computer and use it in GitHub Desktop.
Save normanlmfung/fc4573e4a934e9358fb93d041d9acf50 to your computer and use it in GitHub Desktop.
test_fibonacci_example_3
'''
Example 3, What if market just follow Fibonacci? After ten itterations, it'd converge to usd61.4k, as price_range narrows!
0: 54237.944
1: 65883.57060800001
2: 58686.57336425601
3: 63134.3176608898
4: 60385.61168557012
5: 62084.31197831768
6: 61034.51519739968
7: 61683.289608007006
8: 61282.34702225168
9: 61530.12954024847
10: 61376.99994412645
11: 61471.63403452986
12: 61413.150166660555
'''
swing_low = 42590 # 20240201
swing_high = 73082 # 20240314
swing_low_idx = 1
swing_high_idx = 2
for i in range(100):
retracement_level = estimate_fib_retracement(swing_low, swing_low_idx, swing_high, swing_high_idx)
if swing_low_idx < swing_high_idx: # high came first? Or low?
swing_low = retracement_level
swing_low_idx = 2
swing_high_idx = 1
else:
swing_high = retracement_level
swing_low_idx = 1
swing_high_idx = 2
print(f"{i}: {retracement_level}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment