Errors, bugs, questions - page 730

 

Can you advise how to solve the problem?
After the first run of the Expert Advisor in the tester (Read=false), a csv file with statistics is created.
In int OnInit() the following code:

  ResetLastError();
  if(Read)
  {
    filehandle=FileOpen(FileName,FILE_READ|FILE_CSV);
  }
  else
  {
    filehandle=FileOpen("razdvigka.csv",FILE_WRITE|FILE_CSV);
  }
The created file is stored in directory: tester\Agent\MQL5\Files

However, at second run (Read=true). We need to read data from this file, but the file is deleted.

 
Vitya:

Can you advise how to solve the problem?
After the first run of the Expert Advisor in the tester (Read=false), a csv file with statistics is created.
In int OnInit() the following code:

The created file is stored in directory: tester\Agent\MQL5\Files

However, at second run (Read=true). We need to read data from this file, but the file is deleted.

In this case you need to create a file with flag FILE_COMMON. The file will be created in the shared folder of the terminal.
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Состояние клиентского терминала - Документация по MQL5
 
tol64:
In this case you need to create a file with the flag FILE_COMMON. The file will be created in the terminal's shared folder.
filehandle=FileOpen(FileName,FILE_READ|FILE_CSV|FILE_COMMON);
Thank you.
Got it figured out.
 
Rosh:
Check out ChartIndicatorAdd
Thank you!
 
Servicedesk, is application #359447 groping or have you tried in vain?
 
x100intraday:
Servicedesk, is application #359447 being groped or have you tried for nothing?
There's a lot of discussion going on. But no answer is ready yet.
 

If we assume that this is the indicator), the first time the date will be displayed, but the next settings on the chart (second, third copy) will not display the date.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
    Print(TimeCurrent());
   
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &Time[],
                const double &Open[],
                const double &High[],
                const double &Low[],
                const double &Close[],
                const long &TickVolume[],
                const long &Volume[],
                const int &Spread[])
{
  
  
  
  return(rates_total);
  
}
 
Karlson:

If we assume this is the indicator), it will display the date for the first time, but the next settings in the chart (second, third copy) will not display the date.

Now the calculation part of the indicator is deleted from mql space with a delay.

if you apply the same indicator (with the same parameters) to different (but the same symbol/timeline) charts - there will be no re-initialization.

If after deleting last copy go for a smoke - then there will be reinitialization at startup.

Such side effect of optimization. :)

Note: Smoking is bad for YOUR HEALTH !

;)

 

Dear programmers,

Tell me, what in the mql5 program code affects the speed most of all? The matter is that while creating my own program and increasing the code volume, I have faced the fact that its speed has decreased significantly. Although, the more code-intensive standard Expert Advisors from the Advisors and Examples folder are much faster.

In general, is there an article or explanation of how to better format the code structure on the forum? Give a piece of advice to a novice programmer. Thank you!

 
Alex5757000:

Dear programmers,

Tell me, what in the mql5 program code affects the speed most of all? The matter is that while creating my own program and increasing the code volume, I have faced the fact that its speed has decreased significantly. Although, the more code-intensive standard Expert Advisors from the Advisors and Examples folder are much faster.

In general, is there an article or explanation of how to better format the code structure on the forum? Give a piece of advice to a novice programmer. Thanks!

IMHO, nested loops affect speed the most. Nested loops up to the third depth is practically a limit, beyond which you have to be very careful about the size of the loops. I'll take my P4 for example: it's running at 3Hz, I'm getting ~10k operations per second.

This number means, that triple nested cycles 1000x1000x10 will be executed in 1 sec, if you understand, if the 3rd cycle is increased to 100 you get 10 sec.

Reason: