诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

RSI与KD的经典结合 Kwan.mq4

Kwan 指标将RSI与KD的算法完美结合。

图表:Kwan 指标

源码:

//+------------------------------------------------------------------+
//|                                                          Kwan.mq4|
//|                   Copyright 1999-2008, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Metatrader4 Code by jjk2. Based on MBA Thesis from Simon Fraser University written by C.E. ALDEA."
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

extern int Count_Bars=1000;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double Formula[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
   SetIndexBuffer(1,ExtMapBuffer3);
   SetIndexStyle(2,DRAW_NONE,STYLE_SOLID,3,Yellow);//DRAW_NONE,EMPTY,EMPTY);
   SetIndexBuffer(2,ExtMapBuffer2);
   SetIndexBuffer(3,Formula);
   string short_name="ZigZag BETA    Current value calculated by indicator:";
   IndicatorShortName(short_name);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int pos=0;
   if (Count_Bars>Bars) {pos=Bars;}else{pos=Count_Bars;}
   int temp=pos;
   while(pos>=0)
     {
      double Stoch=iStochastic(NULL,0,9,6,2,MODE_SMA,1,0,pos);
      double RSI=iRSI(NULL,0,9,PRICE_CLOSE,pos);
      double moment=(iMomentum(NULL,0,9,PRICE_CLOSE,pos));

      if (moment!=0)
         ExtMapBuffer2[pos]=Stoch*(RSI)/moment;
      pos--;
     }
     while(temp >=0) 
     {
      ExtMapBuffer1[temp]=EMPTY_VALUE;
      ExtMapBuffer3[temp]=EMPTY_VALUE;
      Formula[temp]=iMAOnArray(ExtMapBuffer2,0,2,0,MODE_SMA,temp);
        if (Formula[temp]>Formula[temp+1])
        {
         ExtMapBuffer1[temp]=Formula[temp];
         if (ExtMapBuffer1[temp+1]==EMPTY_VALUE) ExtMapBuffer1[temp+1]=Formula[temp+1];
         }
         else
         {
         ExtMapBuffer3[temp]=Formula[temp];
         if (ExtMapBuffer3[temp+1]==EMPTY_VALUE) ExtMapBuffer3[temp+1]=Formula[temp+1];
        }
     temp--; 
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » RSI与KD的经典结合 Kwan.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏