Skip to main content

Auto Target for Amibroker (AFL)

halfman about 15 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 2)
  • Tags:
    target, amibroker

I like to plot auto-target and see how far a price possibly up or down. You can set your own target. Pick the lowest and the highest of a trend, and this indicator will autocalculate the target. Enjoy.

Screenshots

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Auto Target Levels");

GraphXSpace=1; 
Plot(C,"", colorWhite,styleCandle); 

// Get values for target levels 

StartBar=SelectedValue(BarIndex()); 
FinishBar = EndValue( BarIndex() ); 
i = startbar; 
period = FinishBar - StartBar; 

Lo =LLV(L,period); 
Hi = HHV(H,period); 
Line0 = 0; 
Line1 = 0;  //Target resisten 1
Line2 = 0;  //Target resisten 2
Line3 = 0;  //Target resisten 3
Line4 = 0;  //Target support 1
Line5 = 0;  //Target support 2
Line6 = 0; // Target support 3
Line100 = 0; 

for( i = startbar; i < finishbar; i++ ) 
{ 
if(EndValue(C)<SelectedValue(C)) 
{ 
Line0 = EndValue(Lo); 
Line100 = EndValue(Hi); 
Line1 = Line0 + (Line0*Param("UpTarget1", 0.10, 0, 1, 0.01)); 
Line2 = Line0 + (Line0*Param("UpTarget2", 0.18, 0, 1, 0.01)); 
Line3 = Line0 + (Line0*Param("UpTarget3", 0.26, 0, 1, 0.01)); 
Line4 = Line100 - (Line100*Param("DownTarget1", 0.10, 0, 1, 0.01));
Line5 = Line100 - (Line100*Param("DownTarget2", 0.20, 0, 1, 0.01)); 
Line6 = Line100 - (Line100*Param("DownTarget3", 0.30, 0, 1, 0.01));

} 
else 
{ 
Line100 = EndValue(Lo); 
Line0 = EndValue(Hi); 
Line1 = Line100 + (Line100*Param("UpTarget1", 0.10, 0, 1, 0.01));
Line2 = Line100 + (Line100*Param("UpTarget2", 0.18, 0, 1, 0.01)); 
Line3 = Line100 + (Line100*Param("UpTarget3", 0.26, 0, 1, 0.01)); 
Line4 = Line0 - (Line0*Param("DownTarget1", 0.10, 0, 1, 0.01));
Line5 = Line0 - (Line0*Param("DownTarget2", 0.20, 0, 1, 0.01));
Line6 = Line0 - (Line0*Param("DownTarget3", 0.30, 0, 1, 0.01));

} 
} 

Uppercolor=ParamColor("Uppercolor", colorRed);
Midcolor=ParamColor("Midcolor", colorSkyblue);
Lowercolor=ParamColor("Lowercolor", colorYellow);

/* Perhitungan target dimulai dari barindex yang dipilih yaitu dimana yang kita klik nanti.
Untuk mempersempit range pengukuran, klik ganda dan set areanya. 
*/
target0= LineArray(startbar, Line0, finishbar, Line0, 0, 1); 
target100 = LineArray(startbar, Line100, finishbar, Line100, 0, 1); 

// depth of middle lines 
n= round((finishbar-startbar)/2); 

//Target line. 0=no extend, 1=extend right. 2=extend left. 3=extend both. 
target1= LineArray((finishbar-n), Line1, finishbar, Line1, 1, 1); 
target2= LineArray((finishbar-n), Line2, finishbar, Line2, 1, 1); 
target3= LineArray((finishbar-n), Line3, finishbar, Line3, 1, 1); 
target4= LineArray((finishbar-n), Line4, finishbar, Line4, 1, 1); 
target5= LineArray((finishbar-n), Line5, finishbar, Line5, 1, 1); 
target6= LineArray((finishbar-n), Line6, finishbar, Line6, 1, 1); 


Plot(target0,"", colorWhite, styleNoLabel); 
Plot(target100,"", colorRed, styleNoLabel); 
Plot(target3,"", Uppercolor, styleNoLabel); 
Plot(target2,"", Midcolor, styleNoLabel); 
Plot(target1,"", Lowercolor, styleNoLabel); 
Plot(target4,"", Lowercolor, styleDashed|styleNoLabel); 
Plot(target5,"", Midcolor, styleDashed|styleNoLabel); 
Plot(target6,"", Uppercolor, styleDashed|styleNoLabel); 



Title = Name() + " - Auto Target Levels " 

+"\n"+EncodeColor(colorLime)+"Open="+EncodeColor(colorWhite)+O
+"\n"+EncodeColor(colorLime)+"Close="+EncodeColor(colorWhite)+C
+"\n"+EncodeColor(colorLime)+"High="+EncodeColor(colorWhite)+H
+"\n"+EncodeColor(colorLime)+"Low="+EncodeColor(colorWhite)+L
+"\n"+EncodeColor(Uppercolor)+"UpTarget3= "+line3 
+"\n"+EncodeColor(Midcolor)+"UpTarget2= "+line2 
+"\n"+EncodeColor(Lowercolor)+"UpTarget1= "+line1 
+"\n"+EncodeColor(Lowercolor)+"DownTarget1= "+line4 
+"\n"+EncodeColor(Midcolor)+"DownTarget2= "+line5 
+"\n"+EncodeColor(Uppercolor)+"DownTarget3= "+line6
+"\n"+EncodeColor(colorWhite)+"x= "+line0
+"\n"+EncodeColor(colorWhite)+"y= "+line100 
+"\n " 
 
;
_SECTION_END();

7 comments

over 13 years ago

Hi Halfman,

This code seems to be very good. Any one using this. Plz share your experiences. Halfman, kindly provide some tips on using this.

Thanks
Viswanath

over 13 years ago

Dear,
How have you been?This AFL seems to be a very good but it is difficult to interpret without knowing it’s interpretation so would you please send me mail how to interpret this.Regards,
Sunny,
email:ahalimchy@yahoo.com

4. halfman
over 13 years ago

Dear all,
Just use the current peak and trough to see the auto target level. You can see a vertical green line and red line at the picture. I’d like to set 10 – 18% rising or declining, but you may set your own percentage based on your own experience.

It seems like using fibonacci, but it’s not. This formula calculates up target from trough and down target from peak. Hope you find this one useful.

over 13 years ago

Thanks Hlafman for info & guidelines on using this. I was thinking that you have used fibonacci.

over 13 years ago

Hi Halfman,

1) Is the vertical lines in the chart (green & red) are drawn manually or AFL is drawing automatically

2) Is it possible to add change ( you say 10 to 18 is ok for you) in the Title

3) Is it possible to develop any scanning/ exploration for listing the stocks for which we can draw targets & trade accordingly

Thanks a lot in adavnce

Viswanath

Leave Comment

Please login here to leave a comment.