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

howto
Tags: #<Tag:0x00007fb3dca50b58>

#1

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
#2

@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


#3

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

Thanks


#4

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


#5

Thank you for your help ...:kissing_heart:


#6

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