找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
首页论坛EAHub 外汇论坛
查看: 15|回复: 0

ZigZag高低点

[复制链接]

4万

主题

54

回帖

4万

积分

管理员

积分
45954
发表于 2026-8-21 23:25:00 | 显示全部楼层 |阅读模式
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int       barn = 300;
extern int       Length=6;
double ExtMapBuffer1[];
//double ExtMapBuffer2[];

int init()
  {

   SetIndexEmptyValue(0, 0.0);
  //SetIndexDrawBegin(0, barn);
   SetIndexStyle(0, DRAW_SECTION);
   SetIndexBuffer(0, ExtMapBuffer1);
SetIndexLabel(0, "HiLoZZ(" + Length + ")");
return(0);
  }
int deinit()
  {
   return(0);
  }

int start()
  {
   int counted_bars = IndicatorCounted();
   int shift, Swing, Swing_n, uzl, i, zu, zd, mv;
   double LL, HH, BH, BL, NH, NL;
   double Uzel[10000][3];
   string text;
Swing_n = 0;
   Swing = 0;
   uzl = 0;
   BH = High[barn];
   BL = Low[barn];
   zu = barn;
   zd = barn;
//----
   for(shift = barn; shift >= 0; shift--)
     {
       LL = 10000000;
       HH = -100000000;
       //----
       for(i = shift + Length; i >= shift + 1; i--)
         {
           if(Low < LL)
             {
               LL=Low;
             }
           if(High > HH)
             {
               HH = High;
             }
         }
       //----
       if(Low[shift] < LL && High[shift] > HH)
         {
           Swing = 2;
           //----
           if(Swing_n == 1)
             {
               zu = shift + 1;
             }
           //----
           if(Swing_n == -1)
             {
               zd = shift + 1;
             }
         }
       else
         {
           if(Low[shift] < LL)
             {
               Swing = -1;
             }
           if(High[shift] > HH)
             {
               Swing = 1;
             }
         }

       //----
       if(Swing != Swing_n && Swing_n != 0)
         {
           if(Swing == 2)
             {
               Swing = -Swing_n;
               BH = High[shift];
               BL = Low[shift];
             }
           uzl=uzl+1;
           //----
           if(Swing == 1)
             {
               Uzel[uzl][1] = zd;
               Uzel[uzl][2] = BL;
             }
           //----
           if(Swing == -1)
             {
               Uzel[uzl][1] = zu;
               Uzel[uzl][2] = BH;
             }
           BH = High[shift];
           BL = Low[shift];
         }
       if(Swing == 1)
         {
           if(High[shift] >= BH)
             {
               BH = High[shift];
               zu = shift;
             }
         }
       if(Swing == -1)
         {
           if(Low[shift] <= BL)
             {
               BL = Low[shift];
               zd = shift;
             }
         }
       Swing_n = Swing;
     }
   for(i = 1; i <= uzl; i++)
     {
       //text=DoubleToStr(Uzel[1],0);
       //text=;
       mv = StrToInteger(DoubleToStr(Uzel[1], 0));
       ExtMapBuffer1[mv] = Uzel[2];
     }
   return(0);
  }复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|EAHub外汇论坛

GMT+8, 2026-10-11 14:59 , Processed in 0.106015 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表