自定义指标 Fisher_mbk.mq4-MT4指标-峰汇在线
诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

自定义指标 Fisher_mbk.mq4

Fisher_mbk 指标根据价格的特定算法创建。

图表:Fisher_mbk 指标

源码:

//+------------------------------------------------------------------+
//|                                                    Fisher_mbk.mq4|
//|                  Copyright @2000-2007, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property  copyright "Copyright ?2005, Matt Kennel"
#property link      "http://www.125808047.com/"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Lime
#property  indicator_color3  Red
#property  indicator_level1  0

extern int period=10;
extern double HMALenHiLo=5.0;
extern double HMALenZ=3.0;

double         ExtBuffer0[];
double         ExtBuffer1[];
double         ExtBuffer2[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+1);

   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);

   IndicatorShortName("Fisher_mbk");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
   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    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
   double Value=0;
   double price;
   double MinL=0;
   double MaxH=0;

   if(counted_bars>0) counted_bars--;
   limit=Bars-period-1;

   int N=Bars-period;
   double HiLo[];
   double HMAofHiLo[];
   double Ztransformed[];
   ArrayResize(HiLo,N);
   ArrayResize(HMAofHiLo,N);
   ArrayResize(Ztransformed,N);

   for(int i=N-1; i>=0; i--)
     {
      MaxH=High[Highest(NULL,0,MODE_HIGH,period,i)];
      MinL=Low[Lowest(NULL,0,MODE_LOW,period,i)];
      price=Close[i]; // (High[i]+Low[i])/2;
      HiLo[i]=2.0* (price-MinL)/(MaxH-MinL) - 1.0;
     }
   HMAOnArray(N,HMALenHiLo,HiLo,HMAofHiLo);
     for(i=N-1; i>=0; i--) 
     {
      Value=MathMin(MathMax(HMAofHiLo[i],-0.999),0.999);
      Ztransformed[i]= MathLog((1+Value)/(1-Value));
     }
   HMAOnArray(N,HMALenZ,Ztransformed,ExtBuffer0);

   bool up=true;
   for(i=limit-2; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if (((current<0)&&(prev>0))||(current<0)) up= false;
      if (((current>0)&&(prev<0))||(current>0)) up= true;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  void HMAOnArray(int N, double HMALen, double &input_1[], double& output[]) 
  {
   double ma1, ma2, mix, mixprime;
   ma1=input_1[N-1];
   ma2=ma1;
   mix=3.0/(2.0 + HMALen);
   mixprime=1.0-mix;

     for(int i=N-2; i>=0; i--) 
     {
      ma1=mixprime*ma1 + mix*input_1[i];
      ma2=mixprime*ma2 + mix*ma1;
      output[i]=1.5*ma1-ma2;
     }
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 自定义指标 Fisher_mbk.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏