Features of the mql5 language, subtleties and tricks - page 60

fxsaber  
Alexey Kozitsyn:
I don't know what GUI you are talking about, but on the parameters tab of the tester window you can set the start and stop fields. And the tester correctly determines the number of parameter values.

The pitch.

[Deleted]  
fxsaber:

Field step.

Sorry, didn't read it carefully.
[Deleted]  
fxsaber:

Step field.

Probably the reason is that enumeration fields can be given eigenvalues, which may not be a multiple of any step.

fxsaber  
Alexey Kozitsyn:

Probably the reason is that the enumeration fields can be set eigenvalues, which may not be a multiple of any step.

Yes, it's not a bug, that's why we started talking about it in this thread. The step of optimization, if needed, can be set through MQL for enum.

fxsaber  

Forum on trading, automated trading systems and testing trading strategies

Libraries: TesterBenchmark

fxsaber, 2017.11.22 16:54

Inserting just one line in each of the MT5 variants

#define Comment(A)

Full-fledged accelerated by 67%, artisanal accelerated by 108%!


But that's not the main point. We managed to speed up our EAs with one line! And this is in the Optimizer where Comment doesn't play any role.

fxsaber  
// Возвращает true только в случае, если выбран (в тестере) режим по реальным тикам
// Перед использованием должен быть хотя бы один OnTick вызван тестером
bool IsRealTicks( void )
{
  MqlTick Tick;
  
  return(SymbolInfoTick(_Symbol, Tick) && (Tick.volume || !(Tick.flags & TICK_FLAG_LAST)));
}


Example of usage.

// Советник будет тестироваться только в режиме по реальным тикам
void OnTick()
{
  static bool IsRemove = true;
  
  if (IsRemove)
  {
    IsRemove = MQLInfoInteger(MQL_TESTER) && !IsRealTicks();
    
    if (IsRemove)
    {
      Print("Real ticks mode is needed!");
      
      ExpertRemove();
      
      return;
    }
  }
  
  //........
}
I don't know how to do it in OnInit (without OnTick).
fxsaber  

A snippet from the dialogue on the mentioned topic

fxsaber2017.11.24 08:35
Don't use expressions in print (or comment) parameters. Specify parameters separated by commas. Then for sure all string conversions will be overridden

Could you explain with an example how these two strings are different in Optimize mode?

Print((string)i + (string)d);
Print(i, d);
Support Team2017.11.24 08:44

When optimizing in the first case, a string expression will be calculated before the print. The print itself will be called, but it will not work.

In the second case, Print will be called, but it won't work. And the i+d string conversion will not work either.

In simple testing, the results of the first and second calls will be the same in terms of both time and output received.

That is, it is much cheaper to use Print with commas for optimization modes than to form a single input parameter for it as a string.


On the other hand, if you form everything as a single line right inside Print, it is easy to disable its formation in Optimize mode through

#define Print(A)

but such a construction will not work if commas are used. Moreover, such a construction will disable it in Optimize mode, too

Print(SendOrder()); // SendOrder будет проигнорирован при #define Print(A)


Therefore (and for other reasons) it is better not to call really important functions inside Print. In the end, if you care about performance in Optimize mode, you still need to do something like this

static const bool IsNotOptim = !MQLInfoInteger(MQL_OPTIMIZATION);

if (IsNotOptim)
{
  const string Str = GetString(); // дорогой вызов
  
  Print(Str);
//  Comment(Str); 
//  Alert(Str);
}
Vladislav Andruschenko  
fxsaber:

A snippet from the dialog on the mentioned topic

I.e. it is much cheaper to use Print with commas for Optimize modes than to form a single input parameter as a string for it.


On the other hand, if you form everything as a single line right inside Print, it is easy to disable its formation in optimization mode through

but such a construction will not work if commas are used. Moreover, such a construction will disable it in Optimize mode, too


Therefore (and for other reasons) it is better not to call really important functions inside Print. As a result, if you care about performance in Optimize mode, you'll still need to do something like this

Sorry, maybe I don't understand, why call important functions in print?
fxsaber  
Vladislav Andruschenko:
I'm sorry, maybe I don't understand, but why call important functions in print?

It's not forbidden.

Vladislav Andruschenko  
fxsaber:

It is not forbidden.

I agree.

I just wanted to know what is the point?

I'm currently facing a problem with more than 1000 trades in the history and when calling the history processing function, for example, to calculate the profit of the history. + When you call the function of history processing, for example, calculate the profit of the current trades - the information on the chart starts to slow down and the terminal hangs. I.e. quotes come with a delay.