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

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 );

@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:

1 Like

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

1 Like


I'd like to plot the equivalent of the applystop (profit) in my chart. For regular backtest mode, that's easy enough - as below. But for regularrawmulti, it's a bit harder. I'd like to apply the same point target to each buy signal like so.


e = ValueWhen(Buy,C)+1;
ee = Cross(H,e);

Appreciate some guidance please.