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

相对活力指数RVI类指标 CyAn_6_RVI.mq4

CyAn_6_RVI指标创建另类RVI。

图表:CyAn_6_RVI指标

源码:

//+------------------------------------------------------------------+
//|                                                  CyAn_6_RVI.mq4  |
//|                          Copyright @2006, Luis Guilherme Damiani |
//+------------------------------------------------------------------+
#property copyright "Copyright @2006, Luis Guilherme Damiani"
#property link      "http://www.125808047.com/"

#property indicator_buffers 2
#property indicator_separate_window
#property indicator_color1 Yellow
#property indicator_color2 Green

extern double length=10;

double ind1[];
double ind2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ind1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ind2);

   SetLevelValue(0,0.0);
   ArrayInitialize(ind1,0.0);
   ArrayInitialize(ind2,0.0);
   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    counted_bars=IndicatorCounted();
      double num=0,denom=0;  

      if(counted_bars<0) return(-1);
      int limit=Bars-counted_bars;

      for (int i = limit; i>=0;i--)
      {
         num=0;denom=0;
         for(int j=0;j<length;j++)
         {
            num=num+v1(i,j);
            denom=denom+v2(i,j);
         }
         if(denom!=0)ind1[i]=num/denom;
	      ind2[i]=ind1[i+1];	          
       }
   return(rates_total);
  }
  
 double v1(int x,int y)
 {
    double pr;
    pr=((Close[x+y]-Open[x+y])+2*(Close[x+y+1]-Open[x+y+1])+2*(Close[x+y+2]-Open[x+y+2])+(Close[x+y+3]-Open[x+y+3]))/6;
  return(pr);          
 }
 
 double v2(int x,int y)
 {
    double pr;
    pr=((High[x+y]-Low[x+y])+2*(High[x+y+1]-Low[x+y+1])+2*(High[x+y+2]-Low[x+y+2])+(High[x+y+3]-Low[x+y+3]))/6;
  return(pr);          
 }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 相对活力指数RVI类指标 CyAn_6_RVI.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏