1 //+------------------------------------------------------------------+
\r
3 //| Copyright © 2008, MetaQuotes Software Corp. |
\r
4 //| http://www.metaquotes.net |
\r
5 //+------------------------------------------------------------------+
\r
6 #property copyright "Copyright © 2008, MetaQuotes Software Corp."
\r
7 #property link "http://www.metaquotes.net"
\r
8 extern int period=20;
\r
9 extern double level=50;
\r
10 //extern int ema1=34;
\r
11 //extern int ema2=89;
\r
12 #property indicator_separate_window
\r
13 #property indicator_buffers 3
\r
14 #property indicator_color1 Green
\r
15 #property indicator_color2 Red
\r
16 #property indicator_color3 Yellow
\r
19 #property indicator_maximum 3
\r
22 bool downtrend=false;
\r
23 double fast[],medium[],slow[],atr[],std[],rsistd[],rsiatr[];
\r
25 //+------------------------------------------------------------------+
\r
26 //| Custom indicator initialization function |
\r
27 //+------------------------------------------------------------------+
\r
31 IndicatorBuffers(7);
\r
32 //---- drawing settings
\r
34 SetIndexBuffer(0,fast);//bbMacd line
\r
35 SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
\r
36 SetIndexBuffer(1,medium);//Upperband line
\r
37 SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
\r
38 SetIndexDrawBegin(0,period);
\r
39 SetIndexDrawBegin(1,period);
\r
41 SetIndexBuffer(2,slow);//overbough
\r
42 SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
\r
43 SetIndexDrawBegin(2,period);
\r
45 SetIndexBuffer(3,atr);//overbough
\r
46 SetIndexBuffer(4,std);//overbough
\r
47 SetIndexBuffer(5,rsistd);//overbough
\r
48 SetIndexBuffer(6,rsiatr);//overbough
\r
50 IndicatorShortName("CK Speed "+ period);
\r
51 SetIndexLabel(0,"Trend");
\r
52 SetIndexLabel(1,"Correction");
\r
53 SetIndexLabel(2,"Sleep");
\r
58 //+------------------------------------------------------------------+
\r
59 //| Custom indicator deinitialization function |
\r
60 //+------------------------------------------------------------------+
\r
68 //+------------------------------------------------------------------+
\r
69 //| Custom indicator iteration function |
\r
70 //+------------------------------------------------------------------+
\r
75 double prev,current,tmp;
\r
77 int counted_bars=IndicatorCounted();
\r
78 //---- check for possible errors
\r
79 if(counted_bars<0) return(-1);
\r
80 //---- last counted bar will be recounted
\r
81 if(counted_bars>0) counted_bars--;
\r
82 limit=Bars-counted_bars;
\r
85 double filterbuy=60;
\r
86 double filtersell=40;
\r
88 for(int k=limit-1;k>=0;k--){
\r
89 atr[k]=iATR(Symbol(),0,period,k);
\r
90 std[k]=iStdDev(Symbol(),0,period,0,0,PRICE_MEDIAN,k);
\r
92 //for(int t=limit-period;t>=0;t--){
\r
95 for(int i=limit-1; i>=0; i--)
\r
97 rsistd[i]=iRSIOnArray(std,0,period,i);
\r
98 rsiatr[i]=iRSIOnArray(atr,0,period,i);
\r
100 if(rsistd[i]>=level&&rsiatr[i]>=level){
\r
105 }else if(rsistd[i]<level&&rsiatr[i]<level){
\r
117 //+------------------------------------------------------------------+