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

动量指标的标准偏差指标 Change_of_Volatility.mq4

Change_of_Volatility指标计算动量指标Momentum的标准偏差。

图表:Change_of_Volatility指标

源码:

//+------------------------------------------------------------------+
//|                                         Change_of_Volatility.mq4 |
//|                       Copyright @2007, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright @2007, MetaQuotes Software Corp."
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int       short_1=6;
extern int       long_1=100;

double HVBuffer[];
double Moment[];
double long_1Log[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,HVBuffer);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(1,Moment);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
  }
  
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  i,limit,limit2, counted_bars=IndicatorCounted();

   if (counted_bars==0)
      {
      limit=Bars-2;
      limit2=Bars-long_1-1;
      }
   if (counted_bars>0)
      {
      limit=Bars-counted_bars;
      limit2=limit;
      }
      
   for (i=limit;i>=0;i--) Moment[i]=iMomentum(NULL,0,1,PRICE_CLOSE,i)/100;         
   for (i=limit2;i>=0;i--) HVBuffer[i]=iStdDevOnArray(Moment,0,short_1,0,MODE_SMA,i)/iStdDevOnArray(Moment,0,long_1,0,MODE_SMA,i);
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 动量指标的标准偏差指标 Change_of_Volatility.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏