Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 862

 

Speaking of cubes!

Can you tell me how to erase an unnecessary "cube"?

 
im-zvv:

Speaking of cubes!

Can you please tell me how to erase an unnecessary "cube"?

To do this, you need to know in which position this "cube" is, how many bytes it occupies, rewrite a file pointer there and write a new value in that place.

Consequently, if strings have different lengths, it is simply not realistic. It will not be possible to calculate how many bytes to the required "cube".

 
Alexey Viktorov:

To do this, you need to know in which position this "cube" is and how many bytes it occupies, then wrap the file pointer there and write the new value in that place.

Consequently, if strings have different lengths, we just can't do it. It will be impossible to calculate how many bytes to the right "cube".

Obviously, all these calculations will increase the processing time.

I will look for other methods.

Thank you.

 
Alexey Viktorov:

To do this, you need to know in which position this "cube" is and how many bytes it occupies, rewrite a file pointer there and write a new value in this place.

Consequently, if strings have different lengths, it simply cannot be done. It will be impossible to calculate how many bytes to the desired "cube".

If it is not crucial and you can use WinApi, then I think the task can be solved via FileMapping.

 

I will try everything. I will start by creating an "empty" file, with abstract variables for the reserve. Then I'll replace it with the data I get.

Maybe it'll work. The only problem is the size of the file. It might get bigger. I will have to create a new backup before each read.

 
Looking for articles on the use ofnew operator in mql4, can you advise such articles? Who can briefly explain why classes are needed if there are functions and global variables, I've watched a lot of videos and read the help many times and still don't understand what's the point?
 
Seric29:
Looking for articles on the use ofnew operator in mql4, advise such articles? I have seen many video clips and read the help file many times, but I don't understand what's the point?

the new operator in MQL is only needed to create a pointer to an object instance


MQL programs are quite specialized and OOP is mainly suitable for encapsulation, I gave an example ofCWorkTime class abovehttps://www.mql5.com/ru/forum/160683/page861#comment_11840254

it's convenient to use encapsulation to make several instances of time-limit object, like this:

int OnInit()
{
   Work1=new CWorkTime(StartHour_1,StartMinute_1,StopHour_1,StopMinute_1);
   Work2=new CWorkTime(StartHour_2,StartMinute_2,StopHour_2,StopMinute_2);
}

.....


void OnTick()
  {

if(Work1.Disable() || Work1.Disable())
{
 Comment("Не торговое время!!!");
 }
else
{......

i.e., in my example, you can now specify 2 intervals of EA's working time

SZY: read - search forum articles section "Objects".

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2019.05.26
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 
Igor Makanu:

It's clear that to a greater extent classes compose data variables and functions, and to the remaining extent probably do something powerful if I understand correctly, because everything can be organized by functions, maybe classes work faster than functions, you get faster access to data, I read forums writing that they use memory more evenly and economically and all that.

 

Why doesn't this code work?

#property version   "1.00"
#property strict
string iComments="\n 
 class CArray : public Cobject 
{
public:
    double m_Array[100];
}//дальше в OnInit()
 {Carray *arr = new CArray;
   arr.m_Array[22] = 1.23456;

....
}

Maybe the class should be described with a colon ::? The idea is to create a pointer that points to another pointer.

 

Hello!

Thanks again toAlexey Viktorov for the tip on the quotes - everything works. This Monday we have a situation - Germans have traded, while Englishmen have a day off. It turned out that in condition for euro position opening old values of pound were used. Hence the request: advise how to set check in the code that both symbols are traded on this day?

Thank you.

Reason: