How to plot an extend line from point A (was: Plot Line Help Please )

Tags: #<Tag:0x00007fb3dca50b58>


Hi All,
I'm new to afl coding. I wrote the fallowing code to plot line from candle (High / Low ) where Two MA Crossed. The problem with this code it is plot the line along the chart . What i need is to plot the line from the bar (High / Low ) where MA Crossed level was established and extend for 5 bars only after that.

Thank you in advance.

		MACross = Cross(MA(C,8),MA(C,50));
		CrossH = ValueWhen(MACross,H);
		CrossL = ValueWhen(MACross,L);

		Plot( CrossH, "CrossH", colorLightBlue, styleLine | styleThick );
		Plot( CrossL, "CrossL", colorDarkRed, styleLine | styleThick );

Plot Lines on chart
Plot Lines on chart

@savio I am not sure if I understood you correctly, but maybe try something like this

MACross = Cross( MA( C, 8 ), MA( C, 50 ) );
CrossH = ValueWhen( MACross, H );
CrossL = ValueWhen( MACross, L );

LineCrossH = IIf( BarsSince( MACross ) < 6, CrossH, Null );
LineCrossL = IIf( BarsSince( MACross ) < 6, CrossL, Null );

Plot( LineCrossH, "CrossH", colorLightBlue, styleDashed | styleThick );
Plot( LineCrossL, "CrossL", colorRed, styleDashed | styleThick );

Gives you something that looks like,



yes exactly as that and if it possible to highlight the area between the two lines that will be nice :slight_smile:



@Savio it helps to put the user name in your post because that will create a notification to the user that you are answering him (so use @ "username").

A couple of useful links you need to review.

PlotOHLC( LineCrossH,LineCrossH,LineCrossL,LineCrossL, "", colorYellow, styleCloud); 


Hope you show me some "love" (click the "like" heart) :heart: !


Thank you for your help ...:kissing_heart:


Your reply was so nicely written that even I clicked the heart! :smile: