[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: I GIVE UP with this to code



PureBytes Links

Trading Reference Links

Hi Mohammed
I give below a code for afl which is similar to request. This code 
generates support and resistance. 
See if it suit your requirements


SetChartBkColor(47);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %
g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( 
ROC( C, 1 ) ) ));
SetChartOptions(1,chartShowDates);
/* The first set of lines are to set up the color coding for

the price bars */

outsidebar = Outside();

insidebar = H <= Ref(H,-1) AND L >= Ref(L,-1);

upbar = H > Ref(H,-1) AND L >= Ref(L, -1);

downbar = L < Ref(L,-1) AND H <= Ref(H,-1);

barcolor=IIf(outsidebar, 1, IIf(downbar, 4, IIf(upbar,5, 6) ) );

/*The following builds the alligator lines*/

MaxGraph=12;

AlligatorBlue=Ref(Wilders(Avg,13),-8);

//Graph0=AlligatorBlue;

AlligatorRed=Ref(Wilders(Avg,8),-5);

//Graph1=AlligatorRed;

AlligatorGreen=Ref(Wilders(Avg,5),-3);

//Graph2=AlligatorGreen;

//Graph0Style=Graph1Style=Graph2Style=1+4;

Graph3=C; 

Graph3Style=64; 

/*Red:* modified for Amibroker*/

 

/*

Graph3Color=22; 22 is the number for dark green

*/
Graph3BarColor=barcolor;

Graph2Color=27; /* 6 is green */

Graph1Color=5; /* 5 is red color */

Graph0Color=7; /* 7 is dark blue */

/*The following builds Fractal Up*/

var1=ValueWhen(

(Ref(H,-2) > Ref(H, -4)) AND

(Ref(H,-2) > Ref(H, -3)) AND

(Ref(H,-2) > Ref(H, -1)) AND

(Ref(H,-2) > H), Ref(H,-2),1); 

FractalUp=HighestSince(var1>0,var1,1);

Graph4=FractalUp;

Graph4Color=3; /* 6 is green */

Graph4Style=9;

/*The following builds Fractal Down*/

var2= 

(Ref(L,-2) <= Ref(L, -1)) AND

(Ref(L,-2) <= Ref(L, 0)) AND

(Ref(L,-2) <= Ref(L, -3)) AND

(Ref(L,-2) <= Ref(L, -4));

FractalDown=ValueWhen( var2,Ref(L,-2),1);

Graph5=FractalDown;

Graph5Style=1;

Graph5Color=8; /* red is 5 blue is 7 */

Graph5Style=9;

/*

Graph6=ma(c,17);

graph7=ma(c,50);

graph8=ma(c,200);

graph6Style=Graph7Style=graph8Style=12;

*/

/* Below are the buy sell signals for testing */

Buy = Cross(H,FractalUp+0.065) 

AND (C > AlligatorRed) ; 

Sell= Avg < AlligatorGreen 

OR (Ref(C,-2) < FractalUp 

AND (Ref(C,-1)<Ref(C,-2) ) ) ;

 
Plot(EMA(C,200),"200ema",colorBlack,styleNoLine|styleDots|styleThick);
a1=EMA(C,200);
//Plot(Volume , "Volume", colorSkyblue, styleLeftAxisScale | 
styleHistogram );

/* The following is Guru commentary coding */

/* Guru Commentary */

WriteIf(Hold(Buy==1,10),

"Buy signal bars ago " + WriteIf(Hold(Buy==1,10),

WriteVal(BarsSince(Buy==1)),""),

"No Buy Signal") + "\n" +

WriteIf(Hold(Sell==1,10),

"Sell signal bars ago " + WriteIf(Hold(Sell==1,10),

WriteVal(BarsSince(Sell==1)),""),

"No Sell Signal") ; 

/* End of commentary code */

/* The following lines of code set up a sell on the last day if in an 
open position*/

barnumber = Cum( 1 );

lastbar = barnumber == LastValue( barnumber );

Sell = Sell OR LASTBAR;

Filter = Cross(H,FractalUp+0.065) OR Cross(L,FractalDown-0.065) ; 

NumColumns = 5;

Column0 = IIf(Buy==1,1,-1);

Column0Format = 1.2;

Column0Name = "Buy+1,Sell-1";WriteIf(Buy==1," Buy"," Sell" );

Column1 = FractalUp;

Column1Name = "FractalUp";Column1 = FractalUp; WriteVal(FractalUp);

Column1Format = 1.2;

Column2 = FractalDown;

Column2Name = "Fractal Down";

Column2Format = 1.2;

Column3 = MA(V,3)/EMA(V,17);

Column3Name = "MAV(3/17)";

Column3Format=1.2;

Column4 = C;

Column4Name = "Today's Close "; 

Column4Format=1.2;

 

/* removes redundant buy and sell signals */

Buy=ExRem(Buy,Sell);

Sell=ExRem(Sell,Buy);

 

first=1; 

/* First is the number of days for each ROC interval for reviewing 
performance */

/* To use this filter always make the current day at least 3*first 
days before the current date

for meaningful results */

/*

numcolumns = 7;

column0 = C;

column0format = 1.2;

column0name = "Close";

column1 = ref(C, 1+first);

column1name = "Close+i ";

column1format = 1.2;

column2 = ref(C,1+first*2);

column2name = "Close+i*2 ";

column2format = 1.2;

column3 = ref(C,1+first*3);

column3name = "Close+i*3 ";

column3format = 1.2;

column4= ref(C,first*1+1) - C;

column4name="ROC+i";

column4format = 1.2;

column5= ref(C,first*2+1) - C;

column5name="ROC+2i";

column5format = 1.2;

column6= ref(C,first*3+1) - C;

column6name="ROC+3i";

column6format = 1.2;

*/

/* End of Exploration Code. */


------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/