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

 
jackprobe:

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



Pouvez-vous me montrer comment vous obtenez avec cet indicateur les valeurs 0.0 et 100.0 ?
 
deVries:

Pouvez-vous me montrer comment vous obtenez avec cet indicateur les valeurs 0.0 et 100.0 ?

Je l'ai fait manuellement en utilisant les outils de retracement fibo de MT4 ...... :) Je veux vraiment faire comme cette image, mais je ne sais toujours pas comment coder.

A propos de iCustom, dois-je l'appeler comme ceci (en appelant votre fichier TopBottomZigzag.ex4) ?

double top[i] = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,i);
double bottom[i] = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,i);

Merci

 
jackprobe:

Je l'ai fait manuellement en utilisant les outils de retracement fibo de MT4 ...... :) Je veux vraiment faire comme cette image, mais je ne sais toujours pas comment coder.

A propos de iCustom, dois-je l'appeler comme ceci (en appelant votre fichier TopBottomZigzag.ex4) ?

Merci


non ce sont les mauvais tampons et vous devez trouver la valeur de i à quelle barre le haut ou le bas sera.

Si je le compare à la version que j'ai postée dans CodeBase, je vois un zigzag avec une ligne à la baisse et une ligne à la hausse.

//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

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

double P0,P1,P2,P3,P4,P5;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

   call_zigzag();


   subPrintDetails();
//----
   return(0); 

  }
//+------------------------------------------------------------------+

//----------------------- PRINT COMMENT FUNCTION
void subPrintDetails()
{
   string sComment   = "";
   string sp         = "----------------------------------------\n";
   string NL         = "\n";


       
   sComment = "ZigZag practise           Copyright © 2012, Tjipke" + NL;
   sComment = sComment + NL;
   sComment = sComment + "P0 " + DoubleToStr(P0,Digits) + NL;
   sComment = sComment + "P1 " + DoubleToStr(P1,Digits) + NL;
   sComment = sComment + "P2 " + DoubleToStr(P2,Digits) + NL;
   sComment = sComment + "P3 " + DoubleToStr(P3,Digits) + NL;
   sComment = sComment + "P4 " + DoubleToStr(P4,Digits) + NL;
   sComment = sComment + "P5 " + DoubleToStr(P5,Digits) + NL;            
   sComment = sComment + "Buffervalue 0  ZigZag " + NL;


   Comment(sComment);
}
//+------------------------------------------------------------------+

void call_zigzag ()
{
//This function calls the custom indicator zigzag and returns it´s values. THE INDICATOR ZIGZAG MUST BE IN THE FOLDER C:\...\MetaTrader 4\experts\indicators AND MUST BE NAMED "zigzag"!!!!
   int n, i = 0;
      while(n<6)
      {
      if(P0>0) {P5=P4; P4=P3; P3=P2; P2=P1; P1=P0; }
      P0=iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
      if(P0>0) {n+=1; }
      i++;
      }
}

C'est comme ça que je faisais avec un zigzag normal avant de créer l'indicateur de ce sujet.

voyez si vous trouvez la logique

.

(éditez le post pour donner le lien de la version correcte que vous trouvez dans CodeBase)

 
deVries:


Non, ce ne sont pas les bons tampons et vous devez trouver la valeur de i à quelle barre le haut ou le bas se trouvera.

Si je la compare à la version que j'ai postée dans CodeBase, je vois un zigzag avec une ligne à la baisse et une ligne à la hausse.

C'est comme ça que je faisais avec le zigzag normal avant de créer l'indicateur de ce sujet.

voyez si vous trouvez la logique

.

(éditer le post pour donner le lien de la version correcte que vous trouvez dans CodeBase)


Bonjour deVries,

Merci pour le lien. Je viens d'essayer d'utiliser iCustom pour appeler votre indicateur que j'ai nommé "TopBottomZigzag.ex4" . Le résultat est excellent. Cette fois la ligne de Fibo est créée par le code ... :)

Je ne peux toujours pas faire le Fibo de la jambe ZZ précédente .... :( Il dessine toujours la dernière jambe ZZ seulement. Et je ne peux toujours pas définir la longueur de la ligne de niveau de la Fibo ...

Merci pour votre beau code ....

- jackprobe

//+------------------------------------------------------------------+
//|                                                       zzFibo.mq4 |
//|                        based on "TopBottomZigzag.mq4" by deVries |
//|                                            edited by : Jackprobe |
//+------------------------------------------------------------------+

#property copyright "deVries & Jackprobe"
#property link      "https://forum.mql4.com/54660"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_width1 2
#property indicator_color2 DeepPink
#property indicator_width2 2

//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
 
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
int    jmlTitik=0;
double prevPrc=0;
int    topCandle=0, bottomCandle=0;
string myObjName = "myZZFibo";
double objWidth = 1.0;
double objStyle = 2.0;
color  objLevelColor = Aqua;
color  objColor = Gold;

//+------------------------------------------------------------------+
//| INIT() Function                                                  |
//+------------------------------------------------------------------+
int init()  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1,indicator_color1); 
   SetIndexBuffer(0,UpBuffer);
   SetIndexArrow(0,221);
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1,indicator_color2); 
   SetIndexBuffer(1,DnBuffer);
   SetIndexArrow(1,222);
   string short_name;
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   short_name="TopBottomZZFibo";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Up");
   SetIndexLabel(1,"Dn");
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexEmptyValue(1,EMPTY_VALUE);   
   return(0);
}

//+------------------------------------------------------------------+
//| DEINIT() Function                                                |
//+------------------------------------------------------------------+
int deinit() {
   ObjectDelete(myObjName);
}

//+------------------------------------------------------------------+
//| START() Function                                                 |
//+------------------------------------------------------------------+
int start() {
   int  shift, counted_bars=IndicatorCounted(),limit;
   double topPrc=0, bottomPrc=0;      
   if ( counted_bars > 0 )  limit=Bars-counted_bars;
   if ( counted_bars < 0 )  return(0);
   if ( counted_bars ==0 )  limit=Bars-1; 
   if ( counted_bars < 1 ) 
   
   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
           ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       
   //----
        return(0);      
}
 

demain je continue

cette partie

   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);

doit être changée

 

Si vous regardez votre image, vous voyez que Fibonnacci est seulement dessiné aux niveaux des 2 derniers points de Zigzag.

votre problème est le suivant : "je ne peux pas faire le Fibo de la jambe ZZ précédente .... :( Il dessine toujours la dernière jambe ZZ seulement. Et aussi, on ne peut toujours pas définir la longueur de la ligne de niveau du Fibo ...".

Vous devez donc vérifier ce que fait votre code et comment il arrive au résultat que vous avez maintenant

.

Nous voulons savoir ce que votre code fait dans cette partie.

  for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
           ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       

en commençant par quelques états d'impression, nous devons découvrir ce qui se passe.

for(shift=limit;shift>=0;shift--)  
      { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
//..
      Print("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc);
//.....
      }

Que voyez-vous se passer ?

 

Bonjour deVries,

J'utilise Alert au lieu de Print. Si la bougie est à l'intérieur de la jambe (pas à la fin ou au début de la jambe), nous ne pouvons pas voir le prix. Mais à la fin de la jambe, nous pouvons voir le prix (voir la flèche rouge et verte sur le graphique). Donc, je pense que iCustom peut être utilisé, mais il y a un mauvais codage, et je ne sais toujours pas où il se trouve ...

edit : il se peut que je doive utiliser un tableau / tampon pour contenir toutes les informations du point de fin de zigzag (prix du point de fin de zz, numéro de bougie du point de fin de zz et numéro d'accurance du point de fin de zz). Il se peut que je doive utiliser un tableau 3x1 de type = double, ou simplement un tableau 1x1 de type string (mais je dois d'abord "concaténer" toutes les informations du point de fin de zigzag). ? ???


for(shift=limit;shift>=0;shift--)  {    
      topPrc = iCustom(Symbol(),0,"topBottomZZ-2",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"topBottomZZ-2",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      Alert("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         Alert("Inside first If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         Alert("Inside second If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       
 

Salut deVries,

Oui, vous avez raison. Si j'essaie d'attraper la valeur, et de la mettre dans un tableau, le résultat est toujours 0 (zéro) .....
Je ne comprends toujours pas, pourquoi il peut afficher la flèche (représentant la fin de ZZ), mais comme j'essaie de le mettre dans le tableau, le résultat est zéro ... ??

Merci


     if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         /// Alert("Inside first If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         DnBuffer[shift]= topPrc + 0.0003;        
         resPrice[jmlTitik] = topPrc;
         resCandle[jmlTitik] = shift;
         resPos[jmlTitik] = 1;
         Alert("1 LastPrice =", resPrice[jmlTitik]);
         Alert("1 LastCandle =", resCandle[jmlTitik]);
         Alert("1 LastPos =", resPos[jmlTitik]);
         //-- ganz unten
         jmlTitik++;
         prevPrc = topPrc;
         topCandle = shift;
      }
 

utiliser l'indicateur de la base de code puis le code doit être

//   if ( counted_bars < 1 ) 
   
   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"Zigzag_with_line_at_lows_and_line_at_highs",ExtDepth,ExtDeviation,ExtBackstep,3,shift);
      bottomPrc = iCustom(Symbol(),0,"Zigzag_with_line_at_lows_and_line_at_highs",ExtDepth,ExtDeviation,ExtBackstep,4,shift);
      
      
       Print("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc);
      
     }/* 

en le testant sur le graphique vous verrez imprimé (avec allert inutile)

2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  1.0298  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  1.0286
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  1.0297  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
//....  this is not all

chaque tick vous le calculez à nouveau enlevez plusieurs fois les objets et placez de nouveaux objets à nouveau jusqu'à ce que vous arriviez au dernier calcul != 0

que fait le code que j'ai donné

//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

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

double P0,P1,P2,P3,P4,P5;


//....  you find it in a post above
 
Merci deVries. Je vais l'essayer ...
Raison: