Comment extraire uniquement les points de retournement de bas de page extraits par l'indicateur zigzag ?

 

Cher tous, Comment modifier le code pour montrer seulement les bas du zigzag ?

Le code ci-dessous permet d'extraire avec succès les tops extraits par l'indicateur zigzag.tops[] a été spécifié comme tampon d'index dans la fonction init( )....Mais est-il possible de ne montrer que les bas des points de retournement inférieurs en modifiant l'avant dernier paramètre de l'appel iCustom ? Si la réponse est non, que dois-je faire sur la plateforme MT4 ? J'ai essayé de prendre 0 et 2 comme avant-dernier paramètre, mais le résultat n'est pas celui que je voulais. ....

Mon code est joint pour votre commodité. Et je l'ai simplifié autant que je peux... Merci beaucoup pour votre temps et votre considération.
int start()
{
  int counted_bars=IndicatorCounted();
  int limit=0;
  limit = Bars-counted_bars;
  
  for(int shift=limit-1;shift>=0;shift--)
  {
    tops[shift]=iCustom (NULL,0,"ZigZag", 12,5,3, 1, shift);
    if(tops[shift]>0.1) tops[shift]=tops[shift];
  }
  
  return(0);
}

 

comme la comparaison

double K = iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
if (K==Low[i] && K>0)  //..low zigzag......   
 

deVries,

Merci beaucoup pour votre réponse rapide. Voulez-vous dire simplement changer l'avant-dernier paramètre de iCustom à 0 ? J'ai déjà essayé de le faire et le résultat n'est pas du tout ce que je souhaitais... Pour rendre ma question plus claire, je vous montre les deux figures ci-dessous pour illustrer ma question....

.FIg.1 Les sommets non désirés (A.B.C.D.e) sont représentés dans la figure ci-dessus.

Fig1. Des sommets non désirés sont affichés alors que je ne veux afficher que les sommets ! Je veux filtrer tous les hauts indésirables alors que je ne veux afficher que les bas.

Fig2. Seuls les sommets souhaités sont affichés

FIg2. Les hauts désirés sont affichés sans aucun bas indésirable. C'est le résultat que je souhaite obtenir.

Ma question est donc la suivante : est-il possible d'afficher uniquement les points bas sans afficher les points A/B/C/D/E ? J'espère avoir répondu clairement à ma question......

Merci beaucoup pour votre réponse rapide....

 
//+------------------------------------------------------------------+
//|                                                      Zigzag2.mq4 |
//|                 Copyright © 2005-2007, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Magenta
#property indicator_color3 LightSkyBlue


//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//---- indicator buffers
double ZigzagBuffer[];
double HighMapBuffer[];
double LowMapBuffer[];
int level=3; // recounting's depth 
bool downloadhistory=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexStyle(1,DRAW_SECTION);   
   SetIndexStyle(2,DRAW_SECTION);   
//---- indicator buffers mapping
   SetIndexBuffer(0,ZigzagBuffer);
   SetIndexBuffer(1,HighMapBuffer);
   SetIndexBuffer(2,LowMapBuffer);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);   
   SetIndexEmptyValue(2,0.0);   

//---- indicator short name
   IndicatorShortName("ZigZag("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i, counted_bars = IndicatorCounted();
   int limit,counterZ,whatlookfor;
   int shift,back,lasthighpos,lastlowpos;
   double val,res;
   double curlow,curhigh,lasthigh,lastlow;

   if (counted_bars==0 && downloadhistory) // history was downloaded
     {
      ArrayInitialize(ZigzagBuffer,0.0);
      ArrayInitialize(HighMapBuffer,0.0);
      ArrayInitialize(LowMapBuffer,0.0);
     }
   if (counted_bars==0) 
     {
      limit=Bars-ExtDepth;
      downloadhistory=true;
     }
   if (counted_bars>0) 
     {
      while (counterZ<level && i<100)
        {
         res=ZigzagBuffer[i];
         if (res!=0) counterZ++;
         i++;
        }
      i--;
      limit=i;
      if (LowMapBuffer[i]!=0) 
        {
         curlow=LowMapBuffer[i];
         whatlookfor=1;
        }
      else
        {
         curhigh=HighMapBuffer[i];
         whatlookfor=-1;
        }
      for (i=limit-1;i>=0;i--)  
        {
         ZigzagBuffer[i]=0.0;  
         LowMapBuffer[i]=0.0;
         HighMapBuffer[i]=0.0;
        }
     }
      
   for(shift=limit; shift>=0; shift--)
     {
      val=Low[iLowest(NULL,0,MODE_LOW,ExtDepth,shift)];
      if(val==lastlow) val=0.0;
      else 
        { 
         lastlow=val; 
         if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=LowMapBuffer[shift+back];
               if((res!=0)&&(res>val)) LowMapBuffer[shift+back]=0.0; 
              }
           }
        } 
      if (Low[shift]==val) LowMapBuffer[shift]=val; else LowMapBuffer[shift]=0.0;
      //--- high
      val=High[iHighest(NULL,0,MODE_HIGH,ExtDepth,shift)];
      if(val==lasthigh) val=0.0;
      else 
        {
         lasthigh=val;
         if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=HighMapBuffer[shift+back];
               if((res!=0)&&(res<val)) HighMapBuffer[shift+back]=0.0; 
              } 
           }
        }
      if (High[shift]==val) HighMapBuffer[shift]=val; else HighMapBuffer[shift]=0.0;
     }

   // final cutting 
   if (whatlookfor==0)
     {
      lastlow=0;
      lasthigh=0;  
     }
   else
     {
      lastlow=curlow;
      lasthigh=curhigh;
     }
   for (shift=limit;shift>=0;shift--)
     {
      res=0.0;
      switch(whatlookfor)
        {
         case 0: // look for peak or lawn 
            if (lastlow==0 && lasthigh==0)
              {
               if (HighMapBuffer[shift]!=0)
                 {
                  lasthigh=High[shift];
                  lasthighpos=shift;
                  whatlookfor=-1;
                  ZigzagBuffer[shift]=lasthigh;
                  res=1;
                 }
               if (LowMapBuffer[shift]!=0)
                 {
                  lastlow=Low[shift];
                  lastlowpos=shift;
                  whatlookfor=1;
                  ZigzagBuffer[shift]=lastlow;
                  res=1;
                 }
              }
             break;  
         case 1: // look for peak
            if (LowMapBuffer[shift]!=0.0 && LowMapBuffer[shift]<lastlow && HighMapBuffer[shift]==0.0)
              {
               ZigzagBuffer[lastlowpos]=0.0;
               lastlowpos=shift;
               lastlow=LowMapBuffer[shift];
               ZigzagBuffer[shift]=lastlow;
               res=1;
              }
            if (HighMapBuffer[shift]!=0.0 && LowMapBuffer[shift]==0.0)
              {
               lasthigh=HighMapBuffer[shift];
               lasthighpos=shift;
               ZigzagBuffer[shift]=lasthigh;
               whatlookfor=-1;
               res=1;
              }   
            break;               
         case -1: // look for lawn
            if (HighMapBuffer[shift]!=0.0 && HighMapBuffer[shift]>lasthigh && LowMapBuffer[shift]==0.0)
              {
               ZigzagBuffer[lasthighpos]=0.0;
               lasthighpos=shift;
               lasthigh=HighMapBuffer[shift];
               ZigzagBuffer[shift]=lasthigh;
              }
            if (LowMapBuffer[shift]!=0.0 && HighMapBuffer[shift]==0.0)
              {
               lastlow=LowMapBuffer[shift];
               lastlowpos=shift;
               ZigzagBuffer[shift]=lastlow;
               whatlookfor=1;
              }   
            break;               
         default: return; 
        }
     }

   return(0);
  }
//+------------------------------------------------------------------+

Il était possible de ne montrer que le tampon zigzag.

le zigzag se repeint


voir le résultat de ceci

 

Voici ce que j'ai trouvé. Je n'ai pas vérifié les résultats de deVries ci-dessus [je faisais cela quand il a posté].

#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);
}

 
ubzen:

Voici ce que j'ai trouvé. Je n'ai pas vérifié les résultats de deVries ci-dessus [je faisais cela quand il a posté].

Nice ubzen avec l'aide de votre code je suis venu à ce......

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 3
#property indicator_color2 Green
#property indicator_width2 3
#property indicator_color3 Yellow
#property indicator_width3 3


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


double ZigZag[];
double Bottoms[];
double Toppers[];

int init()
{
   IndicatorBuffers(3);

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

   SetIndexStyle(2,DRAW_SECTION);
   SetIndexBuffer(2,Toppers);
   SetIndexEmptyValue(2,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--)
  {
    ZigZag[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        0, shift
    );

    if(ZigZag[shift]>0.1 && Low[shift]==ZigZag[shift]) Bottoms[shift]=ZigZag[shift];
    if(ZigZag[shift]>0.1 && High[shift]==ZigZag[shift]) Toppers[shift]=ZigZag[shift];
  }
  
  return(0);
}

Cela donne le résultat suivant


maintenant les bas et les hauts correspondent tous avec le zigzag.

 
deVries: Niceubzen avec l'aide de votre code je suis venu à ce...... Cela donne comme résultat
Beau travaildeVries.
 
Chers tous, avec votre aide et votre gentillesse, notamment de la part deVries et Ubzen, mon indicateur a réussi à dessiner le tableau reliant les points de retournement de bas de page extraits par l'indicateur zigzag en cette joyeuse matinée de début de printemps.... :)
 
d



deVries:

Nice ubzen avec l'aide de votre code je suis venu à ce......

Cela donne comme résultat

maintenant les bas et les hauts correspondent tous avec le zigzag





Bonjour deVries,

Merci beaucoup pour votre code. Si je veux savoir à quelle distance se trouve le Retracement de Fibonacci de la dernière jambe en zigzag, par rapport à la jambe en zigzag précédente. Comment faire ?

Je veux faire comme l'image, mais le code ci-dessous que j'ai essayé ne l'a pas fait ...

Merci,

jack

Retracement Fibo


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 3
#property indicator_color2 Green
#property indicator_width2 3
#property indicator_color3 Yellow
#property indicator_width3 3


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


double ZigZag[];
double Bottoms[];
double Toppers[];
double resBuffer[][];

//---
int init() {
   IndicatorBuffers(3);

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

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

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

int deinit()
{
  ObjectDelete("myFibo");
  return(0);
}

int start()
{
  int counted_bars=IndicatorCounted();
  int limit=0;
  limit = Bars-counted_bars;
  int k=0, m=0;
  int candle1=0, candle2=0;
  double prc1=0, prc2=0;
  
  for(int shift=limit-1;shift>=0;shift--) {
    ZigZag[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        0, shift
    );

    if(ZigZag[shift]>0.1 && Low[shift]==ZigZag[shift]) {
      Bottoms[shift]=ZigZag[shift];
      resBuffer[k][0] = Bottoms[shift];
      resBuffer[k][1] = shift;
      k++;
    }
    if(ZigZag[shift]>0.1 && High[shift]==ZigZag[shift]) {
      Toppers[shift]=ZigZag[shift];
      resBuffer[k][0] = Toppers[shift];
      resBuffer[k][1] = shift;
      k++;
    }
  } // ende for
  
  //---
  for(m=k;m>=0;m--) {
   candle1 = resBuffer[m][1];
   prc1 = resBuffer[m][0];
   candle2 = resBuffer[m-1][1];
   prc2 = resBuffer[m-1][0];
   //---
         ObjectDelete("myFibo");
         ObjectCreate("myFibo", OBJ_FIBO, 0, Time[candle1], prc2, Time[candle2], prc1);
 
  } // ende for
          
  return(0);
}
 
jackprobe:


Bonjour deVries,

Merci beaucoup pour votre code. Si je veux savoir à quelle distance se trouve le Retracement de Fibonacci de la dernière jambe de zigzag, par rapport à la jambe de zigzag précédente. Comment faire ?

Merci,

jack


dessiner fibonacci de cette façon trouver les deux points avec l'indicateur zigzag iCustom

0.0 1.6154

100.0 1.6168

différence 0.0014

dernier sommet = 1.6169

différence avec 0.0 0.0015 en% 0.0015/0.0014 * 100% = 107% en distance + 0.0001

C'est ce que vous voulez dire ?

 

Bonjour deVries,

Merci. Oui, c'est comme l'image que vous avez envoyé. Mais je veux savoir comment le coder. Il doit calculer chaque jambe de zigzag précédente, puis dessiner le niveau de Fibonacci, afin que nous sachions jusqu'où va le zigzag actuel / dernier zigzag.

edit : j'ai envoyé le code sur le post précédent. Il ne dessine pas la ligne de Fibonacci ...

Merci

Raison: