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

自定义指标 FastFractals.mq4

FastFractals 指标侧重于绘制蜡烛的影线。

图表:FastFractals 指标

源码:

//+------------------------------------------------------------------+
//|                                                 FastFractals.mq4 |
//+------------------------------------------------------------------+
#property copyright " "
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int Shift_Bars=0;
int Bars_Count= 0;

double v1[];
double v2[];
  
int OnInit()
{ 
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,v1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,v2);
   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[])
  {
  bool hiFractal;
  bool loFractal;
  int curFractal;
  double price;
  int i;
  int shift;
  int counted_bars = IndicatorCounted();
  if (counted_bars > 0) counted_bars--;
  if (Bars_Count > 0 && Bars_Count <= Bars)
  {
    i = Bars_Count - counted_bars;
  }else{
    i = Bars - counted_bars;
  }
  
  while(i>=0)
   {
    shift = i + Shift_Bars;
   
    price = High[shift+3];
    hiFractal = price > High[shift+2] &&
              price > High[shift+1];

    price = Low[shift+3];
    loFractal = price < Low[shift+2] &&
              price < Low[shift+1];
              
    if (hiFractal && !loFractal) {
      curFractal = -1;
    }else if(loFractal && !hiFractal) {
      curFractal = 1;
    }else if(loFractal && hiFractal){
      curFractal = 0;
    }
    
    if (curFractal == 1) {
      v2[i] = High[i];
      v1[i] = Low[i];
    }else if(curFractal == -1) {
      v1[i] = High[i];
      v2[i] = Low[i];    
    }else{
      v1[i] = Low[i];
      v2[i] = Low[i];     
    }
    i--;
   }   
  return(rates_total);
 }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 自定义指标 FastFractals.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏