最低和最高函数返回什么 - 页 4

 
我将尝试用第一页上composter 给出的代码进行实验。也许有些东西会起作用。
 
nen:
正确,它是计算出来的。找到了细胞编号。从这个单元格(时间序列)中获取条形图的最大或最小值。据认为,在这根柱子上已经发现了最大值。然后将这个值与找到的数字 一起放入指标缓冲区。指标的最大值应与条形图上的最大值相对应。在我的代码中,最大值也是从数组(timeseries)中取出相同的发现数,并与val的 值比较。检查一下我们是否在做正确的事情:我们把数字val放进缓冲区,这个数字。它也应该等于酒吧的最大值。对取自同一地点的数字进行比较是非常正确的。

在我看来,比较...==val,是很危险的,因为它是单元格的数字,可能会从tick到tick变化。特别是在小的时间段,有很多密切匹配的低点高点。然而,我们应该仔细想想,也许我们指的是不同的时刻。
 
nen,你想测试一下这个人字形吗?实际上,这是对每一个有使用之字形经验的人的请求,他们知道自己想从之字形中得到什么。也许你能从这个原型中做出一些有用的东西?
//+------------------------------------------------------------------+
//|                                                      CZigZag.mq4 |
//|                                         Copyright © 2006, Candid |
//|                                                   likh@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Candid"
#property link      "likh@yandex.ru"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue

//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
//extern int ExtBackstep=3;

int    shift;
double res;
int i;
int fBar;
double CurMax,CurMin;
int CurMaxPos,CurMinPos;
int CurMaxBar,CurMinBar;
double hPoint;
double mhPoint;
double EDev;
int MaxDist,MinDist;
bool FirstRun;
bool AfterMax,AfterMin;

//---- indicator buffers
double ZigZag[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
//---- indicators
   SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers mapping
   SetIndexBuffer(0,ZigZag);
   SetIndexEmptyValue(0,0.0);
//---- indicator short name
   IndicatorShortName("CZigZag("+ExtDepth+","+ExtDeviation+")");
   
   FirstRun = true;
//----
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {
//----
   
//----
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
  int counted_bars=IndicatorCounted();
  
  if (FirstRun) {
    hPoint = 0.5*Point;
    mhPoint = -hPoint;
//    EDev = ExtDeviation*Point;
    EDev = (ExtDeviation+0.5)*Point;
    AfterMax = true;
    AfterMin = true;
    fBar = Bars-1;
    CurMax = High[fBar];
    CurMaxBar = 1;
    CurMin = Low[fBar];
    CurMinBar = 1;
    MaxDist = 0;
    MinDist = 0;
    FirstRun = false;
  }
//----
  fBar = Bars-counted_bars-1;
  if (fBar > Bars-2) fBar = Bars-2;
  for(shift=fBar; shift>=0; shift--) {
    if (AfterMax) {
//      res = Low[shift]-CurMin-hPoint;
      res = Low[shift]-CurMin;
//      if (res < 0) {
      if (res < mhPoint) {
        ZigZag[Bars-CurMinBar] = 0;
        CurMin = Low[shift];
        CurMinBar = Bars-shift; 
        ZigZag[Bars-CurMinBar] = CurMin;
      } else {  //  if (res < 0)
//        if (res > 0 ) {
        if (res > hPoint ) {
          MaxDist = Bars-CurMaxBar-shift+1;
          MinDist = Bars-CurMinBar-shift+1;
          if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) {
            AfterMax = false;
            AfterMin = true;
            CurMaxBar = CurMinBar+1;
            CurMaxPos = Bars-CurMaxBar;
            CurMax = High[CurMaxPos];
            for (i=CurMaxPos-1;i>=shift;i--) {
              if (High[i] > CurMax+hPoint) {
                CurMaxBar = Bars-i;
                CurMax = High[i];
              }
            }  //  for (i=CurMaxPos-1;i>=shift;i--)
            ZigZag[Bars-CurMaxBar] = CurMax;
          }  //  if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev)
        }  //  if (res > 0 )
      }  // else if (res < 0)
    }  //  if (AfterMax) 
    if (AfterMin) {
//      res = CurMax-High[shift]-hPoint;
      res = CurMax-High[shift];
//      if (res < 0) {
      if (res < mhPoint) {
        ZigZag[Bars-CurMaxBar] = 0;
        CurMax = High[shift];
        CurMaxBar = Bars-shift; 
        ZigZag[Bars-CurMaxBar] = CurMax;
      } else {  //  if (res < 0)
//        if (res > 0 ) {
        if (res > hPoint ) {
          MaxDist = Bars-CurMaxBar-shift+1;
          MinDist = Bars-CurMinBar-shift+1;
          if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) {
            AfterMin = false;
            AfterMax = true;
            CurMinBar = CurMaxBar+1;
            CurMinPos = Bars-CurMinBar;
            CurMin = Low[CurMinPos];
            for (i=CurMinPos-1;i>=shift;i--) {
              if (Low[i] < CurMin-hPoint) {
                CurMinBar = Bars-i;
                CurMin = Low[i];
              }
            }  //  for (i=CurMinPos-1;i>=shift;i--)
            ZigZag[Bars-CurMinBar] = CurMin;
          }  //  if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev)
        }  //  if (res > 0 )
      }  // else if (res < 0)
    }  //  if (AfterMin) 
  }  //  for(shift=fBar; shift>=0; shift--)
//----
  return(0);
}
//+------------------------------------------------------------------+


请注意,虽然保留了参数名称,但它们的工作方式不同。


 
这里也是,看看我的ZigZag,可能有助于了解它的底部 ....

//+------------------------------------------------------------------+
//|                                                        DT_ZZ.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link      "klot@mail.ru"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Blue
#property indicator_color3 Red
//---- indicator parameters
extern int ExtDepth=12;
//---- indicator buffers
double zzL[];
double zzH[];
double zz[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
 //  IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexArrow(2,159);
   SetIndexArrow(1,159);
//---- indicator buffers mapping
   SetIndexBuffer(0,zz);
   SetIndexBuffer(1,zzH);
   SetIndexBuffer(2,zzL);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
     
//---- indicator short name
   IndicatorShortName("DT_ZZ("+ExtDepth+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos;
   double curlow,curhigh,lasthigh,lastlow;
   double min, max;
   ArrayInitialize(zz,0.0);
   ArrayInitialize(zzL,0.0);
   ArrayInitialize(zzH,0.0);
   
   lasthighpos=Bars; lastlowpos=Bars;
   lastlow=Low[Bars];lasthigh=High[Bars];
  for(shift=Bars-ExtDepth; shift>=0; shift--)
    {
      curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift);
      curlow=Low[curlowpos];
      curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift);
      curhigh=High[curhighpos];
      //------------------------------------------------
      if( curlow>=lastlow ) { lastlow=curlow; }
      else
         { 
            //идем вниз
            if( lasthighpos>curlowpos  ) 
            { 
            zzL[curlowpos]=curlow;
              ///*
              min=100000; pos=lasthighpos;
               for(i=lasthighpos; i>=curlowpos; i--)
                  { 
                    if (zzL[i]==0.0) continue;
                    if (zzL[i]<min) { min=zzL[i]; pos=i; }
                    zz[i]=0.0;
                  } 
               zz[pos]=min;
               //*/
            } 
          lastlowpos=curlowpos;
          lastlow=curlow; 
         }
      //--- high
      if( curhigh<=lasthigh )  { lasthigh=curhigh;}
      else
         {  
            // идем вверх
            if( lastlowpos>curhighpos ) 
            {  
            zzH[curhighpos]=curhigh;
           ///*
               max=-100000; pos=lastlowpos;
               for(i=lastlowpos; i>=curhighpos; i--)
                  { 
                    if (zzH[i]==0.0) continue;
                    if (zzH[i]>max) { max=zzH[i]; pos=i; }
                    zz[i]=0.0;
                  } 
               zz[pos]=max;
           //*/     
            }  
         lasthighpos=curhighpos;
         lasthigh=curhigh;    
         }       
    //----------------------------------------------------------------------
    }
 return(0);
}
//+------------------------------------------------------------------+



 
nen 你想测试一下这个人字形吗?实际上,这是对任何有 "之 "字形经验的人的请求,他们知道自己想要什么 "之 "字形。也许你能从这个原型中做出一些有用的东西?
请记住,虽然参数的名称相同,但它们的工作方式不同。


烛光。我将看一看。第一次安装时,我有如下观察。
有几个连续的柱子有相同的高点。你的 "之 "字形变体在最后一格画出了断点(顶部)。就是说,最接近零的那条。理想情况下,断点应该画在第一个柱子上,也就是离零柱子最远的地方。出现的第一个顶点意义重大。这和mtnemums的情况一样。我可以引用几个来源(来自文献),在需要这样做的地方。
 
klot , 谢谢你。按照你的DT-ZigZag的想法,我现在已经使我的指标与高时间框架数据一起工作。但我只留下了这个想法。我已经做了自己的算法。昨天我在Zigzag中又做了一些修正。现在我已经上传了它,供大家测试。我一定会尝试你的变体。以下是造成整个混乱的指标的描述:http://onix-trade.net/forum/index.php?showtopic=373。 请注意,DT-ZigZag模式使用指标中包含的外部之字形。而这种外部之字形有时会在第一道梁上失败。目前正在测试一个新版本的外部 "之 "字形。
 
klot 谢谢你。按照你的DT-ZigZag的想法,我现在已经使我的指标能够与更高的时间段的数据一起工作。但我只留下了这个想法。我已经做了自己的算法。昨天我在Zigzag中又做了一些修正。现在我已经上传了它,供大家测试。我一定会尝试你的变体。以下是造成整个混乱的指标的描述:http://onix-trade.net/forum/index.php?showtopic=373。 请注意,DT-ZigZag模式使用指标中包含的外部之字形。而这种外部之字形有时会在第一道梁上失败。目前正在测试一个新版本的外部 "之 "字形。

是的,我注意到了:)只是一个想法:)。我现在到处使用我的ZZ(上面帖子中的代码),它与其他TF数据一起工作更稳定。
 
nen:
在第一次安装时,立即产生了以下观察结果。
有几个连续的柱子有相同的高点。你的 "之 "字形选项在最后一个条形上画了一个断点(顶部)。
啊哈,所以我选择了错误的 "选项"。我现在将编辑源帖中的代码。变化的标志是注释出来的错误 "选项 "的行数。
 
Candid,现在好了。
Klot,有趣的选择。

如果你的人字形变体显示出有趣的结果,我可以在我的开发中应用它们吗?
 
如果你的人字形变体显示出有趣的结果,你能在你的设计中应用它们吗?是
的,当然了。如果测试的结果是积极的,我甚至会尝试把它添加到代码库中。
原因: