Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 961

 
Yevhenii Levchenko:

What do I have to say: does it happen and is it also due to some kind of cracks in the quotes or am I writing something wrong?

Do you want me to tell you that the MT4 tester is not working correctly? - You won't hear your screenshot with errors in ticks or bars - the tester will generate everything from any possible low TF

the developers have always answered questions like yours - write the codes correctly!

i showed you an example of how to write your code.... i can't see it, and it's not interesting :))) - busy, reading articles, I'll get to work on my codes

 
Igor Makanu:

Do you want me to tell you that the MT4 tester is not working correctly? - You won't hear your screenshot with errors in ticks or bars - the tester will generate everything from any possible low TF

the developers have always answered questions like yours - write the codes correctly!

i showed you an example of how to write your code.... i can't see it, and it's not interesting :))) - busy, reading articles, I'll get to work on my codes

Okay! Thank you

 
Yevhenii Levchenko:

Okay! Thank you

Might come in handy: https://www.mql5.com/ru/forum/165405#comment_5602248

Архивные котировки от Metaquotes
Архивные котировки от Metaquotes
  • 2017.01.02
  • www.mql5.com
Ситуация: В терминале MT4 по клавише F2 можно закачать архивные котировки. Они нужны всем, кто разрабатывает свою торговую систему...
 

Good afternoon, comrades. I'm learning to write simple things in mql4, now I'm trying to work with arrays. I can't understand the error in this piece of code:

   double d1 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, MaxLimit, 0)],4);
   double d2 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, MaxLimit, 0)],4);
   double CrossBarsNum[][2];
   for (double d = d1; d <= d2; d += 0.0001)
     {
       double a = 0.0;
       for(int i = 0; i < MaxLimit; i++)
           if(d > Low[i] && d < High[i])
               a+=1;
               CrossBarsNum[(d-d1)/0.0001,0] = d;
               CrossBarsNum[(d-d1)/0.0001,1] = a;

It's crashing on the last two lines with the wording integer expression expected. As far as I understood, an index in an array can be set using a formula. It is needed to search through the array strings and sequentially record the quotes and the number of bars containing such a quote. The formula gives an integer value (from 0 and higher in increments of one), so what is the error?

 
Azat0t:

Good afternoon, comrades. I'm learning to write simple things in mql4, now I'm trying to work with arrays. I can't understand the error in this piece of code:

It's crashing on the last two lines with the wording integer expression expected. As far as I understood, an index in an array can be set using a formula. It is needed to search through the array strings and sequentially record the quotes and the number of bars containing such a quote. The formula returns an integer value (from 0 and higher in steps of one), so what is the error?

Make the array index an int type, not double. The array index should be an integer.

 
Sergey Basov:

Might come in handy: https://www.mql5.com/ru/forum/165405#comment_5602248

Thank you! I've pretty much always done that. After loading, I pressed "Refresh" - the quotes were different. I forgot that I had set time limit for robot's work. :)
 
Azat0t:

Good afternoon, comrades. I'm learning to write simple things in mql4, now I'm trying to work with arrays. I can't understand the error in this piece of code:

It's crashing on the last two lines with the wording integer expression expected. As far as I understood, an index in an array can be set using a formula. It is needed to search through the array strings and sequentially record the quotes and the number of bars containing such a quote. The formula returns an integer value (from 0 and higher in steps of one), so where is the error?

Use an explicit type conversion

               CrossBarsNum[int((d-d1)/0.0001),0] = d;
               CrossBarsNum[int((d-d1)/0.0001),1] = a;
 
Thanks, I fixed the error, but still no result: the array doesn't fill up. What can this be connected to?
   int handle;
   handle = FileOpen("FindLevels.txt", FILE_CSV|FILE_WRITE, '\t');
   double d1 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, MaxLimit, 0)],4);
   double d2 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, MaxLimit, 0)],4);
   double CrossBarsNum[][2];
   for (double d = d1; d <= d2; d += 0.0001)
     {
       double a = 0.0;
       for(int i = 0; i < MaxLimit; i++)
           if(d > Low[i] && d < High[i])
               a++;
               CrossBarsNum[int((d-d1)/0.0001),0] = a;
               CrossBarsNum[int((d-d1)/0.0001),1] = d;
     } 
   FileWrite(handle, CrossBarsNum[11,1], d, d1, d2, a, ArraySize(CrossBarsNum));
   //FileWriteArray(handle, CrossBarsNum, 0, WHOLE_ARRAY);
   FileClose(handle);
   return(0);
Variables d, d1, d2 work exactly
 
Azat0t:
Thanks, I fixed the error, but still no result: the array is not filled. What can this be connected to? Variables d, d1, d2 work exactly
Your array size is always zero in the first dimension. I didn't see ArrayResize() anywhere
 
Azat0t:
Thanks, I fixed the error, but still no result: the array is not filled. What can this be about? Variables d, d1, d2 work exactly

Don't forget to put

#property strict
Fix all the errors and maybe everything will work out. Learn to use the debugger. With step-by-step execution all problems are revealed.