Errors, bugs, questions - page 2898

 

Message to developers. Python script hangs when receiving data via copy_rates_from_pos under certain circumstances.

Let me explain the situation. The broker has about 4k instruments.
I do primary selection of the instruments by searching and filtering them according to certain rules.

On one of the instruments in the terminal there is no history (i.e., in the market watch and in the list of symbols, the instrument is present, but the data is empty).

When trying to execute the script: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 1, analysis_days),
the script just hangs. It doesn't help to try or check for None as the error itself doesn't occur, everything hangs on this line.

If I try to execute: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 0, analysis_days),
, i.e. specify the starting bar number from 0, it does not hang and returns an empty table.

Addendum. I also found a similar problem when I FIRST retrieve data via copy_rates_from_pos with the number of bars requested, more than there is in the history. Also the script hangs. There is no such error on second request. That's why it seems to be difficult to repeat the error (perhaps, only by deleting the entire history for the symbol).

I may be wrong or have missed something, but it seems to be a bug since the function should either return the data or make an error.

 
Alexander Mikheev:

Dear developers, if I am mistaken or have not considered something, please correct me.

Do you want someone to take the time to write a source code based on your data and test it on different trade servers?

It is not going to happen. Respect other people's time: fully provide data to reproduce the problem - source, server, machine configuration and so on.


The source is concise and with comments, so that you don't waste time parsing what was written there. Tell what you wanted to get and what you got.

 
fxsaber:

A password-protected ZIP archive.

Are locked archives supported in MQL?

 
Stanislav Korotky:

Are locked archives supported in MQL?

I don't know.

 
suncrypto:

Message to developers. Python script hangs when receiving data via copy_rates_from_pos under certain circumstances.

Let me explain the situation. The broker has about 4k instruments.
I do primary selection of the instruments by searching and filtering them according to certain rules.

On one of the instruments in the terminal there is no history (i.e., in the market watch and in the list of symbols, the instrument is present, but the data is empty).

When trying to execute the script: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 1, analysis_days),
the script just hangs. It doesn't help to try or check for None as the error itself doesn't occur, everything hangs on this line.

If I try to execute: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 0, analysis_days),
, i.e. specify the starting bar number from 0, it does not hang and returns an empty table.

Addendum. I also found a similar problem when I FIRST retrieve data via copy_rates_from_pos with the number of bars requested, more than there is in the history. Also the script hangs. There is no such error on second request. That's why it seems to be difficult to repeat the error (perhaps, only by deleting the entire history for the symbol).

Perhaps I was mistaken about something or missed something, but it seems to be a bug since the function must either return the data or make an error.

Reproduced, corrected.

 
TesterHideIndicators(false) has stopped working;
 
suncrypto:

Message to developers. Python script hangs when receiving data via copy_rates_from_pos under certain circumstances.

Let me explain the situation. The broker has about 4k instruments.
I do primary selection of the instruments by searching and filtering them according to certain rules.

On one of the instruments in the terminal there is no history (i.e., in the market watch and in the list of symbols, the instrument is present, but the data is empty).

When trying to execute the script: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 1, analysis_days),
the script just hangs. It doesn't help to try or check for None as the error itself doesn't occur, everything hangs on this line.

If I try to execute: rates_d1 = mt5.copy_rates_from_pos(curSymbol.name, mt5.TIMEFRAME_D1, 0, analysis_days),
, i.e. specify the starting bar number from 0, it does not hang and returns an empty table.

Addendum. I also found a similar problem when I FIRST retrieve data via copy_rates_from_pos with the number of bars requested, more than there is in the history. Also the script hangs. There is no such error on second request. That's why it seems to be difficult to repeat the error (perhaps, only by deleting the entire history for the symbol).

I may be wrong or have missed something, but it seems to be a bug since the function should either return the data or make an error.

Fixed, will be in the next beta
 
Aleksey Vyazmikin:
TesterHideIndicators(false) stopped working;

TesterHideIndicator sets the visibility flag for indicators that are created afterwards.

It does not change the visibility flag of previously created indicators.

You can check with the following expert

//+------------------------------------------------------------------+
//|                                     TestTesterHideIndicators.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

int ExtHandleMacd;
int ExtHandleEma;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   TesterHideIndicators(true);
   ExtHandleMacd=iMACD(NULL,0,12,26,9,PRICE_CLOSE);
   TesterHideIndicators(false);
   ExtHandleEma=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  }
//+------------------------------------------------------------------+

In the visualizer and in the chart opened after the simple test, MACD indicator is not visible, the Moving Average is visible

So, it works as intended

Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Видимость объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Видимость объектов
  • www.mql5.com
Комбинация флагов видимости объекта определяет таймфреймы графика, на которых объект отображаем. Для установки/получения значения свойства OBJPROP_TIMEFRAMES можно использовать функции ObjectSetInteger()/ObjectGetInteger...
 
DMITRII PECHERITSA:
Bug - inconsistent operation of pointers (5.00, 2650)

Compilation error. Any thoughts?



Use the dereference statement explicitly

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   C201022_090654 c_1(* new C201022_090641); //works
   C201022_090654 c_3(* new C201022_092325(1)); //works
//---'new' - parameter passed as reference, variable expected
   C201022_090654 c_2(* new C201022_090641(1)); //not works
                      ^
  }
 

A100:
Ошибка при компиляции:

typedef void (*fn)();
void f() {}
fn g() { return f; }
oid OnStart()
{
        g()(); //Error: ')' - expression expected
}

Previously researched this question, this is what I found:

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Sergey Dzyublik, 2020.04.04 21:46

Bug MT5(build 2375) compilation error when calling a function via its pointer, when an array of pointers to a function is used:

#define  PRINT(x) ; Print(#x, ":", string(x))

void test(){
   PRINT(__FUNCSIG__);
}

template<typename T>
void call(T f_ptr){
   f_ptr();
}


template<typename T>
class A{
public:
   T arr_1[1];
   
   typedef void (*ff)();
   ff arr_2[1];  
   
   
   T test_1(){
      return arr_1[0];
   } 
   
   ff test_2(){
      return arr_2[0];
   } 
   
   T operator[](int index){
      return arr_1[index];
   }
};

void OnStart(){
   typedef void (*ff)();
   ff arr[1];
   arr[0] = test;   
   
   ff f_ptr = arr[0];
   f_ptr();             //Ok
   call(arr[0]);        //Ok
   arr[0]();            //Compile Error: ')' - expression expected   
   
   
   A<ff> a;             
   a.arr_1[0] = test;
   a.arr_2[0] = test;
   
   
   a.arr_1[0]();        //Compile Error: ')' - expression expected   
   a.arr_2[0]();        //Compile Error: ')' - expression expected   
   
   a.test_1()();        //Compile Error: ')' - expression expected   
   a.test_2()();        //Compile Error: ')' - expression expected   
   
   a[0]();              //Ok ???
}