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

Williams AFL code



PureBytes Links

Trading Reference Links

I don't know why it never occurred to me when I first was talking about the 
Williams system that I developed to attached the code in its native form, 
but it never did. So here it is as my latest incarnation for the record if 
anyone is going to bring these things together.

Steve/* 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(A,13),-8);
Graph0=AlligatorBlue;
AlligatorRed=Ref(Wilders(A,8),-5);
Graph1=AlligatorRed;
AlligatorGreen=Ref(Wilders(A,5),-3);
Graph2=AlligatorGreen;
Graph0Style=Graph1Style=Graph2Style=1+4;

Graph3=C; 
Graph3Style=64; 

/*
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;

/* the following code is for the consolidation periods or better know
as the sleeping Alligator */

var3= 5;
var4= 3;
var10=10; 
var0= Ref(Wilders(C,13),-8);
var1= Ref(Wilders(C,8),-5);
var2= Ref(Wilders(C,5),-3);
var5= Ma((var0+var1+var2),var4) ;
angle=Atan(var5-Ref(var5,-var3)/var3);
angle=iif( angle >90,angle-360,angle);
hope=iif( angle <20 AND angle>-20,1,0);
cry=((Stdev(C,var3*2) - Ref(Wilders(Stdev(C,var3*2),8),-5))/
(Ref(Wilders(Stdev(C,var3*2),8),-5)))<0;

/* End of consolidation code or sleeping alligator */


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

/*
buy = cross( rsi(), 30 );
sell = cross( 70, rsi() );
*/

/*
buy = cross( ultimate(), 50 );
sell = cross( 50, ultimate() );
*/


buy = cross(H,FractalUp+0.065) 
and (C > AlligatorRed) 
/* and ref(O,1) > O */
and (Cry and Hope) == 0 ; 

Sell= A < AlligatorGreen 
or (ref(C,-2) < FractalUp 
and (ref(C,-1)<ref(C,-2) ) ) ;


/* Below is the dynamic MACD Buy and Sell Signals */

/*
var1=(PeakBars(H,5,1) );
var2=(PeakBars(H,5,2) );
var3=(var2-var1);
var4=(Ma(C,LastValue(var3))-
Ma(C,LastValue(Var2)) );
Var5=EMa(LastValue(var4),LastValue(var3));
var6=var4-var5;
Buy=LLV(var6,7)==ref(var6,-4);
Sell=HHV(var6,7)==ref(var6,-4);
*/

/*
Buy=Cross(Oscp(8,3),Ma(Oscp(8,3),3));
Sell=Cross(ma(Oscp(8,3),3),Oscp(8,3));
*/

/*
Buy=Sar(.02,.2)<C;
Sell=Sar(.02,.2)>C;
*/

/* The following is Guru commentary coding */
/* Guru Commentary */
/*buy = cross( macd(), 0 );
sell = Cross(0,macd() );*/
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;

/* removes redundant buy and sell signals */
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

<<< text/plain; charset="us-ascii"; format=flowed: Unrecognized >>>