Plot Fibonacci levels between two inputs


Category:
0
0

Hi Pete,

I am looking for a study where there are two inputs for high and low and it plots the fibs.

Thank you in advance for your help

Shaishav

Marked as spam
Posted by (Questions: 49, Answers: 62)
Asked on July 2, 2023 7:18 pm
137 views
0
Private answer

I moved your question out of the "Frequently Asked Questions" and into the "Chart Studies" topic. I also updated the title of your question to include the full name instead of the abbreviation. Both of these changes will make it easier for the rest of our viewers to locate this solution using the search function.

You did not state which direction you wanted the Fibonacci levels to be computed so I had to pick one. I included the three most common Fibonacci levels as well as the zero and 100% levels. Once you see how the code is structured you can add any additional lines you want. I also included user inputs to adjust the multiplier for each of the three Fibonacci levels.

Screenshot below shows how this looks on the chart. The screenshot includes a comment showing where I have added a hand drawn Fibonacci retracement to validate the levels are computed correctly.

input priceHigh = 100.0;
input priceLow = 50.0;
input fibOne = 23.8;
input fibTwo = 50.0;
input fibThree = 61.8;
def range = priceHigh - priceLow;
plot fibZero = priceLow;
plot fibLevelOne = priceLow + (range * fibOne * 0.01);
plot fibLevelTwo = priceLow + (range * fibTwo * 0.01);
plot fibLevelThree = priceLow + (range * fibThree * 0.01);
plot fib100 = priceHigh;

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on July 2, 2023 7:37 pm
0
Thank you Pete. I can add other levels but I will not be able to add the direction . If you can modify the code to include the direction selector that would be great. Thank you
( at July 4, 2023 3:56 am)
0
All you have to do is invert the values you apply to each input. In the example provided in my solution, you would simply use a value of 50 for the "priceHigh" input and a value of 100 for the "priceLow" input. Obviously its possible to build a solution which has many additional features and functionality. But this is what I am able/willing to build free of charge.
( at July 4, 2023 9:01 am)