Unverständlicher Kompilierfehler

Einloggen oder registrieren, um einen Kommentar zu schreiben
Mekko189
12
Mekko189  

Hallo zusammen,


ich verzweifel gerade an einem Kopilierungsfehler, wo (meiner Meinung nach) keiner ist.

//+------------------------------------------------------------------+
//| The Zigzag function                                              |
//+------------------------------------------------------------------+
int Zigzag(int H,int Start,int Finish,CArrayInt *IndexVertex,CArrayDouble *ValueVertex)
  {
   bool Up=true;
   double dH=H*Point();
   int j=0;
   int TempMaxBar = Start;
   int TempMinBar = Start;
   double TempMax = rates[Start].high;
   double TempMin = rates[Start].low;
   for(int i=Start+1;i<=Finish;i++)
     {
      // processing the case of a rising segment
      if(Up==true)
        {
         // check that the current maximum has not changed
         if(rates[i].high>TempMax)
           {
            // if it has, correct the corresponding variables
            TempMax=rates[i].high;
            TempMaxBar=i;
           }
         else if(rates[i].low<TempMax-dH)
           {
            // otherwise, if the lagged level is broken, fixate the maximum
            ValueVertex.Add(TempMax);
            IndexVertex.Add(TempMaxBar);
            j++;
            // correct the corresponding variables
            Up=false;
            TempMin=rates[i].low;
            TempMinBar=i;
           }
        }
      else
        {
         // processing the case of the descending segment
         // check that the current minimum hasn't changed
         if(rates[i].low<TempMin)
           {
            // if it has, correct the corresponding variables
            TempMin=rates[i].low;
            TempMinBar=i;
           }
         else if(rates[i].high>TempMin+dH)
           {
            // otherwise, if the lagged level is broken, fix the minimum
            ValueVertex.Add(TempMin);
            IndexVertex.Add(TempMinBar);
            j++;
            // correct the corresponding variables
            Up=true;
            TempMax=rates[i].high;
            TempMaxBar=i;
           }
        }
     }
   // return the number of zigzag tops
   return(j);
  }
CArrayObj *ZigzagArray; // declare the ZigzagArray global dynamic array
//+------------------------------------------------------------------+
//| The FillZigzagArray function                                     |
//| search through the values of the parameter H zigzag              |
//| and fill the array ZigzagArray                                   |
//+------------------------------------------------------------------+
void FillZigzagArray(int Start,int Finish)
  {
   ZigzagArray=new CArrayObj;                       // create the dynamic array of zigzags
   CArrayInt *IndexVertex=new CArrayInt;         // create the dynamic array of indexes of zigzag tops
   CArrayDouble *ValueVertex=new CArrayDouble;   // create the dynamic array of values of the zigzag tops
   TZigzag *Zigzag;                                 // declare the class for storing the indexes and values of the zigzag tops
   int H=1;
   int j=0;
   int n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex);//find the tops of the zigzag with the parameter H=1
   if(n>0)
     {
      // store the tops of the zigzag in the array ZigzagArray
      Zigzag=new TZigzag; // create the object for storing the found indexes and the zigzag tops, 
                             // fill it and store in the array ZigzagArray
      Zigzag.IndexVertex=IndexVertex;
      Zigzag.ValueVertex=ValueVertex;
      ZigzagArray.Add(Zigzag);
      j++;
     }
   H++;
   // loop of the H of the zigzag
   while(true)
     {
      IndexVertex=new CArrayInt;                            // create a dynamic array of indexes of zigzag tops
      ValueVertex=new CArrayDouble;                        // create a dynamic array of values of the zigzag tops
      n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex); // find the tops of the zigzag
      if(n>0)
        {
         Zigzag=ZigzagArray.At(j-1);
         CArrayInt *PrevIndexVertex=Zigzag.IndexVertex; // get the array of indexes of the previous zigzag
         bool b=false;
         // check if there is a difference between the current zigzag and the previous zigzag
         for(int i=0; i<=n-1;i++)
           {
            if(PrevIndexVertex.At(i)!=IndexVertex.At(i))
              {
               // if there is a difference, store the tops of a zigzag in the array ZigzagArray
               Zigzag=new TZigzag;
               Zigzag.IndexVertex=IndexVertex;
               Zigzag.ValueVertex=ValueVertex;
               ZigzagArray.Add(Zigzag);
               j++;
               b=true;
               break;
              }
           }
         if(b==false)
           {
            // otherwise, if there is no difference, release the memory
            delete IndexVertex;
            delete ValueVertex;
           }
        }
      // search for the tops of the zigzag until there is two or less of them
      if(n<=2)
         break;
      H++;
     }
  }

An den Zeilen

int n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex);//find the tops of the zigzag with the parameter H=1

und

n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex); // find the tops of the zigzag

scheint er sich zu stören:

',' - unexpected token   
'H' - some operator expected   
'=' - illegal operation use  
')' - unexpected token 

Die Funktion

int Zigzag(int H,int Start,int Finish,CArrayInt *IndexVertex,CArrayDouble *ValueVertex)

wird mit allen Argumenten angelegt und beim Aufruf mit

int n=Zigzag(H,Start,Finish,IndexVertex,ValueVertex);//find the tops of the zigzag with the parameter H=1

wirft der Kompilier diese Fehler raus. n ist als int deklariert und wird mit der Funktion Zigzag initialisiert. Alle enthaltenen Argumente sind vorher auch als int deklariert worden. Was übersehe ich? Der Kompilier kann ja nicht kaputt sein. ;-)

Vielen Dank für Eure Hilfe.


Version: 5.00 build 2190

Carl Schreiber
Moderator
8695
Carl Schreiber  

Poste doch bitte den ganzen Ausdruck der Fehler, da ist dann leichter zu erkennen, ob es zB. ein Folgefehler ist.

Ist H global vielleicht auch noch definiert, zB. als Makro für die Stunde?

Übrigens eine einfache Suche (oben rechts)  nach "ZigZag" ergab für die frei verfügbare CodeBase 170 Varianten von ZigZag (17 Seiten mit jeweils 10 Varianten) da könnte doch etwas sein?
Mekko189
12
Mekko189  
Carl Schreiber:

Poste doch bitte den ganzen Ausdruck der Fehler, da ist dann leichter zu erkennen, ob es zB. ein Folgefehler ist.

Ist H global vielleicht auch noch definiert, zB. als Makro für die Stunde?

Vielen Dank für die schnelle Antwort.

Das H noch irgendwie/wo anders definiert ist, habe ich nicht gefunden. Hier das Protokoll:

'Elliott_wave_en.mq5'   Elliott_wave_en.mq5     1       1
'Object.mqh'    Object.mqh      1       1
'StdLibErr.mqh' StdLibErr.mqh   1       1
'List.mqh'      List.mqh        1       1
'ArrayObj.mqh'  ArrayObj.mqh    1       1
'Array.mqh'     Array.mqh       1       1
'ArrayInt.mqh'  ArrayInt.mqh    1       1
'ArrayDouble.mqh'       ArrayDouble.mqh 1       1
'ArrayString.mqh'       ArrayString.mqh 1       1
'ChartObjectsTxtControls.mqh'   ChartObjectsTxtControls.mqh     1       1
'ChartObject.mqh'       ChartObject.mqh 1       1
'Data structures.mqh'   Data structures.mqh     1       1
'Analysis functions.mqh'        Analysis functions.mqh  1       1
'Rules functions.mqh'   Rules functions.mqh     1       1
declaration of 'Text' hides member      Data structures.mqh     34      33
   see previous declaration of 'Text'   Data structures.mqh     33      22
declaration of 'Wave' hides member      Data structures.mqh     34      45
   see previous declaration of 'Wave'   Data structures.mqh     32      22
possible loss of data due to type conversion    Rules functions.mqh     33      19
possible loss of data due to type conversion    Rules functions.mqh     34      39
possible loss of data due to type conversion    Rules functions.mqh     35      11
possible loss of data due to type conversion    Rules functions.mqh     42      19
possible loss of data due to type conversion    Rules functions.mqh     43      11
possible loss of data due to type conversion    Rules functions.mqh     49      11
check operator precedence for possible error; use parentheses to clarify precedence     Rules functions.mqh     203     31
expression not boolean  Rules functions.mqh     231     30
possible loss of data due to type conversion    Elliott_wave_en.mq5     189     20
possible loss of data due to type conversion    Elliott_wave_en.mq5     226     20
possible use of uninitialized variable 'Color'  Elliott_wave_en.mq5     292     27
possible use of uninitialized variable 'Anchor' Elliott_wave_en.mq5     293     47
declaration of 'IndexVertex' hides global variable      Elliott_wave_en.mq5     440     50
   see previous declaration of 'IndexVertex'    Rules functions.mqh     8       5
declaration of 'ValueVertex' hides global variable      Elliott_wave_en.mq5     440     76
   see previous declaration of 'ValueVertex'    Rules functions.mqh     9       8
declaration of 'IndexVertex' hides global variable      Elliott_wave_en.mq5     508     15
   see previous declaration of 'IndexVertex'    Rules functions.mqh     8       5
declaration of 'ValueVertex' hides global variable      Elliott_wave_en.mq5     509     18
   see previous declaration of 'ValueVertex'    Rules functions.mqh     9       8
',' - unexpected token  Elliott_wave_en.mq5     513     18
'H' - some operator expected    Elliott_wave_en.mq5     513     17
'=' - illegal operation use     Elliott_wave_en.mq5     513     9
possible use of uninitialized variable 'Zigzag' Elliott_wave_en.mq5     513     10
'Start' - semicolon expected    Elliott_wave_en.mq5     513     19
',' - unexpected token  Elliott_wave_en.mq5     513     24
expression has no effect        Elliott_wave_en.mq5     513     19
',' - unexpected token  Elliott_wave_en.mq5     513     31
expression has no effect        Elliott_wave_en.mq5     513     25
',' - unexpected token  Elliott_wave_en.mq5     513     43
expression has no effect        Elliott_wave_en.mq5     513     32
')' - unexpected token  Elliott_wave_en.mq5     513     55
expression has no effect        Elliott_wave_en.mq5     513     44
',' - unexpected token  Elliott_wave_en.mq5     530     17
'H' - some operator expected    Elliott_wave_en.mq5     530     16
'=' - illegal operation use     Elliott_wave_en.mq5     530     8
',' - unexpected token  Elliott_wave_en.mq5     530     23
',' - unexpected token  Elliott_wave_en.mq5     530     30
expression has no effect        Elliott_wave_en.mq5     530     24
',' - unexpected token  Elliott_wave_en.mq5     530     42
expression has no effect        Elliott_wave_en.mq5     530     31
')' - unexpected token  Elliott_wave_en.mq5     530     54
expression has no effect        Elliott_wave_en.mq5     530     43
declaration of 'IndexVertex' hides global variable      Elliott_wave_en.mq5     576     18
   see previous declaration of 'IndexVertex'    Rules functions.mqh     8       5
declaration of 'ValueVertex' hides global variable      Elliott_wave_en.mq5     577     21
   see previous declaration of 'ValueVertex'    Rules functions.mqh     9       8
15 error(s), 28 warning(s)              16      29
Carl Schreiber
Moderator
8695
Carl Schreiber  

Wegen dieser beiden Zeilen:

'=' - illegal operation use     Elliott_wave_en.mq5     513     9
possible use of uninitialized variable 'Zigzag' Elliott_wave_en.mq5     513     10

vermute ich, dass es eine Variable und eine Funktion mit dem selben Namen ZigZag gibt, und das zu dem Fehler führt.

Mekko189
12
Mekko189  
Carl Schreiber:

Wegen dieser beiden Zeilen:

vermute ich, dass es eine Variable und eine Funktion mit dem selben Namen ZigZag gibt, und das zu dem Fehler führt.

Ich glaube, das war's. Manchmal sieht man den Wald vor lauter Bäumen nicht.

Hab eine von beiden umbenannt und schon funktioniert es.


Vielen vielen Dank für Deine Hilfe.
Einloggen oder registrieren, um einen Kommentar zu schreiben