거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

Ideal ZigZag - MetaTrader 4용 지표

조회수:
46517
평가:
(19)
게시됨:
2012.03.28 06:40
업데이트됨:
2016.11.22 07:32
XLab_ZZ.mq4 (4.6 KB) 조회
XLab_ZZP.mq4 (4.62 KB) 조회
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동



Advantages :

  1. The most expensive function is iBarShift which totally replaces all cycles in the code needed for peaks retrieval.
  2. All information needed to build ZZ for every bar is accessible not only in every moment but also for every extern code.
  3. No suspended peaks
  4. Efficient method to find peaks is available
  5. Very fast
  6. Works correct at history insertions and when switching TFs.
  7. Perfect for use in EA.


Disadvantages :

1. Memory requirements. This indicator uses 5 buffers instead of 2 (or even 1) in other similar implementations. But (imho) this is good price for advantages #6 and #7. None of fast ZigZags I have seen can process history insertions without full rebuild. Mine does it. Moreover it does it in efficient way

2. Additional lines are available. This is required to make the data visible for any extern code. These lines should never be visible.


Principle:

The ZZ is drawn by the channeling principle.

The channel width can be defined in Points (XLab_ZZ) or in Percent (XLab_ZZP)


Peaks retrieval:

extern int ChannelWidth = 100;

#property indicator_chart_window
#property indicator_buffers 1

#property indicator_color1 Red
#property indicator_width1 3

datetime LastTime;

int init()
{
   LastTime = 0;
   
   return(0);
}

bool GetValue(double dir, int bar, int prevBar, double& peak, int& peakBar, datetime& peakTime)
{
   if (dir < 0)
   {
      datetime t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 2, bar);
      int i = iBarShift(Symbol(), 0, t);

      if (i == prevBar)
      {
         t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 2, bar + 1);
         i = iBarShift(Symbol(), 0, t);
      }

      double v = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 1, i);
      
      if (v == EMPTY_VALUE)
      {
         t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 2, bar + 1);
         i = iBarShift(Symbol(), 0, t);
         v = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 1, i);
      }
      
      peak = v;
      peakBar = i;
      peakTime = t;
   }
   else if (dir > 0)
   {
      t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 3, bar);
      i = iBarShift(Symbol(), 0, t);

      if (i == prevBar)
      {
         t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 3, bar + 1);
         i = iBarShift(Symbol(), 0, t);
      }

      v = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 0, i);
      
      if (v == EMPTY_VALUE)
      {
         t = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 3, bar + 1);
         i = iBarShift(Symbol(), 0, t);
         v = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 0, i);
      }
      
      peak = v;
      peakBar = i;
      peakTime = t;
   }
   else 
   {
      return (false);
   }
   
   return (true);
}

int start()
{
   if (LastTime == Time[0]) return (0);
   LastTime = Time[0];
   
   double dir = iCustom(Symbol(), 0, "XLab_ZZ", ChannelWidth, 4, 1);
   double rdir = -dir;

   if (dir == EMPTY_VALUE) return (0);
   
   double v1, v2, v3, v4, v5;
   int    i1, i2, i3, i4, i5;
   datetime t1, t2, t3, t4, t5;
   
   GetValue(dir, 1, 0, v1, i1, t1);
   GetValue(rdir, i1, 0, v2, i2, t2);
   GetValue(dir, i2, i1, v3, i3, t3);
   GetValue(rdir, i3, i2, v4, i4, t4);
   GetValue(dir, i4, i3, v5, i5, t5);

   SetPt("1", v1, t1);
   SetPt("2", v2, t2);
   SetPt("3", v3, t3);
   SetPt("4", v4, t4);
   SetPt("5", v5, t5);
   
   Print(v1, "   ", v2, "  ", v3, "  ", v4, " ", v5, " ", i1, "  ", i2, "  ", i3, " ", i4, " ", i5);

   return(0);
}

void SetPt(string name, double price, datetime time)
{
   ObjectCreate(name, OBJ_ARROW, 0, time, price);
   ObjectSet(name, OBJPROP_ARROWCODE, 108);
   ObjectSet(name, OBJPROP_PRICE1, price);
   ObjectSet(name, OBJPROP_TIME1, time);
}

This example is an indicator that marks (one time per bar) first five peaks (including current forming)

Attention! This code can work incorrect if 0th Bar Mode is swiched on


0th Bar Mode:

Is set with DrawZeroBar variable. Off by default.

It is not recommended to use this option, especially if the indicator is used in EA


Enjoy using it ;) . Feel free to ask any questions.

If any bugs found, please report me. Thank you.

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/10671

Main Points - Dottor Market Main Points - Dottor Market

Three main pivot points : Daily - Weekly - Monthly.

Strategy Viewer Strategy Viewer

This is a script to view a myfxbook's CSV statements file in MT4.

Martini Martini

The EA without indicators with increasing lot size.

s-PSI@CalculateProfitFromTime s-PSI@CalculateProfitFromTime

Review the results of the work of your strategy (in history) by the hour.