Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1185

 
odyn:

Hi Connoisseurs!

Here is the code :

struct STRUCT_POSITION {\...\}

STRUCT_POSITION SPosition[];

Question:

What is STRUCT_POSITION SPosition[]; ? If it's creating an instance of the structure, why is it a dynamic array? Is it really possible to do this? Why?


I will be very grateful to you for your answer.

Declaring the struct STRUCT_POSITION {\...\} structure is the creation of a user-defined data type. And STRUCT_POSITION SPosition[]; is declaring a variable of the user type. The fact that the variable is an array is indicated by square brackets [] You can declare several variables of the custom type just like any other type.

double a, b[];

STRUCT_POSITION Pos, SPosition[];// при условии, что структура уже создана.
In this entry type, variable,array
 
Good day to all, time of day.
On one of my android devices, MT5 stopped working
It just stopped working. Didn't change anything, didn't configure anything.
It looks like the screenshot.
I have Internet, everything else works.
I have a demo account only.
Sorry if I'm in the wrong place.
 

Is there any utility (like WatchDog) for restarting MT5.


Suppose MT5 has closed due to some error. How can I remotely trace this immediately and restart MT5.

I am using MT4bar for MT4. Need something similar for MT5.

 

Good afternoon.

I'm trying to make a universal base class to always define and call an object of the same class.

And I am making two solutions for testing news. I have a base class CNewsFilter and two inherited CNewsFilterLive and CNewsFilterTester. I want to define a CNewsFilter object in my code. And it will automatically select a class depending on which mode is running. But something does not work. Here is a base class, I left only Init() method for example.

//+------------------------------------------------------------------+
//| News Filter Class                                                |
//+------------------------------------------------------------------+
class CNewsFilter
  {
protected:
   //---
public:
                     CNewsFilter(void);
                    ~CNewsFilter(void);
   virtual bool      Init(string,int);
   virtual void      Deinit(void);                    
   virtual bool      CheckNews(ENUM_NEWS_TYPE &type);
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CNewsFilter::Init(string symbol_name,int magic_number)
  {
   return true;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#ifdef __MQL5__//MQL_TESTER || MQL_VISUAL_MODE
#include <NewsFilterTester.mqh>
#else
#include <NewsFilterLive.mqh>
#endif

An inherited class:

//+------------------------------------------------------------------+
//| News Filter Class                                                |
//+------------------------------------------------------------------+
class CNewsFilterTester : public CNewsFilter
  {
protected:
public:
                     CNewsFilterTester(void);
                    ~CNewsFilterTester(void);
   virtual bool      Init(string,int);
   virtual void      Deinit(void);                    
   virtual bool      CheckNews(ENUM_NEWS_TYPE &type);
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CNewsFilterTester::CNewsFilterTester() :  m_delimiter('\t')
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CNewsFilterTester::~CNewsFilterTester(void)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CNewsFilterTester::Init(string symbol_name,int magic_number)
  {
   // some code
   return true;
  }

And then I call it in my EA code:

#include <NewsFilter.mqh>
....
CNewsFilter    news_filter;

news_filter.Init(Symbol(),MagicNumber);

When debugging, it never gets into an inherited class CNewsFilterTester, which should get into according to the base class directive, which I added to the end of the base class code. __MQL5__ is here only as an example. How to do it with the tester is another question. So far, the idea itself does not work - methods of the inherited class are not called. When Init() is called, it does not go to Init() of the inherited class - in this example CNewsFilterTester. Help, please.

#ifdef __MQL5__//MQL_TESTER || MQL_VISUAL_MODE
#include <NewsFilterTester.mqh>
#else
#include <NewsFilterLive.mqh>
#endif
 
leonerd:

Good afternoon.

I'm trying to make a universal base class to always define and call an object of the same class.

And I am making two solutions for testing news. I have a base class CNewsFilter and two inherited CNewsFilterLive and CNewsFilterTester. I want to define a CNewsFilter object in my code. And it will automatically select a class depending on which mode is running. But something does not work. Here is a base class, I left only Init() method for example.

An inherited class:

And then I call it in my EA code:

When debugging, it never gets into an inherited class CNewsFilterTester, which should get into according to the base class directive, which I added to the end of the base class code. __MQL5__ is here only as an example. How to do it with the tester is another question. So far, the idea itself does not work - methods of the inherited class are not called. When Init() is called, it does not go to Init() of the inherited class - in this example CNewsFilterTester. Please help.

Here

#include <NewsFilter.mqh>
....
CNewsFilter    news_filter;

news_filter.Init(Symbol(),MagicNumber);

you create a base class object. Accordingly - you have a base class everywhere.

 

How to write a condition correctly :

like this

if(((MASlowHandle - PBid) > 0.0002) && ((MASlowHandle - MAFastHandle) > 0.0002))

or like this:

if((MASlowHandle - PBid) > 0.0002 && (MASlowHandle - MAFastHandle) > 0.0002)

??

 
odyn:

How to write a condition correctly :

like this

or like this:

??

It doesn't really matter. You can even write it this way.

if(MASlowHandle - PBid > 0.0002 && MASlowHandle - MAFastHandle > 0.0002)

Arithmetical operations take precedence over logical ones.

But if there are both && and || in the condition, it is preferable to separate them with brackets to make it easier to understand.

 
Alexey Viktorov:

It's not a matter of principle. You can even put it this way

The priority of arithmetic is higher than that of logic.

But if the condition has both && and ||, it is preferable to divide it by parentheses to make it easier to understand.

Thanks for the answer!

 

What is the reason I can't publish the code?

I always get a message:

Code review completed with errors:
Errors detected during code verification Trading Statistics Real Time Report.
https://www.mql5.com/en/code/28074/230766

But I don't understand the reason for the code publishing error.

Please answer me on this.

What is the problem, at least it should be highlighted.

 
jaffer wilson:

What is the reason I can't publish the code?

I always get a message:

Code check completed with errors:
Errors detected during code check Trading Statistics Real Time Report.
https://www.mql5.com/en/code/28074/230766

But I don't understand the reason for the code publishing error.

Please answer me on this.

What is the problem, at least it should be highlighted.

Where is the question? What exactly are the errors? Sorry, all the telepaths are on holiday.

Click