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

指标 HVR

HVR指标以价格的特定算法在副图创建另类指标线。

HVR指标图表:HVR指标

HVR指标源码:

//+------------------------------------------------------------------+ 
//|                                                          HVR.mq4 | 
//|       Copyright @2005, Albert,(idea and code into MQL2 - podval) | 
//+------------------------------------------------------------------+ 
#property  copyright " Copyright @2005, Albert,(idea and code into MQL2 - podval)"
#property  link      "http://www.125808047.com/"
#property strict

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 3
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Red
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double  hv6=0,
   hv100=0,
   len=150,
   prevBars=0,
   mean6=0,
   mean100=0;

int    shift=0, i=0;
double
   x6[6],
   x100[100];

double HVRBuffer[];
double ExtMapBuffer[];
int ExtCountedBars=0;
int Barsi=1000;
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
void OnInit(void)
  {
   IndicatorBuffers(2);
   SetIndexBuffer(0,HVRBuffer);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   IndicatorShortName("HVR");
   SetIndexLabel(0,"HVR");
   Comment("www.125808047.com");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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[])
  {
   if (prevBars==Barsi) return(0);
   prevBars=Barsi;
   for(shift=0; shift<=Barsi-1-len; shift++)
     {
      for(i =0; i<=5; i++)
        {
         x6[i]= MathLog(Close[shift+i]/Close[shift+i+1]);
        }
      for(i=0; i<=99; i++)
        {
         x100[i]=MathLog(Close[shift+i]/Close[shift+i+1]);
        }
      mean6=0;
      for(i =0; i<=5; i++)
        {
         mean6=mean6 + x6[i];
        }
      mean6=mean6/6;
      mean100=0;
      for(i=0; i<=99; i++)
        {
         mean100=mean100 + x100[i];
        }
      mean100=mean100/100;
      hv6=0;
      for(i =0; i<=5; i++)
        {
         hv6=hv6 + (x6[i] - mean6)*(x6[i] - mean6);
        }
      hv6=MathSqrt(hv6/5)*7.211102550927978586238442534941;
      hv100=0;
      for(i=0; i<=99; i++)
         hv100=hv100 + (x100[i] - mean100)*(x100[i] - mean100);
      hv100=MathSqrt(hv100/99)*7.211102550927978586238442534941;
      HVRBuffer[shift]= hv6/hv100;
     }
  return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 指标 HVR
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏