4评论

0收藏

HA

avatar zzjianchi | 862 人阅读 | 4 人评论 | 2018-08-19

//+------------------------------------------------------------------+
//|                                                         HA.mq4   |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright ?2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  White
#property  indicator_color2  Red
#property  indicator_width1  1
#property  indicator_width2  1
//---- indicator buffers
double     HighBuffer[];
double     LowBuffer[];
double     OpenBuffer[];
double     CloseBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(4);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexDrawBegin(0,2);
   SetIndexDrawBegin(1,2);
   IndicatorDigits(Digits+2);
//---- 4 indicator buffers mapping
   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexBuffer(2,OpenBuffer);
   SetIndexBuffer(3,CloseBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("HA");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Heiken Ashi                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 引用Heiken Ashi指标的开盘价
   for(int i=0; i<limit; i++)
      OpenBuffer[i]=iCustom(NULL, 0, "Heiken Ashi",2, i);
//---- 引用Heiken Ashi指标的收盘价
   for(i=0; i<limit; i++)
      CloseBuffer[i]=iCustom(NULL, 0, "Heiken Ashi",3, i);
//---- 给柱线上色
   for(int j = i; j >= 0; j--)
     {
       if(OpenBuffer[j] < CloseBuffer[j])
         {
           HighBuffer[j] = High[j];
           LowBuffer[j] = Low[j];
         }
       else
           if(OpenBuffer[j] > CloseBuffer[j])
             {
               LowBuffer[j] = High[j];
               HighBuffer[j] = Low[j];
             }
     }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

""
还没有人打赏,支持一下

评论|共 4 个

听听海

发表于 2020-11-22 16:15:29 | 显示全部楼层

f516421

发表于 2021-7-14 15:02:29 | 显示全部楼层

顶下

岁月痕迹

发表于 2021-7-30 10:00:43 | 显示全部楼层

顶下

woceshiyong8

发表于 2021-8-1 15:02:47 | 显示全部楼层

支持下

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则