jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Fibonacci retracements

1. is there a way we can draw retracements with just 2 click and always parallel to x-axis.
2. is there a way i can extend these retracements to the end of x-Axis.. ( end of full range) ?

Thanks
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Hi,

Thanks for the question!

1. Sure, you can listen to the dblclick event (https://developer.mozilla.org/en-US/doc ... lick_event) and update the chart with chart.update or update only the series/annotations with series.update or annotation.update.

2. I think this blog post should help yout: https://www.highcharts.com/docs/advance ... tracements
Take a look at this demo:: https://jsfiddle.net/BlackLabel/kxdungr9/

Let me know if that helps.

Best regards!
Jakub
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Fibonacci retracements

i am sorry for confusion. for #1 ..

right now from annotation when you try to draw annotation.. you have t o click at 3 different points to draw on chart.. its 3 click annotation.. instead of that i want to draw entire fib retracements with just 2 clicks.. (by choosing 2 dialgonal points)

#2 -- thanks for link.. thats really useful, just one more question on this.. instead of hardcoding start/end point.. i want let user choose the points.. like any other annotations(line,ray).. how can i do that ?
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Sure, no problem!

1. Unfortunately, I'm not entirely sure what you mean by this. If you want to create a "drawing fibonacci retracements" functionality you'll probably have to implement this yourself (please let me know if I'm wrong and there is a Highcharts function allowing users to create Fibonacci Retracements by clicking on the chart).

2. That's not a problem at all! You can achieve this with chart.update or chart.addAnnotation.

Demo: https://jsfiddle.net/BlackLabel/qdecsxLy/

API:
- https://api.highcharts.com/class-refere ... art#update
- https://api.highcharts.com/class-refere ... Annotation

I'm waiting for your reply regarding point #1. I'll try to help you with that!

Kind regards!
Jakub
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Fibonacci retracements

Thanks for update.. i think i can use this one to create what i need.. but is there a way to get the mouse points ( like other annotation) when user selects on chart (first click would select start and next click would select end)

but for #1 i think i can use retracement function..
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Hi,

You can do it like this: https://jsfiddle.net/BlackLabel/2cnazr1y/

You can customize this solution to your needs, I just wanted to give you a brief idea of how you can achieve it.

Does that work for you?
Jakub
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Fibonacci retracements

Thanks a lot for this idea... while i searching forum i came across this thread

viewtopic.php?p=173851#p173851

here they talk about extending plugin. i still dont what would i have to change to what i achieve.. but do you think that would be reasonable approach rather than adding whole new annotation ?

sorry.. but i am not familiar at all about extending plugin and modifying..
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Hi,

Are you using StockTools to create the Fibonacci retracmenets? I thought that you were trying to create them without using StockTools with your custom 2-click method.

What my collegue meant in the thread you linked is that you can modify Highcharts source code to achieve a certain custom solution when you're using StockTools.

This part of code is responsible for creating the Fibonacci advanced annotation: https://github.com/highcharts/highchart ... 1751-L1810

You can modify it (https://www.highcharts.com/docs/extendi ... highcharts) and adjust it to your needs.

My collegue suggested that you modify the steps array at the end (or the updateNthPoint method) to change the default behavior.

So, depending on whether you use StockTools or not you could either stick with the solution I presented in my previous post or try to modify the code that my collegue attached.

Kind regards!
Jakub
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Fibonacci retracements

Thanks a lot for reply. we decided to use both ways.. so user can add custom *indicator* as fibonacci with custom ranges.. in this case i have to use method you suggested.. and it is a part of stock Tools--> annotation as well.. in such case i will have to modify steps to use just two clicks..

Thanks again for response...
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Sure, let me know if you need any help.


Best regards!
Jakub
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Fibonacci retracements

one more question on same topic..
we have yet another requirement where based on user's choice we have to extend retracements on left or right side.. (dataMax /dataMin) which i can do via following code

Code: Select all

let options = currAnn.options.typeOptions;
options.points[1].x = xAxis.dataMax;
							currAnn.update({
								typeOptions: {
									points: options.points
								}
							});
which is working and it is extending the retracements to the extreme right..but then if user un-select the options..then i have to restore his original settings..
is there a easy way to do it.. i can always store *old* points in current annotations.. and do it.. but just wanted to find out if there is any better approach.

Thanks
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Fibonacci retracements

Hi,

That is the optimal way to do this.

I don't think we can find anything faster than annotation.update({ typeOptions: newTypeOptions }).

Here's a short example: https://jsfiddle.net/BlackLabel/qj2f56z1/

You can stick to this solution and you should not encounter any problems.

Kind regards!
Jakub
Highcharts Developer

Return to “Highcharts Stock”