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

另类价格高低点通道指标 HiLoBandsBug.mq4

HiLoBandsBug指标根据价格高低点创建另类布林带通道。

图表:HiLoBandsBug指标

源码:

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

#property indicator_chart_window
#property indicator_buffers 5

#property indicator_color1 White
#property indicator_color2 Aqua
#property indicator_color3 Aqua
#property indicator_color4 Orange
#property indicator_color5 Orange

extern int CountBars=4000;
extern int bandlen=9;
int counter=0;

double highline[],lowline[];
double highline2[],lowline2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,highline);
   SetIndexBuffer(1,lowline); 
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(2,highline2);
   SetIndexBuffer(3,lowline2); 
   Comment("www.125808047.com");   
  }
//+------------------------------------------------------------------+
//| SilverTrend_PowerLaw                                             |
//+------------------------------------------------------------------+
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[])
  {
   CountBars = MathMin(Bars-bandlen-1,CountBars); 

   int shift,counted_bars=IndicatorCounted();
   int limit; 

   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
  
   limit = CountBars; 
   if (limit < 1) limit = 1; 
   ArrayResize(highline,limit);
   ArrayResize(lowline,limit); 
   
   for (shift = limit; shift>=0; shift--) 
   { 
      int offset = 1; 
      double H1,L1;
      double H2,L2;
      
      H1 = High[iHighest(Symbol(),0,MODE_HIGH,bandlen,shift+offset)];
      L1 = Low[iLowest(Symbol(),0,MODE_LOW,bandlen,shift+offset)];
      highline[shift] = H1;
      lowline[shift] = L1;
      H2 = High[shift+offset];
      L2 = Low[shift+offset];
      for (int k=1; k < bandlen; k++) {
         double HV = High[shift+k+offset];
         if (HV > H2) H2 = HV; 
         double LV = Low[shift+k+offset];
         if (LV < L2) L2 = LV;
      }
      highline2[shift] = H2;
      lowline2[shift] = L2;
    }
   return(rates_total);
}
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 另类价格高低点通道指标 HiLoBandsBug.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏