Custom lines with labels. How to plot text next to the plotted line on the chart

I got this to plot a line on the chart and wanted to plot text to the right side of the line

Eg : " ____M1" want to show up next to the Horizontal Line with the "value"

Plot( cdl( M1 ), "", colorLightBlue, styleLine +styleThick  + styleNoRescale );
Plot( cdl( N1 ), "", colorLightBlue, styleLine +styleThick  + styleNoRescale );


Also want ted to fill grey cloud between the lines

PlotText( ''text'', x, y, color, bkcolor = colorDefault, yoffset = 0 )

got the syntax in AFL library but I dont know how to implement it Plz help

There are many possible ways, but this one is probably the simplest:

M1 = LastVisibleValue(HHV(H, 10)); // Example
N1 = LastVisibleValue(LLV(L, 10)); // Example
LVBI = LastVisibleValue(BarIndex());

PlotOHLC(M1, M1, N1, N1, "", colorLightYellow, styleCloud|styleNoLabel, Null, Null, 0, -5, 1);
Plot( M1, "M1", colorLightBlue, styleLine|styleThick|styleNoRescale );
Plot( N1, "N1", colorLightBlue, styleLine|styleThick|styleNoRescale );

PlotTextSetFont("   M1   ", "Arial black", 10,  LVBI - 5, M1, colorGreen, colorLightGrey, -5);
PlotTextSetFont("   N1   ", "Arial black", 10,  LVBI - 5, N1, colorRed, colorLightGrey, -5);

Lines%203

15 Likes

@Milosz Thank You so much

1 Like

Hi, I want to use labels to mark fixed Values on the chart for example a support or a resistance using the PlotGrid method, can you help me on this?

@mugsd your description is very short and vague. I might be able to help you but I won't do everything from scratch. Why should I? I have already provided several examples that you can use. One of them is above. Have you tried modifying it? Some others here:

But in this case I simply recommend using Horizontal line Tool and marking Show Y value on right/left in the properties. No AFL coding required at all:

SupRes

https://www.amibroker.com/guide/drawtools.html

3 Likes

Plot( MovingAV, " MOVINGAV " , colourchange , style = styleLine , styleThick , 0 , 0 , 0 , 0 , ) ;
WHERE IS WRONG ? PLEASE.....

@niloy, welcome to the Forum!

Please try this:

Plot( MovingAV, "MOVINGAV", colourchange, style = styleLine | styleThick ) ;

Optionally, you can shorten it as:

Plot( MovingAV, "MOVINGAV", colourchange, styleLine | styleThick ) ;

The significant change here is the use of the | operator (Bit-wise "Or") to combine the values of style. The extra parameters are probably not needed, and you can leave them out.

I suggest to carefully review the documentation for the Plot() function and this document titled: Using graph styles, colors, titles and parameters in Indicators, that will provide many examples.

3 Likes

Made my day....thanks a lot..was looking for it

1 Like