Three part question:
- How to find 2 user created horizontal lines on a chart by name and return the price of each.
- Then determine which HLine was crossed by the price most recently to determine trend direction.
- Calculate Fibonacci levels based on prices and direction
Difficult to understand exactly what you are after, not sure if you are trying to find the graphical objects or just calculate levels based on the prices. Assuming you have the price of the two horizontal lines, the following structure and function can be used to calculate Fibonacci levels. (price 1 is earlier in time than price 2).
Calculation based on formula found here
this is your value if you have name of the object, if you dont have it - need to loop over all objects:
Working example of Fibonacci object that can be edited by the user and printing of fibonacci levels.