[MT4指标]Expected Volumes指标
附图指标,
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//|                                             Expected Volumes.mq4 |
//|                                     Copyright ? 2007, Amir Aliev |
//|                                       http://finmat.blogspot.com |
//+------------------------------------------------------------------+
#property  copyright \"Copyright ? 2007, Amir Aliev\"
#property  link      \"http://finmat.blogspot.com\"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- input parameters
extern int hist_steps=100;      // Number of observations
extern int span=1;              // Days to step back each time 
//---- buffers
double ExtMapBuffer1;
int sum;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicators
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   short_name=\"Expected volumes(\" + hist_steps + \")\";
   IndicatorShortName(short_name);
   SetIndexLabel(0, short_name);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int rest=Bars - counted_bars;
   int j, k, u;
//----   
   while(rest>=0)
     {
      if(Bars - rest < span * 23 * hist_steps)
        {
         ExtMapBuffer1[rest]=0;
         rest--;
         continue;
        }
      sum=0;
      j=0;
      k=0;
      u=0;
      while(j < hist_steps && k < Bars)
        {
         if(TimeHour(Time[rest+k])==TimeHour(Time[rest]))
           {
            u++;
            if(u==span)
              {
               u=0;
               j++;
               sum+=Volume[rest + k];
              }
            k+=23;
           }
         k++;
        }
      ExtMapBuffer1[rest]=sum/hist_steps;
      rest--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
发表于:2017-08-11 08:05只看该作者
2楼 
谢谢分享!!
韬客社区www.talkfx.co













