siho166 发表于 2022-7-14 09:29:53

神龙通道指标不能输出第二条线,哪位大佬能帮忙改一下

//+------------------------------------------------------------------+
//|                                                    MHDMT_XMA.mq4 |
//|                                    Copyright 2022, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Yellow


extern int U = 9;
extern int U1 = 9;
extern int mode = 2;
double ExtMapB1[];
double ExtMapB2[];
int iMin = 0;
int iMax = 0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
{

//IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0, ExtMapB1);
   SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(1, ExtMapB2);
   //IndicatorShortName("XMA(" + N + ")");
   iMin = U;
   iMax = U + U1;
   SetIndexDrawBegin(0, iMin);
   SetIndexDrawBegin(1, iMin);
   return (0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
{

   int counted_bars = IndicatorCounted();
   if(Bars <= iMax) return (0);
   if(counted_bars > 0) counted_bars--;

   int limit =Bars-counted_bars -1;
   int m,n;
   m=(iMin-1)/2;
   n=(iMax-1)/2;

   for(int i = 0; i < limit; i++)
   {   
      double Con1=0.0;

      if(i >= m)
      {
         for(int x = i-m; x <= i+m; x++)Con1 += Close;//(Close);   //循环20次,第1次累加(20.0 * (High),第2次累加(19.0 * (High),直到累加到()1*High)            
         ExtMapB1 = (Con1/iMin);//第二个循环一次后,把20次累加的值/210.0赋给MidUpBuf数组

      }
      else
      {
          for(x = 0; x <=i+m; x++)Con1 += Close;
          ExtMapB1 = (Con1+Con1 * (iMin-i*2-1)/(iMin+i*2+1))/iMin;

      }
   }
   for(i=0; i < limit; i++)
   {   
      double Con2=0.0;
      if(i >= m)
      {
         for(x =i+m ; x > i-m; x++)Con2 += ExtMapB1;
         ExtMapB2 = (Con2/iMin);

      }
      else
      {
          for(x = 0; x <=i+m; x++)Con2 += ExtMapB1;
          ExtMapB2=(Con2+Con2 * (iMin-i*2-1)/(iMin+i*2+1))/iMin;

      }   

   }
   return (0);
}

WA263222 发表于 2022-7-14 09:32:52

这里有很多神龙现成的,自己下个研究或者不用直接用,没人改

张京斌 发表于 2022-7-31 15:27:39

{:1_186:}

随风飘云 发表于 2022-8-11 14:51:51

{:1_179:}

艾拓思何 发表于 2022-8-25 21:35:53

支持下

紫枫晨 发表于 2022-8-28 13:20:09

支持下

一行代码 发表于 2022-8-31 22:41:43

顶下

学百家 发表于 2022-9-3 19:28:06

顶下

爱迪生砝码 发表于 2022-9-7 18:31:39

顶下

沧海笑 发表于 2022-9-15 17:04:37

支持下
页: [1] 2 3
查看完整版本: 神龙通道指标不能输出第二条线,哪位大佬能帮忙改一下