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

Re: [amibroker] % R divergence



PureBytes Links

Trading Reference Links

Dimitris

I have to hand it to you. This is some nice coding. The Bollinger bands 
are very nice looking.

I used the Williams divergence and added an exploration to it so that I 
could test my universe of stocks. This works very well. The code below is 
what I added to the end of your code.

Thanks for sharing.

Steve


/* The following code is the exploration code */

Filter= (DIVB==-100 or DIVS==-20) ;
numcolumns = 5;
column0 = IIF(DIVB==-100,1,IIF(DIVS==-20,-1,0) );
column0format = 1.2;
column0name = "Divergence";
column1 = C;
column1name = "Close ";
column1format = 1.2;
column2 = ma(v,17);
column2name = "17 Ma Vol ";
column2format = 1.0;
column3 = ma(C,17)/ma(c,50);
column3name = "% 17/50 ";
column3format = 1.2;
column3format = 1.2;
column4= ma(c,17);
column4name="17 C ma";
column4format = 1.2;
column4= ma(c,50);
column4name="50 C ma";
column4format = 1.2;

/* End of Exploration Code. */





At 12:58 PM 5/26/01 +0000, you wrote:
1. Floating Bars
Using the following technique, you may have "floating bars" for
Bollinger bands.
Deleting last pair of /*,*/ you get the limits of Bollinger bands
envelope.
Deleting the first pair of /*,*/ you get the line of Close .
Note : Do not change the numeration of graphs. The result will not be
the same.

MAXGRAPH=6;
/*GRAPH0=C;
GRAPH0BARCOLOR=4;*/
GRAPH1=C;
GRAPH1STYLE=64;
GRAPH1BARCOLOR=1;
GRAPH2=bbandbot( close, 20, 2 );
GRAPH2STYLE=2;
GRAPH2BARCOLOR=0;
GRAPH3=bbandtop( close, 20, 2 );
GRAPH3STYLE=2;
GRAPH3BARCOLOR=3;
/*GRAPH4=bbandtop( close, 20, 2 );
GRAPH5=bbandbot( close, 20, 2 );
GRAPH4STYLE=1;
GRAPH5STYLE=1;
GRAPH4BARCOLOR=3;
GRAPH5BARCOLOR=3;*/

2. Williams Divergence
Many times in overbought conditions, %R index begins to fall, leaving
its (near zero) tops whereas Close price is getting new highs. This
bearish divergence is frequently a forerunner of a decline.
Respectively, at the end of a bearish period, %R reacts one or more
days before price reaches its lowest.
Using the above floating technique, you may have on the same graph %
R, its 9 days EMA, a red 20 units bar when a bearish divergence
occurred yesterday and a green 20 units bar when a bullish divergence
took place.
On the title of the graph you can read %R last value and if any type
of divergence occurred.
So, you have a lot of info at a glance.

/* %R, ema 9 and divergences */
MAXGRAPH=5;
R=-100*((HHV(HIGH,14)-CLOSE))/(HHV(HIGH,14)-LLV(LOW,14));
DIVR=(R-REF(R,-1))*(C-REF(C,-1));
DIVB=IIF((DIVR<0) AND (R-ref(R,-1))>0 and (REF(R,-1)<-90),-100,0);
DIVB1=IIF((DIVR<0) AND (R-ref(R,-1))>0 and (REF(R,-1)<-90),-80,0);
DIVS=IIF((DIVR<0) AND (R-ref(R,-1))<0 and (REF(R,-1)>-10),-20,0);
GRAPH2=DIVB1;
GRAPH2STYLE=2;
GRAPH2BARCOLOR=0;
graph0 = R;
GRAPH0BARCOLOR=12;
GRAPH1=EMA(R,9);
graph1barcolor=3;
GRAPH2=DIVB1;
GRAPH2STYLE=2;
GRAPH2BARCOLOR=0;
GRAPH4=DIVB;
GRAPH4STYLE=2;
GRAPH3=DIVS;
GRAPH3STYLE=2;
graph4barcolor=8;
graph3barcolor=4;
TITLE=NAME()+" - %R="+writeval(LASTVALUE(R))+
writeif(DIVB==-100," POSITIVE DIVERGENCE"," ")+
WRITEIF(DIVS==-20," NEGATIVE DIVERGENCE","");