zzjianchi 发表于 2018-8-19 18:41:39

HA

//+------------------------------------------------------------------+
//|                                                         HA.mq4   |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#propertycopyright "Copyright ?2004, MetaQuotes Software Corp."
#propertylink      "http://www.metaquotes.net/"
//---- indicator settings
#propertyindicator_chart_window
#propertyindicator_buffers 2
#propertyindicator_color1White
#propertyindicator_color2Red
#propertyindicator_width11
#propertyindicator_width21
//---- 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=iCustom(NULL, 0, "Heiken Ashi",2, i);
//---- 引用Heiken Ashi指标的收盘价
   for(i=0; i<limit; i++)
      CloseBuffer=iCustom(NULL, 0, "Heiken Ashi",3, i);
//---- 给柱线上色
   for(int j = i; j >= 0; j--)
   {
       if(OpenBuffer < CloseBuffer)
         {
         HighBuffer = High;
         LowBuffer = Low;
         }
       else
         if(OpenBuffer > CloseBuffer)
             {
               LowBuffer = High;
               HighBuffer = Low;
             }
   }
//---- done
   return(0);
}
//+------------------------------------------------------------------+

听听海 发表于 2020-11-22 16:15:29

{:1_186:}

f516421 发表于 2021-7-14 15:02:29

顶下

岁月痕迹 发表于 2021-7-30 10:00:43

顶下

woceshiyong8 发表于 2021-8-1 15:02:47

支持下
页: [1]
查看完整版本: HA