木结构 隼牟结构:KDJ

来源:百度文库 编辑:中财网 时间:2024/04/28 20:51:11

//+------------------------------------------------------------------+
//|                                                      KDJ共振.mq4 |
//|                                       Copyright ? 2009, wyd95968 |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2009, wyd95968"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_color2 Blue
#property indicator_width2 1

 

extern int kperiod_5 = 5;
extern int dperiod_5 = 1;
extern int slowing_5 = 3;
extern int kperiod_30 = 30;
extern int dperiod_30 = 1;
extern int slowing_30 = 18;


/*
extern int
kperiod, dperiod, slowing*/

int MAMethod    = 0;
int PriceField  = 0;
int tt=10;

double s[];
double b[];
double b1[];
double b2[];
double b3[];
double b4[];
double b5[];

int init()  {
   IndicatorBuffers(7);
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
   SetIndexArrow(1,233);
   SetIndexArrow(0,234);
   SetIndexBuffer(0,s);
   SetIndexBuffer(1,b);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexBuffer(2,b1);
   SetIndexBuffer(3,b2);
   SetIndexBuffer(4,b3);
   SetIndexBuffer(5,b4);
   SetIndexBuffer(6,b5);
//   Comment("p1="+p1+"\np2="+p2+"\np3="+p3);
   return(0);
}

void deinit()
{
   Comment("");
}

int start() {
   int counted_bars=IndicatorCounted();
   int i,limit;
  
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-1;
   if(counted_bars>=1) limit=Bars-counted_bars-1;
   if (limit<0) limit=0;

   for (i=0;i<=limit;i++)                    
   {
       b1[i]=iStochastic(NULL,0,kperiod_5,dperiod_5, slowing_5,MAMethod,PriceField,0,i);
       b2[i]=iStochastic(NULL,0,kperiod_5,dperiod_5, slowing_5,MAMethod,PriceField,0,i+1);
       b3[i]=iStochastic(NULL,0,kperiod_5,dperiod_5, slowing_5,MAMethod,PriceField,0,i+2);
      
       b4[i]=iStochastic(NULL,0,30,1,18,MAMethod,PriceField,0,i);
       b5[i]=iStochastic(NULL,0,30,1,18,MAMethod,PriceField,0,i+1);     
       if((b1[i]>b2[i])&&(b2[i]b5[i])&&(b4[i]<40))b[i]=Low[i]-tt*Point;//上
       if((b1[i]b3[i])&&(b3[i]>60)&&(b4[i]60))s[i]=High[i]+tt*Point; 

      

    
     
   }
   return(0);
}

  /*     
       if((b1[i]>b2[i])&&(b2[i]       if((b1[i]b3[i])&&(b3[i]>60)&&(b4[i]>50))s[i]=High[i]+tt*Point; 
             
              if((b1[i]>b2[i])&&(b2[i]       if((b1[i]b3[i])&&(b3[i]>60))s[i]=High[i]+tt*Point;
              double h = High[Highest(0,0,MODE_HIGH,5,i+5)];
       double l = Low[Lowest(0,0,MODE_LOW,5,i+5)];
       double x = h - Open[i+5];
       double y = Close[i] - l;
       b4[i] = ((x+y)*100) / ((h-l)*2);
       */
       //Print(DoubleToStr(b4[i]));
      
      

       //b4[i]=iStochastic(NULL,0,kperiod_30,dperiod_30, slowing_30,MAMethod,PriceField,0,i);