下载MetaTrader 5
要添加评论,请登录注册
您已经制作MetaTrader 截屏吗?与朋友分享它!
Fa Cao
1143
Fa Cao 2013.12.04 09:06 

代码如下:

请问最后两行代码有何意义?if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_width1 1
#property indicator_color2 Yellow
#property indicator_width2 1

double Bottoms[];
double Toppers[];

int init()
{

   IndicatorBuffers(2);

   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,Bottoms);
   SetIndexEmptyValue(0,0.0);

   SetIndexStyle(1,DRAW_SECTION);
   SetIndexBuffer(1,Toppers);
   SetIndexEmptyValue(1,0.0);

  IndicatorShortName("zz show top & bottom");
  return(0);
}

int deinit()
{
  return(0);
}

int start()
{
  int counted_bars=IndicatorCounted();
  int limit=0;
  limit = Bars-counted_bars;
  
  for(int shift=limit-1;shift>=0;shift--)
  {
    int ExtDepth=12; int ExtDeviation=5; int ExtBackstep=3;
    int ZigzagBuffer=0; int HighMapBuffer=1; int LowMapBuffer=2;
    
    Bottoms[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        LowMapBuffer, shift
    );
    
    Toppers[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        HighMapBuffer, shift
    );
    
    if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift];
    if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];
  }
  
  return(0);
}
Fa Cao
1143
Fa Cao 2013.12.04 09:09  

以上代码做为指标使用没有问题,可以正常显示,但是如果将以下代码写入EA中,有问题: print 显示出来的全部是0,请问为什么?在EA中用iCustom()调用返回数值,有什么特别之处吗?

for(int shift=99;shift>=0;shift--)
  {
    int ExtDepth=12; int ExtDeviation=5; int ExtBackstep=3;
    int ZigzagBuffer=0; int HighMapBuffer=1; int LowMapBuffer=2;
    
    Bottoms[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        LowMapBuffer, shift
    );
    
    Toppers[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        HighMapBuffer, shift
    );
    if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift];
    if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];
 }
 
 shift=0;
 while(shift<100)
 {
 Print("Bottoms,Toppers:",Bottoms[shift]," , ",Toppers[shift]);
 shift++;
 }
okwh
1629
okwh 2013.12.07 04:43  
ZigZag 有些特殊, 它是 只有部分点有值的稀疏数组,大部分内容是空的。只有那些折点处有值。 查论坛,好象有有关资料 https://www.mql4.com/cn/search#!keyword=Zigzag
Fa Cao
1143
Fa Cao 2013.12.09 01:54  
知道有这么多零,所以才遍历100个点,100个点,不可能都是空的
enbo lu
版主
1894
enbo lu 2013.12.17 13:33  

呵呵,

这个很好猜到原因,请问

你是如何声明Bottoms和Toppers的?

你再想一想,呵呵。

/
要添加评论,请登录注册