A question for MQL experts - page 16

 
artmedia70:

Is there such a symbol?

Thank you very much!!! I never would have found such a glitch... They write a lot of crap in textbooks, and I'm just copying without looking...
 

Could you please tell me where the error is? Why are the results different?

//+------------------------------------------------------------------+
//|                                                       TestFr.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   double FrUpz=0;
   double FrUp1 = GetFractal("0", 0, 1, MODE_UPPER);
   double FrUp2 = GetFractal("0", 0, 2, MODE_UPPER);
   double FrUp3 = GetFractal("0", 0, 3, MODE_UPPER);
   Print("# FrUp1=",FrUp1);
   Print("# FrUp2=",FrUp2);
   Print("# FrUp3=",FrUp3);
   for(int z=1;z<=3;z++)
      {
       FrUpz = GetFractal("0", 0, z, MODE_UPPER);
       Print("z=",z," FrUpz=",FrUpz);
      } 
  }
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru  & khorosh        |
//+----------------------------------------------------------------------------+
//|  Версия   : 08.02.2009                                                     |
//|  Описание : Возвращает фрактал по его номеру.                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента        ("" или NULL - текущий символ)     |
//|    tf - таймфрейм                       (    0       - текущий ТФ)         |
//|    nf - номер фрактала                  (    0       - последний)          |
//+----------------------------------------------------------------------------+
double GetFractal(string sy="0", int tf=0, int nf=0, int mode=MODE_UPPER) {
  if (sy=="" || sy=="0") sy=Symbol();
  double f=0;
  int    i, k=iBars(sy, tf), kf;
  for (i=3; i<k; i++) {
    if(mode==MODE_LOWER){
    f=iFractals(sy, tf, MODE_LOWER, i);
    if (f!=0) {
      kf++;
      if (kf>nf) return(iLow(sy,tf,i));
     } 
    }
    if(mode==MODE_UPPER){
    f=iFractals(sy, tf, MODE_UPPER, i);
    if (f!=0) {
      kf++;
      if (kf>nf) return(iHigh(sy,tf,i));
      }
    }
  }
  Print("GetFractalBar(): Фрактал не найден");
  return(-1);
}

Result:

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=3 FrUpz=1.37083

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=2 FrUpz=1.37083

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=1 FrUpz=1.37104

2014.02.17 19:56:38.828 TestFr EURUSD,M15: # FrUp3=1.37056

2014.02.17 19:56:38.812 TestFr EURUSD,M15: # FrUp2=1.37162

2014.02.17 19:56:38.812 TestFr EURUSD,M15: # FrUp1=1.37083

 
khorosh:

Could you please tell me where the error is? Why are the results different?

Result:

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=3 FrUpz=1.37083

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=2 FrUpz=1.37083

2014.02.17 19:56:38.828 TestFr EURUSD,M15: z=1 FrUpz=1.37104

2014.02.17 19:56:38.828 TestFr EURUSD,M15: # FrUp3=1.37056

2014.02.17 19:56:38.812 TestFr EURUSD,M15: # FrUp2=1.37162

2014.02.17 19:56:38.812 TestFr EURUSD,M15: # FrUp1=1.37083


For ease of control, the function is slightly modified to return the bar number

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru  & khorosh        |
//+----------------------------------------------------------------------------+
//|  Версия   : 08.02.2009                                                     |
//|  Описание : Возвращает фрактал по его номеру.                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента        ("" или NULL - текущий символ)     |
//|    tf - таймфрейм                       (    0       - текущий ТФ)         |
//|    nf - номер фрактала                  (    0       - последний)          |
//+----------------------------------------------------------------------------+
double GetFractal(string sy="0",int tf=0,int nf=0,int mode=MODE_UPPER) 
  {
   if(sy=="" || sy=="0") sy=Symbol();
   double f=0;
   int    i,k=iBars(sy,tf),kf;
   for(i=3; i<k; i++) 
     {
      if(mode==MODE_LOWER)
        {
         f=iFractals(sy,tf,MODE_LOWER,i);
         if(f!=0) 
           {
            kf++;
//            if(kf>nf) return(iLow(sy,tf,i));
               if(kf>nf) return(i);
           }
        }
      if(mode==MODE_UPPER)
        {
         f=iFractals(sy,tf,MODE_UPPER,i);
         if(f!=0) 
           {
            kf++;
//            if(kf>nf) return(iHigh(sy,tf,i));
               if(kf>nf) return(i);
           }
        }
     }
   Print("GetFractalBar(): Фрактал не найден");
   return(-1);
  }
//+------------------------------------------------------------------+

Result

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: z=3 FrUpz=9.0

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: z=2 FrUpz=9.0

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: z=1 FrUpz=13.0

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: # FrUp3=24.0

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: # FrUp2=17.0

2014.02.17 21:45:57.409 TestFr GBPUSD,H1: # FrUp1=13.0


 

Added explicit initialisation of all variables

double GetFractal(string sy="0",int tf=0,int nf=0,int mode=MODE_UPPER) 
  {
   if(sy=="" || sy=="0") sy=Symbol();
   double f=0;
   int    i=0,k=iBars(sy,tf),kf=0;
   for(i=3; i<k; i++) 
     {
      if(mode==MODE_LOWER)
        {
         f=iFractals(sy,tf,MODE_LOWER,i);
         if(f!=0) 
           {
            kf++;
//            if(kf>nf) return(iLow(sy,tf,i));
               if(kf>nf) return(i);
           }
        }
      if(mode==MODE_UPPER)
        {
         f=iFractals(sy,tf,MODE_UPPER,i);
         if(f!=0) 
           {
            kf++;
//            if(kf>nf) return(iHigh(sy,tf,i));
               if(kf>nf) return(i);
           }
        }
     }
   Print("GetFractalBar(): Фрактал не найден");
   return(-1);
  }

Result

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=3 FrUpz=24.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=2 FrUpz=17.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=1 FrUpz=13.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp3=24.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp2=17.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp1=13.0

Need to show the developers. Something is not right in the functions

 

I noticed that the code

Print(ChartID()," ",ChartGetInteger(ChartID(),CHART_HEIGHT_IN_PIXELS,0))

placed in the indicator produces strange results. For example, if the chart tab is open, to which the indicator has been reset, the results of the main chart window height are correct.

However, as soon as I leave the "native" chart the result for some reason becomes equal to 75 (of course, in other cases the results may be different), but the Chart ID value remains the same.

When I return to the "native" graph, the height values become correct.

A big request to the developers and those "in the know" to explain what the peculiarity is here. Is it really the way it was intended?! I don't believe it!

If this is the case, please suggest the code that gives the correct height value for the native chart when any tab is open.
 
Vinin:

Added explicit initialisation of all variables

Result

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=3 FrUpz=24.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=2 FrUpz=17.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: z=1 FrUpz=13.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp3=24.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp2=17.0

2014.02.17 21:50:09.462 TestFr GBPUSD,H1: # FrUp1=13.0

Need to show the developers. Something is not right in the functions

Thank you for paying attention to my question. It turns out that the cause was only because two variables in the function were not explicitly initialized. I'll have to look through all Kim's functions and fix it.
 

Good afternoon.

The EA code involves I.Kim's f-i. Which involves calling the "mounted" libraries. The code after the "external paremeters" is provided:

//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>

However, accidentally (after the same update of mt4 - EA does not work) I noticed a strange entry in the "EA properties" window, "dependencies" tab:

Can you please tell me what this error means and how to fix it (if both libraries are still present in the Include folder)? What does the Libraries folder have to do with it?

 
Rita:

Good afternoon.

The EA code involves I.Kim's f-i. Which involves calling the "mounted" libraries. The code after the "external paremeters" is provided:

However, accidentally (after the same update of mt4 - EA does not work) I noticed a strange entry in the "EA properties" window, "dependencies" tab:

Can you please tell me what this error means and how to fix it (if both libraries are still present in the Include folder)? What does the Libraries folder have to do with it?


stderror.mqh imports ErrorDescription function from stdlib.ex4 library, which is located in the Libraries folder, together with the source. Check if you have this file there, if not, get it from any other terminal.
 

Both folders (Incloud and Libraries) contain stdlib sources. Just in case, I added-copied from the Incloud folder.

But the error described above is still displayed in the "dependencies" tab. Maybe somehow change the calling of these functions: Instead of:

//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>

Set the call in some other way?

Or will it be impossible to use I.Kim's functions in the latest version of mt4 now?

 
Rita:

Both folders (Incloud and Libraries) contain stdlib sources. Just in case, I added-copied from the Incloud folder.

But the error described above is still displayed in the "dependencies" tab. Maybe somehow change the calling of these functions: Instead of:

Set the call in some other way?

Or will it be impossible to use I.Kim's functions in the latest version of mt4 now?


Make sure that there is stdlib.ex4 executable file in Libraries folder, although it seems to be not Kim's, it is a standard file from delivery.


Alternatively, see what the Kim function takes from it and work out what's wrong.

Reason: