Errors, bugs, questions - page 2826

 

Hello. I hope I chose the right branch.

The visual tester almost never creates the window of the indicator used by the EA, no errors are generated and everything else works.

The indicator appears and is rendered only if I open Sleep(1) in the EA's initializer.

What may be the problem?

I cannot use Sleep() becauseChartWindowFind(0, short_name) of the custom indicator stops working on the left side of the chart.

Here is a simple example with which I have a problem:

int MACDHandle=INVALID_HANDLE;
double macd_value[];

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   MACDHandle=iMACD(_Symbol,0,12,26,9,PRICE_CLOSE);
//Sleep(1);
   ArraySetAsSeries(macd_value, true);
//--- Нужно проверить, не были ли возвращены значения Invalid Handle
   if(MACDHandle<0)
     {
      Alert("Ошибка при создании индикатора MACD - номер ошибки: ",GetLastError(),"!!");
      return(-1);
     }
   else
     {
      Print("MACD инициализирован, handle: ", MACDHandle);
      return(INIT_SUCCEEDED);
     }
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- Освобождаем хэндлы индикаторов
   IndicatorRelease(MACDHandle);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   CopyBuffer(MACDHandle, 0, 0, 1, macd_value);
   Print("macd_value: ", macd_value[0]);
  }
//+------------------------------------------------------------------+
mt5 build 2572
 
fxsaber:

That's the workaround I was considering, thank you. That seems to be the only way.

I don't know if anything has changed, but at the time of writing this article this code works in a universal way:

FileOpen(filename, FILE_READ | FILE_TXT | FILE_ANSI, 0, CP_UTF8);
Синтаксический анализ MQL средствами MQL
Синтаксический анализ MQL средствами MQL
  • www.mql5.com
Суть программирования заключается в формализации и автоматизации неких процессов с помощью языков общего или специального назначения. Торговая платформа MetaTrader позволяет применять программирование для решения самых разных задач трейдера, благодаря встроенному языку MQL. И обычно процесс программирования строится на анализе и обработке...
 
Can you suggest a way to find out the kernel number in the EA being tested? There is no such thing in MQL API, but I think someone did a parsing of agent's path - it's not clear how unified folders are in Tester there.
 
Stanislav Korotky:
Can you suggest a way to find out the kernel number in an EA under test. There's no such thing in MQL API, but I think someone did a parsing of agent's path - it's not clear how unified folders are in Tester there.

https://www.mql5.com/ru/forum/1111/page2660#comment_15183572

 

Thanks, I'll give it a try. However, the port number can also be five digits (and technically less than 4 digits, although they are considered as reserved for standard services), so I will correct the extraction method for myself.

 

Good day!

Suppose I run an EA in debug mode while developing it. The default value of one of the input variables has just been changed in the code. Its run-time value, however, is inserted from the previous strategy tester input set.

The question is "why the hell is this happening? The hell with no synchronization, but why does the debug mode prioritize the set over the code?

Как в MetaTrader 5 быстро разработать и отладить торговую стратегию
Как в MetaTrader 5 быстро разработать и отладить торговую стратегию
  • www.mql5.com
Скальперские автоматические системы по праву считаются вершиной алгоритмического трейдинга, но при этом они же являются и самыми сложными для написания кода. В этой статье мы покажем, как с помощью встроенных средств отладки и визуального тестирования строить стратегии, основанные на анализе поступающих тиков. Для выработки правил входа и...
 
Nikolai Karetnikov:

Good day!

Suppose I run an EA in debug mode while developing it. The default value of one of the input variables has just been changed in the code. Its run-time value, however, is inserted from the previous strategy tester input set.

The question is "why the hell is this happening? To hell with the lack of synchronisation, but why does debug mode prioritise the set over the code?

In short, just consider this feature.

 

Share info, what are the sizes of EX5 files of combat trading EAs?

I have(one (unsigned) trading logic) without any explicit or implicit(static arrays) resources and without GUI ~1250Kb (EX4 - 450Kb). At the same time, Tester version (without real-world wrapper) is ~250Kb.

 
fxsaber:

Share info, what is the size of the EX5 file of combat trading EAs?

150kb without indicators