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

 

HistorySelect is a very expensive function. But HistorySelectByPosition is even more expensive.

For example, if you need to find the first deal of the closed position, you can act in two ways

  1. Make HistorySelectByPosition and then find the necessary deal from the obtained small list. But this list is formed as follows First of all ALL history is formed (equivalent to the call of the "infinite" HistorySelect). Then there is a complete cycle forwards through the list, and only those deals are selected, which have an appropriate POSITION_IDENTIFIER.
  2. Make HistorySelect (you can "infinite", but it's better to use an interval, if known), then in the for loop make a break, when you reach the corresponding DEAL_ENTRY.

The second item could be much cheaper. But certainly not more expensive.

Calling HistorySelect*-functions in the tester is almost a waste of computing resources. Therefore you should always try to minimize their number. Especially HistorySelectByPosition.

 
For Hedge accounts in the tester
Activation check for regular limiters on the next tick.
This means that the result of the tester depends very much on the type of account.
 
fxsaber:
For Hedge accounts in the testerThis means that the tester result depends very much on the type of account.


As it turned out in one of the neighboring threads, the tester result even depends on whether the testing is done on a local agent or on one of the distributed network agents.

https://www.mql5.com/ru/forum/1111/page1880#comment_4904481

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • www.mql5.com
Форум алго-трейдеров MQL5
 
Yury Kirillov:


As it turned out in one of the neighboring threads, the result of the tester even depends on whether the testing takes place on a local agent or on one of the agents of a distributed network.

https://www.mql5.com/ru/forum/1111/page1880#comment_4904481

You described a BAG, which is not in the context of this thread. The difference in the execution of limiters is the official position.
 
fxsaber:
You described BAG, which is not in the context of this thread. The difference in the execution of limiters is the official position.

I agree, I just wanted to note that the tester is becoming more and more unpredictable tool.
 
Yury Kirillov:

I agree, I just wanted to note that the tester is becoming an increasingly unpredictable tool.
It has never been predictable, unfortunately.
 
fxsaber:
This means that the result of the tester depends very much on the type of account.
This only applies to stock instruments.
 
All standard types are set to each other
void OnStart()
{
  string Str = "1.23qwedfg";
  
  Print((int)Str);
  Print((double)Str);
}

Result

1
1.23
 

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

fxsaber, 2017.04.10 16:53

Dear developers, how to get rid of Warnings in this situation?
template <typename T>
T GetValue()
{
  T Res; // possible use of uninitialized variable 'Res'
  
  return(Res);
}

void OnStart()
{
  MqlTick Tick = GetValue<MqlTick>();
  int i = GetValue<int>();
}
Lifehack
template <typename T>
const T GetDefaultValue( void )
{
  struct STRUCT_TYPE
  {
    const T Value;
  };
  
  const STRUCT_TYPE Res = {0};
  
  return(Res.Value);
}

void OnStart()
{
  int i = GetDefaultValue<int>();
  MqlTick Tick = GetDefaultValue<MqlTick>();
  string Str = GetDefaultValue<string>();
}
 

Rudiment functions (not needed)

  • StringToDouble
  • StringToInteger
  • StringToTime
  • StringToColor
  • StringAdd
  • StringConcatenate
  • GetPointer

Reason: