Author Topic: Help coding this MQL4 indicator TO AFL coding  (Read 2010 times)

kumar

  • Newbie
  • *
  • Posts: 1
    • View Profile
Help coding this MQL4 indicator TO AFL coding
« on: April 13, 2016, 09:36:41 am »
Kindly it is very hepful if any one convert this MQL4 indicator TO AFL coding..
ZIGZAG WITHOUT REPAINT:
----------------------------------
Code: [Select]
#property copyright "ñëîâà - Mandor, ìóçûêà - íàðîäíàÿ"
#property link "mandorr@gmail.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue
//----
extern int Length=18;       
extern int CountBars=1000; 
extern int  indexSymbolUp = 108;
extern int  indexSymbolDn = 108;
extern int  widthSimbol = 1;   

//----
double buffer[];
double buf_UP[];
double buf_DN[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void init()
  {
   SetIndexStyle(0,DRAW_SECTION,0,1);
   SetIndexBuffer(0,buffer);
   SetIndexLabel(0,"Value");
   SetIndexDrawBegin(0,0);
    SetIndexBuffer(1,buf_UP);
    SetIndexStyle(1,DRAW_ARROW, EMPTY, widthSimbol, Blue);
    SetIndexArrow(1,indexSymbolUp);
    SetIndexLabel(1, "Up");
    SetIndexBuffer(2,buf_DN);
    SetIndexStyle(2,DRAW_ARROW, EMPTY, widthSimbol, Red);
    SetIndexArrow(2,indexSymbolDn);
    SetIndexLabel(2, "Dn");

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void start()
  {
   int shift, zu, zd, Swing, Swing_n;
   double HH, LL, BH, BL;
//----
   Swing=0;
   Swing_n=0;
   shift=CountBars-1;
   zu=shift;
   zd=shift;
   BH=High[shift];
   BL=Low[shift];
//----
   for(shift=CountBars-1; shift>=0; shift--)
     {
      HH=High[Highest(NULL,0,MODE_HIGH,Length,shift+1)];
      LL=Low [Lowest (NULL,0,MODE_LOW ,Length,shift+1)];
      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];}
         if (Swing== 1) { buffer[zd]=BL; buf_UP[zd] = BL;}
         if (Swing==-1) { buffer[zu]=BH; buf_DN[zu]=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;
     }
  }
//+------------------------------------------------------------------+
« Last Edit: May 15, 2016, 08:15:07 pm by administrator »