Questions from Beginners MQL5 MT5 MetaTrader 5 - page 730

 
Artyom Trishkin:
bars[]
If you can, please show me the code.
 
Vitaly Muzichenko:

Called itBars, the compiler is scolding it to the skies. Have you tested this design, or just assumed it should work, or am I doing something wrong?

Yes, my mistake. Name it. In general, the idea is to give expressive names to variables, then you won't need to create additional variables, whose existence is not always justified.
 
Vasiliy Sokolov:
Yes, my mistake. Name it. In general, the idea is to give expressive names to variables, then you won't need to create additional variables, the existence of which is not always justified.

I didn't call it to express something, but to reduce code when working with them:

if(open1<close1 && close2>close3 && close1>close2 &&

And the rest in the same way, otherwise the length of the lines increases

Thanks to all for clarifications!

 
Vitaly Muzichenko:

I didn't name it to express something, but to reduce code when working with them:

if(open1<close1 && close2>close3 && close1>close2 &&

And the rest in the same way, otherwise the length of the lines increases

Thank you all for clarifications!

If you want to reduce the code to a minimum, make reference directly to the data array

//+------------------------------------------------------------------+
//|                                                       test09.mq5 |
//|                                                   Sergey Gritsay |
//|                         https://www.mql5.com/ru/users/sergey1294 |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link      "https://www.mql5.com/ru/users/sergey1294"
#property version   "1.00"

MqlRates bars[]; // массив для хранения данных цен OHLC
int start_bar=0; // с какого бара копируем
int count_bar=4; // сколько баров копируем
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ArraySetAsSeries(bars, true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(CopyRates(Symbol(),PERIOD_CURRENT, start_bar, count_bar, bars)<count_bar) return;
  
   if(bars[1].open<bars[1].close && bars[2].close>bars[3].close && bars[1].close>bars[2].close)
   {
  
   }
  }
//+------------------------------------------------------------------+

...
 

Good afternoon!

Where and how to correctly delete placed orders and open positions when unloading (deleting) an Expert Advisor? If it is not difficult, please share an example.

Thank you.

 

One of the EAs is having some strange nonsense. Tests the EA normally, clicking on "Run single test" only runs one single, first time. Then, when you click on the single test or click on any line in the Optimization, it shows in the Journal:

2017.02.08 13:31:05.165 Tester cannot get inputs for pass 4234087422336

2017.02.08 13:31:34.829 Tester cannot get inputs for pass 4076312468706

2017.02.08 13:31:47.973 Tester cannot get inputs for pass 1004506640527

The other EAs behave normally. What could it be?

 

Gentlemen, recording a huge 10000*10000 matrix

      if(count==0)
        {
         //--- запишем файл
         ResetLastError();
         int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
         //---
         if(handle!=INVALID_HANDLE)
           {
            for(int z=ARRAY_SIZE_Y; z>0; z--) // Перебор по барам, колонка Y
              {
               for(int q=0; q<ARRAY_SIZE_X; q++) // Перебор по периоду, колонка X
                 {
                  arra[q]=sm.d[q].m[nBar-z];                // M(I) SMA              
                 }
         //--- запишем данные массива в конец файла FileTell IsFileLineEnded
               FileSeek(handle,0,SEEK_END);
               FileWriteArray(handle,arra);
              }
            FileClose(handle);
           }
         else
            Print("Failed to open the file, error ",GetLastError()," handle ",handle);
        //---
         count=1;
        }

How do you think this algorithm is efficient in terms of speed?

Because when the matrix is 1000*1000 the speed is a few seconds, when increasing to 10000*10000 the system gets up

 
Top2n:

Gentlemen, recording a huge 10000*10000 matrix

      if(count==0)
        {
         //--- запишем файл
         ResetLastError();
         int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
         //---
         if(handle!=INVALID_HANDLE)
           {
            for(int z=ARRAY_SIZE_Y; z>0; z--) // Перебор по барам, колонка Y
              {
               for(int q=0; q<ARRAY_SIZE_X; q++) // Перебор по периоду, колонка X
                 {
                  arra[q]=sm.d[q].m[nBar-z];                // M(I) SMA              
                 }
         //--- запишем данные массива в конец файла FileTell IsFileLineEnded
               FileSeek(handle,0,SEEK_END);
               FileWriteArray(handle,arra);
              }
            FileClose(handle);
           }
         else
            Print("Failed to open the file, error ",GetLastError()," handle ",handle);
        //---
         count=1;
        }

How do you think this algorithm is efficient in terms of speed?

Because when the matrix is 1000*1000 the speed is a few seconds, when increasing to 10000*10000 the system gets up

How can you get such a matrix if no more than four-dimensional arrays are allowed?
Is there any confusion?
Документация по MQL5: Операции с массивами
Документация по MQL5: Операции с массивами
  • www.mql5.com
Операции с массивами - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:
How is it possible to get such a matrix if no more than four-dimensional arrays are allowed?
Isn't there any confusion?

Isn't 10000 x 10000 a two-dimensional matrix?

double arr[10000][10000];

and all that...

 
Alexey Viktorov:
How is it possible to get such a matrix if no more than four-dimensional arrays are allowed?
Is there any confusion?
Yeah, it's two-dimensional, so I'm not saying it right, I'm saying it's not a matrix, but an array. Does a matrix imply multidimensionality?