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,

image

6 Likes

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

Thanks

@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.
http://www.amibroker.com/kb/2016/01/22/how-to-fill-background-between-hand-drawn-trend-lines/

http://www.amibroker.com/kb/2007/03/17/how-to-fill-the-area-between-two-lines-with-a-solid-color/

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

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

image

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

17 Likes

Thank you for your help ...:kissing_heart:

1 Like

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

1 Like

Hi,

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.

x

e = ValueWhen(Buy,C)+1;
Plot(Ref(e,-1),"",colorblack,styleStaircase);
ee = Cross(H,e);
PlotShapes(IIf(ee,shapeSMALLdownTRIANGLE,shapeNone),colorblack,0,h,30);

Appreciate some guidance please.