Errors, bugs, questions - page 1153

 
joo:
The video in the forum posts does not play. in place of video empty space. tried many browsers. device - Lenovo K900.
Video plays fine on the youtube site. and on other youtube sites video plays....
Let's check.
 
Renat:
How do you run a program installed in Windows 8.1? With /portable?
No. I usually run it without /portable. Not only that, but to make sure, I installed and uninstalled MT5 twice. After deinstalling, I manually deleted folders in AppData as well.
 

If working in Windows 8.1 as a normal user, the MT5 terminal does not remember the account numbers entered. Also MetaEditor does not save MQL5 Storage state. This can only be fixed if you work as an administrator or if "Run this program as administrator" is selected in the metaeditor64.exe and terminal64.exe file properties.

But in this case, when running under a regular user account, I have to enter the administrator's password - is this correct, considering security issues?

P.S. The terminal is the latest - but the problem is not new.


 

Good afternoon.

I have quite a resource-intensive indicator (which is calculated from 7+ arrays), it loads normally only "intermittently" in the terminal, I don't know for what reason. No errors in it, it's something with MT5 terminal itself...

I would like to test it in the tester, but in the tester it keeps giving error: I attached a screenshot.

Please advise, is there any possibility to process the error before the start of the tester and forcibly reload the indicator in the tester, if it appears?

 
M1k3:

Good afternoon.

I have quite a resource-intensive indicator (which is calculated from 7+ arrays), it loads normally only "intermittently" in the terminal, I don't know for what reason. No errors in it, it's something with MT5 terminal itself...

I'd like to test it in the tester, but in the tester it keeps giving me an error: I attached a screenshot.

Please advise, is there any way to handle the error before the start of the tester and forcibly reload the indicator in the tester, if it appears?

.

The error is in your code, not in the terminal. There's even a hint where to look for the error: line 302, position 49. This error is an array out of its range. For example, you have an array with size [4], but you are trying to get value [5].
 
barabashkakvn:
The error is in your code, not in the terminal. There is even a hint where to look for the error: line 302, position 49. This error is an array exit from its range. For example, you have an array with size [4], but you are trying to get value [5].

I can't fix it, the array is filled with quotes (100%) or indicator values. In the terminal at a certain moment the value of quotes or indicators X outputs NULL, and at another moment it outputs a normal value (not on the 0th bar). I do not know why it happens.

The NULL value is always present in the tester. The error occurs when I try to multiply a quote or indicator value, but there NULL.

 
M1k3:

I can't fix it, the array is filled with quotes (100%) or indicator values. In the terminal at a certain moment of time the value of quotes X gives NULL, and at another moment it gives a normal value (not on the 0th bar). I do not know why it happens.

The NULL value is always present in the tester. The error occurs when I try to multiply a quote or indicator value, but there NULL.

Use code debugging or insert Print() operators in doubtful code sections. This way you will understand where the error is.
 
barabashkakvn:

This code is the code from the indicator and the OnInit() function. Accordingly, OnInit() is processed at the moment of terminal start - and this code correctly displays tick price. It is OnInit() and not init() - like yours. If the error repeats, please send the code and the terminal version.

The error is that you are trying to receive market information (MarketInfo...) in OnInit() from the indicator. The indicator has no trading functions and therefore, during initialization it is not waiting for update of account and market information.

To get market data, use OnInit() of the EA, not the indicator.

If you want to use the market information in the indicator, you should enter a flag (bool) and check the correctness of the account information (Account...) in the OnCalculate() function in the case of the first run or in OnInit() if you change timeframe or indicator settings.

Do not mislead people. Regardless of whether you use init() or OnInit() of the indicator, the terminal doesn't guarantee that this handler will be called when the login has already been performed and the tick value is known. So it's easy to get zero in OnInit as well. Also there is no prohibition on the use of market information in indicators. But in this case we really have to transfer the initialization to the calculation part of the indicator and execute it on the first ticks.
 
marketeer:
Do not mislead people. Regardless of whether the init() or OnInit() of the indicator is used, the terminal doesn't guarantee that this handler will be called when the login is done and the tick value is known. So it's easy to get zero in OnInit as well. Also there is no prohibition on the use of market information in indicators. But in this case we really have to transfer the initialization to the calculation part of the indicator and execute it on the first ticks.

There are no trading functions in the indicator. The Expert Advisor has trade functions. Therefore, when the EA calls the market environment and/or account information, everything goes correctly in OnInit().

To prove my words, here is a simple EA in which OnInit() refers to the trading environment and to the account information:

//+------------------------------------------------------------------+
//|                                                  test_expert.mq4 |
//|                              Copyright © 2014, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  //--- выведем всю информацию, доступную из функции AccountInfoDouble()
      printf("ACCOUNT_BALANCE =  %G",AccountInfoDouble(ACCOUNT_BALANCE));
      printf("ACCOUNT_CREDIT =  %G",AccountInfoDouble(ACCOUNT_CREDIT));
      printf("ACCOUNT_PROFIT =  %G",AccountInfoDouble(ACCOUNT_PROFIT));
      printf("ACCOUNT_EQUITY =  %G",AccountInfoDouble(ACCOUNT_EQUITY));
      printf("ACCOUNT_MARGIN =  %G",AccountInfoDouble(ACCOUNT_MARGIN));
      printf("ACCOUNT_FREEMARGIN =  %G",AccountInfoDouble(ACCOUNT_FREEMARGIN));
      printf("ACCOUNT_MARGIN_LEVEL =  %G",AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));
      printf("ACCOUNT_MARGIN_SO_CALL = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL));
      printf("ACCOUNT_MARGIN_SO_SO = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_SO));
      //--- MarketInfo
      Print("Symbol=",Symbol());
      Print("Минимальная дневная цена=",MarketInfo(Symbol(),MODE_LOW));
      Print("Максимальная дневная цена=",MarketInfo(Symbol(),MODE_HIGH));
      Print("Время поступления последней котировки=",(MarketInfo(Symbol(),MODE_TIME)));
      Print("Последняя поступившая цена предложения=",MarketInfo(Symbol(),MODE_BID));
      Print("Последняя поступившая цена продажи=",MarketInfo(Symbol(),MODE_ASK));
      Print("Размер пункта в валюте котировки=",MarketInfo(Symbol(),MODE_POINT));
      Print("Количество цифр после запятой в цене инструмента=",MarketInfo(Symbol(),MODE_DIGITS));
      Print("Спрэд в пунктах=",MarketInfo(Symbol(),MODE_SPREAD));
      Print("Минимально допустимый уровень стоп-лосса/тейк-профита в пунктах=",MarketInfo(Symbol(),MODE_STOPLEVEL));
      Print("Размер контракта в базовой валюте инструмента=",MarketInfo(Symbol(),MODE_LOTSIZE));
      Print("Размер минимального изменения цены инструмента в валюте депозита=",MarketInfo(Symbol(),MODE_TICKVALUE));
      Print("Минимальный шаг изменения цены инструмента в пунктах=",MarketInfo(Symbol(),MODE_TICKSIZE));
      Print("Размер свопа для ордеров на покупку=",MarketInfo(Symbol(),MODE_SWAPLONG));
      Print("Размер свопа для ордеров на продажу=",MarketInfo(Symbol(),MODE_SWAPSHORT));
      Print("Календарная дата начала торгов (фьючерсы)=",MarketInfo(Symbol(),MODE_STARTING));
      Print("Календарная дата окончания торгов (фьючерсы)=",MarketInfo(Symbol(),MODE_EXPIRATION));
      Print("Разрешение торгов по указанному инструменту=",MarketInfo(Symbol(),MODE_TRADEALLOWED));
      Print("Минимальный размер лота=",MarketInfo(Symbol(),MODE_MINLOT));
      Print("Шаг изменения размера лота=",MarketInfo(Symbol(),MODE_LOTSTEP));
      Print("Максимальный размер лота=",MarketInfo(Symbol(),MODE_MAXLOT));
      Print("Метод вычисления свопов=",MarketInfo(Symbol(),MODE_SWAPTYPE));
      Print("Способ расчета прибыли=",MarketInfo(Symbol(),MODE_PROFITCALCMODE));
      Print("Способ расчета залоговых средств=",MarketInfo(Symbol(),MODE_MARGINCALCMODE));
      Print("Начальные залоговые требования для 1 лота=",MarketInfo(Symbol(),MODE_MARGININIT));
      Print("Размер залоговых средств для поддержки открытых ордеров в расчете на 1 лот=",MarketInfo(Symbol(),MODE_MARGINMAINTENANCE));
      Print("Маржа, взимаемая с перекрытых ордеров в расчете на 1 лот=",MarketInfo(Symbol(),MODE_MARGINHEDGED));
      Print("Размер свободных средств, необходимых для открытия 1 лота на покупку=",MarketInfo(Symbol(),MODE_MARGINREQUIRED));
      Print("Уровень заморозки ордеров в пунктах=",MarketInfo(Symbol(),MODE_FREEZELEVEL)); 
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
Files:
 
barabashkakvn:

There are no trading functions in the indicator. The Expert Advisor has trade functions. Therefore, when the EA calls the market environment and/or account information, everything goes correctly in OnInit().

To prove my words, here is a simple Expert Advisor that OnInit() calls the market environment and account information:

Well, the question was originally about the indicator. And you were answering about the OnInit of indicator. Expert Advisor is another matter, there is no problem there, but the Expert Advisor cannot replace an indicator.
Reason: