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

 
Mihail Matkovskij:

But it will take a lot of tweaking before this code can be used in real trading...

Yes, I understand. It's unlikely to come to full automatic trading at all. You need to thoroughly test your trading ideas over a long period of time with a large number of deals.

Without the tester it is impossible to check an idea qualitatively, which is unfortunate. Optimization of strategy parameters is also unfortunate. The tester makes the process very easy.

 
Alexey Viktorov:

I never thought I'd have to quote you on the documentation...

... ... the closing time of the order is 0...

Thanks, I didn't think so either. I haven't often, but I've had to sample a ticket and never had a problem, probably because I've cycled through those in the market.

 
Igor Makanu:
Alexey Viktorov:

Thank you!

 

Hello. Trying to find calculation errors in the indicator. Outputs a Close[0] value (used below) via Alert. Outputs a number with 4 decimal places, the broker has five digits.

Alert(Close[0]);

What i am doing wrong? Thank you.

 
Oleg Bondarev:

Hello. Trying to find calculation errors in the indicator. Outputs a Close[0] value (used below) via Alert. Outputs a number with 4 decimal places, the broker has five digits.

What i am doing wrong? Thank you.

And where did you get Close[0] from? It would be interesting to have a look at the source code, as you are not on a psychic forum... :)

 

Hello, help me find a way out - problem!

#define           Pmax 1200   //размер массива по периоду
double           ExtBuffer[];

//+------------------------------------------------------------------+
//| Структура для хранения данных Фибо                               |
//+------------------------------------------------------------------+
struct PosFib
  {
   double            period[Pmax]; 
  };

int OnCalculate(const int rates_total,....)
{
   PosFib BP[Pmax];
   
   for(int p=2; p<Pmax; p++) // отбор по периодам
      for(int b=prev_calculated>Pmax?prev_calculated:Pmax; b<rates_total; b++)
        {
         BP[b].period[p]=sm.d[p-1].m[b];
        }

   return(rates_total);
}

When compiling, it gives a warning - the size of local variables is too large (more than 512kb)

How critical is this warning?


 
Top2n:

Hello, help me find a way out - problem!

When compiling, it gives a warning - the size of local variables is too large (more than 512kb)

Please advise how to bypass this situation!

int OnCalculate(const int rates_total,....)
{
   PosFib BP[];
   ArrayResize(BP, Pmax);
....

SZY: it is convenient to use Indicator buffers for calculations (INDICATOR_CALCULATIONS), if you have problems, use them instead

 
Igor Makanu:

Thank you

 

Good day to you all!

Question on MQL-4.
There is function ArrayBsearch( S_L,Ask,WHOLE_ARRAY,0,MODE_ASCEND);. It searches for an element of a pre-sorted array. If the array is two dimensional then this function searches only for an element in the first dimension.

Q. Which function or language construct can be used to find the required element in the second dimension of the array? I have a two-dimensional array with two rows

10,9,8,7,6,5,4,3,2,1

10,3,8,9,2,1,1,8,8,6
How can I find the array element with the value I want in the bottom line, not the top one? Because ArrayBsearch( ) searches only in the top row.
Thanks for your help.

 
ANDREY:

Good day to all!

Question on MQL-4.
There is function ArrayBsearch( S_L,Ask,WHOLE_ARRAY,0,MODE_ASCEND);. It searches for an element of a pre-sorted array. If the array is two dimensional then this function searches only for an element in the first dimension.

Q. Which function or language construct can be used to find the required element in the second dimension of the array? I have a two-dimensional array with two rows

10,9,8,7,6,5,4,3,2,1

10,3,8,9,2,1,1,8,8,6
How can I find the array element with the value I want in the bottom row instead of the top row? Because ArrayBsearch( ) searches only in the top row.
Thanks for the help.

In MQL4, I have only this way:

//+------------------------------------------------------------------+
//|                                                  FindInArray.mq4 |
//|                                       Copyright 2020, © Cyberdev |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, © Cyberdev"
#property version   "1.00"
#property strict

#property script_show_inputs

#define  size1 2 
#define  size2 10

input double value1 = 3;
input double value2 = 8;

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart() {
  double array[size1][size2] = {
    {10,9,8,7,6,5,4,3,2,1}, 
    {10,3,8,9,2,1,1,8,8,6}
  };
  
  double bufer[size2];
  
  int i;
  
  int index;
  
  string str;
  
  i = 0;
  for(; i < size2; i++) {
    bufer[i] = array[0, i];
  }
  
  ArraySort(bufer, WHOLE_ARRAY, 0, MODE_ASCEND);
  
  index = ArrayBsearch(bufer, value1, WHOLE_ARRAY, 0, MODE_ASCEND);
  
  str = "";
  
  i = 0;
  for(; i < size2; i++) {
    array[0, i] = bufer[i];
    str += (string)array[0, i] + ((i != size2 - 1) ? ", " : "");
  }
  
  Print("array[0]: {" + str + "}");
  
  Print("value1 array[0]["+(string)index+"]: ", array[0][index]);
  
  
  i = 0;
  for(; i < size2; i++) {
    bufer[i] = array[1, i];
  }
  
  ArraySort(bufer, WHOLE_ARRAY, 0, MODE_ASCEND);
  
  index = ArrayBsearch(bufer, value2, WHOLE_ARRAY, 0, MODE_ASCEND);
  
  str = "";
  
  i = 0;
  for(; i < size2; i++) {
    array[1, i] = bufer[i];
    str += (string)array[1, i] + ((i != size2 - 1) ? ", " : "");
  }
  
  Print("array[1]: {" + str + "}");
  
  Print("value2 array[1]["+(string)index+"]: ", array[1][index]);
}
//+------------------------------------------------------------------+

Result:

2020.07.08 09:25:41.426 FindInArray AUDUSD,M30: value2 array[1][6]: 8.0

2020.07.08 09:25:41.426 FindInArray AUDUSD,M30: array[1]: {1, 1, 2, 3, 6, 8, 8, 8, 9, 10}

2020.07.08 09:25:41.426 FindInArray AUDUSD,M30: value1 array[0][2]: 3.0

2020.07.08 09:25:41.426 FindInArray AUDUSD,M30: array[0]: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}


Files:
Reason: