分享

关于MT4里BIAS的问题

 灰晖 2010-12-10
MT4里一般的乖离率公式如下:
/+------------------------------------------------------------------+
//|                                              BIAS-乖离率指标.mq4 |
//|                                                 FXLong技术部编写 |
//|                                           http://www./ |
//+------------------------------------------------------------------+
#property copyright  "一条龙外汇网:www."
#property  link      "http://www./"

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Orange
#property  indicator_color2  Turquoise
#property  indicator_color3  CornflowerBlue

//---- Level Lines
#property indicator_level1 0

//---- indicator parameters
extern int MA1=6;
extern int MA2=12;
extern int MA3=24;
//---- indicator buffers
double     MA1Buffer[];
double     MA2Buffer[];
double     MA3Buffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   
   SetIndexDrawBegin(0,MA1);
   SetIndexDrawBegin(1,MA2);
   SetIndexDrawBegin(2,MA3);   
   
   IndicatorDigits(Digits+1);
   
//---- indicator buffers mapping
   SetIndexBuffer(0,MA1Buffer);
   SetIndexBuffer(1,MA2Buffer);
   SetIndexBuffer(2,MA3Buffer);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("BIAS("+MA1+","+MA2+","+MA3+")");
   SetIndexLabel(0,"BIAS");
   SetIndexLabel(1,"BIAS");
   SetIndexLabel(2,"BIAS");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

//---- bias counted in the 1-st buffer
   for(int i=0; i<limit; i++)
   {   
      MA1Buffer= 100*(Close- iMA(NULL,0,MA1,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,MA1,0,MODE_SMA,PRICE_CLOSE,i);
      MA2Buffer= 100*(Close- iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,i);
      MA3Buffer= 100*(Close- iMA(NULL,0,MA3,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,MA3,0,MODE_SMA,PRICE_CLOSE,i);
   }

//---- done
   return(0);
  }
//+------------------------------------------------------------------+

都是以Close的ma计算的 我想变为以(H+L)/2的smoothed计算的均线乖离

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多