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

市场促进指数与成交量的完美结合 BW_MFI+Volumes.mq4

BW_MFI+Volumes指标将市场促进指数与成交量的完美结合在副图。

图表:BW_MFI+Volumes指标

源码:

//+------------------------------------------------------------------+
//|                                               BW_MFI+Volumes.mq4 |
//|                       Copyright @2005, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright @2004, MetaQuotes Software Corp."
#property link      "http://www.125808047.com/"

#property  indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 5
#property indicator_color1 Black
#property indicator_color2 Green 
#property indicator_color3 Blue 
#property indicator_color4 Gold 
#property indicator_color5 Red  

double dMFIBuffer[];
double dMFIUpVUpBuffer[]; 
double dMFIDownVDownBuffer[];
double dMFIUpVDownBuffer[];
double dMFIDownVUpBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
{
   SetIndexBuffer(0,dMFIBuffer);       
   SetIndexBuffer(1,dMFIUpVUpBuffer);
   SetIndexBuffer(2,dMFIDownVDownBuffer);
   SetIndexBuffer(3,dMFIUpVDownBuffer);
   SetIndexBuffer(4,dMFIDownVUpBuffer);

   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexStyle(4,DRAW_HISTOGRAM);   

   IndicatorShortName("BW MFI + Volumes");
   SetIndexLabel(0,"BW MFI");      
   SetIndexLabel(1,"");
   SetIndexLabel(2,"");
   SetIndexLabel(3,"");
   SetIndexLabel(4,"");

   SetIndexEmptyValue(1, 0.0);
   SetIndexEmptyValue(2, 0.0);       
   SetIndexEmptyValue(3, 0.0);
   SetIndexEmptyValue(4, 0.0);      
   
   IndicatorDigits(0);   
   Comment("www.125808047.com"); 
  }
//+------------------------------------------------------------------+
//| BW Market Facilitation Index                                     |
//+------------------------------------------------------------------+
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,nLimit,nCountedBars;

   nCountedBars=IndicatorCounted();

   if(nCountedBars>0) nCountedBars--;
   nLimit=Bars-nCountedBars;

   for(i=0; i<nLimit; i++)
     if(i==0 && Volume[i]<Period()*1.5)
        dMFIBuffer[i]=0.0;
     else   
        dMFIBuffer[i]=(High[i]-Low[i])/(Volume[i]*Point);

   for(i=nLimit-1; i>=0; i--)
    {
     if((i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]>dMFIBuffer[i+2]&&Volume[i]>Volume[i+1])||
        (i!=nLimit-1&&dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]>Volume[i+2])||
        (i<nLimit-2&&dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]==Volume[i+2]&&Volume[i]>Volume[i+3])||        
        (i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]>dMFIBuffer[i+2]&&Volume[i]==Volume[i+1]&&Volume[i]>Volume[i+2])||
        (dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]>Volume[i+1])) 
       {
        dMFIUpVUpBuffer[i]=Volume[i];
        dMFIDownVDownBuffer[i]=0.0;
        dMFIUpVDownBuffer[i]=0.0;
        dMFIDownVUpBuffer[i]=0.0;
        continue;
       }
     if((i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]<dMFIBuffer[i+2]&&Volume[i]<Volume[i+1])||
        (i!=nLimit-1&&dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]<Volume[i+2])||
        (i<nLimit-2&&dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]==Volume[i+2]&&Volume[i]<Volume[i+3])||        
        (i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]<dMFIBuffer[i+2]&&Volume[i]==Volume[i+1]&&Volume[i]<Volume[i+2])||        
        (dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]<Volume[i+1])) 
       {
        dMFIUpVUpBuffer[i]=0.0;
        dMFIDownVDownBuffer[i]=Volume[i];
        dMFIUpVDownBuffer[i]=0.0;
        dMFIDownVUpBuffer[i]=0.0;
        continue;         
       }
     if((i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]>dMFIBuffer[i+2]&&Volume[i]<Volume[i+1])||
        (i!=nLimit-1&&dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]<Volume[i+2])||
        (i<nLimit-2&&dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]==Volume[i+2]&&Volume[i]<Volume[i+3])||        
        (i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]>dMFIBuffer[i+2]&&Volume[i]==Volume[i+1]&&Volume[i]<Volume[i+2])||        
        (dMFIBuffer[i]>dMFIBuffer[i+1]&&Volume[i]<Volume[i+1])) 
       {
        dMFIUpVUpBuffer[i]=0.0;
        dMFIDownVDownBuffer[i]=0.0;
        dMFIUpVDownBuffer[i]=Volume[i];
        dMFIDownVUpBuffer[i]=0.0;
        continue;         
       }
     if((i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]<dMFIBuffer[i+2]&&Volume[i]>Volume[i+1])||
        (i!=nLimit-1&&dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]>Volume[i+2])||
        (i<nLimit-2&&dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]==Volume[i+1]&&Volume[i]==Volume[i+2]&&Volume[i]>Volume[i+3])||        
        (i!=nLimit-1&&bCompareDouble(dMFIBuffer[i],dMFIBuffer[i+1])&&dMFIBuffer[i]<dMFIBuffer[i+2]&&Volume[i]==Volume[i+1]&&Volume[i]>Volume[i+2])||        
        (dMFIBuffer[i]<dMFIBuffer[i+1]&&Volume[i]>Volume[i+1])) 
       {
        dMFIUpVUpBuffer[i]=0.0;
        dMFIDownVDownBuffer[i]=0.0;
        dMFIUpVDownBuffer[i]=0.0;
        dMFIDownVUpBuffer[i]=Volume[i];
        continue;         
       }        
    }                     
   return(rates_total);
  }
//+------------------------------------------------------------------+
 bool bCompareDouble (double dNumber1, double dNumber2)
    {
     bool bCompare=NormalizeDouble(dNumber1 - dNumber2,8) == 0;
     return(bCompare);
    }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 市场促进指数与成交量的完美结合 BW_MFI+Volumes.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏