Manipulation of mouse-drawn annotation


I'm trying to figure out if I can have a chart detect when and where I draw a trendline with my mouse, and then annotate some text near that point based on the (x2,y2) (x1,y1) position. I would like, for instance to plot some text stating the percentage change from one point to the other and how long it took.

In this picture example, I would draw the trendline as shown but the text would appear naturally after calculating the trendline data:

I couldn't find any reference to anyone doing this.


You can easily achieve that by using studies in AFL formulas. Play around with the AFL shown in this KB - Getting X, Y co-ordinates of Study().

Once you have the co-ordinates of your study (which is a trend-line in your case), you shall be able to then display your calculations anywhere you wish with reference to those co-ordinates.


Thanks! I was using the wrong keyword. I was calling them annotations when they are studies. Thanks!

1 Like