I'm trying to figure out my counter and rewrite it in classes, but I still can't output the working parallel functions. I think m_pause should be declared differently. How should it be done correctly?
#ifdef __MQL4__#endif
//+------------------------------------------------------------------+//| Счётчик |//+------------------------------------------------------------------+class CCounter
{
private:
//--- Шаг счётчикаint count;
//--- Счётчик int chekcount;
//--- int m_pause;
public:
//--- Проверяет прохождение указанного временного интервала int CheckCounter(constint pause);
void ZeroCounter(void){count=0;chekcount=0;}
};
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int CCounter::CheckCounter(constint pause)
{
m_pause=pause;
count++;
Print(" Class count= ",count);
Print(" Class pause= ",pause);
Print(" Class m_pause= ",m_pause);
if(count>=chekcount+m_pause)
{
chekcount=count;
}
return(chekcount);
}
//+------------------------------------------------------------------+
I'm trying to figure out my counter and rewrite it in classes, but I still can't output the working parallel functions. I think m_pause should be declared differently. How should it be done correctly?
And there must be two CCounter objects - each for its counter.
Not sure what you mean by "two CCounter objects". I read the article https://www.mql5.com/ru/articles/351, it says "Once loaded, the class becomes an object". Does it mean I'll have to make copies of classes for each counter? So it turns out the same copies with different names that I can do without classes? The goal was to get rid of copying using classes, because I need more than a hundred of them. I was told that it's possible to do it with a class, so I started messing around with classes. Or what am I saying about "two CCounter objects"?
Stuck, it seems to me, in such a simple place. What to do with global int chekcount=0; int count=0; in case I want to run several counter() functions in parallel?
Just use a class or make copies of functions with different names.
На самом деле все намного проще. Чтобы пользоваться ООП вовсе не нужно знать, что означают эти слова - можно просто использовать предоставляемые ООП возможности, даже не зная как они называются. Но все же, надеюсь, в процессе прочтения статьи все желающие не только научатся использовать ООП в достаточной мере, но и разъяснят себе значения этих...
Not sure what you mean by "two CCounter objects". I read the article https://www.mql5.com/ru/articles/351, it says "Once loaded, the class becomes an object". Does it mean I'll have to make copies of classes for each counter? So it turns out the same copies with different names that I can do without classes? The goal was to get rid of copying using classes, because I need more than a hundred of them. I was told that it's possible to do it with a class, so I started messing around with classes. Or what am I saying about "two CCounter objects"?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I'm trying to figure out my counter and rewrite it in classes, but I still can't output the working parallel functions. I think m_pause should be declared differently. How should it be done correctly?
I'm trying to figure out my counter and rewrite it in classes, but I still can't output the working parallel functions. I think m_pause should be declared differently. How should it be done correctly?
You need to check it in the timer.
And there should be two CCounter objects - each for a different counter.
The timer has to be checked.
Thanks, but I don't understand why the timer needs to check? For every tick the Expert Advisor accesses the CCounter and counts the ticks "count++".
Thanks, but I don't understand why the timer needs to be checked? For every tick, the EA accesses the CCounter and counts the ticks "count++".
So it's not in the timer...
And there must be two CCounter objects - each for its counter.
Not sure what you mean by "two CCounter objects". I read the article https://www.mql5.com/ru/articles/351, it says "Once loaded, the class becomes an object". Does it mean I'll have to make copies of classes for each counter? So it turns out the same copies with different names that I can do without classes? The goal was to get rid of copying using classes, because I need more than a hundred of them. I was told that it's possible to do it with a class, so I started messing around with classes. Or what am I saying about "two CCounter objects"?
Stuck, it seems to me, in such a simple place. What to do with global int chekcount=0; int count=0; in case I want to run several counter() functions in parallel?
Just use a class or make copies of functions with different names.
Not sure what you mean by "two CCounter objects". I read the article https://www.mql5.com/ru/articles/351, it says "Once loaded, the class becomes an object". Does it mean I'll have to make copies of classes for each counter? So it turns out the same copies with different names that I can do without classes? The goal was to get rid of copying using classes, because I need more than a hundred of them. I was told that it's possible to do it with a class, so I started messing around with classes. Or what am I saying about "two CCounter objects"?
Only use a class, or make copies of functions with different names.
Just create as many class objects as you need. And use each one for your counting.
Thank you, I will read what this CArrayObj is and try to figure it out. :)
How do I create a one-dimensional array of the prices of all open orders? This is probably a very simple question for you, but please advise)
How do I create a one-dimensional array of the prices of all open orders?
Go through all the orders in a loop and write the open prices into the array.
Go through all the orders in the loop and write the opening prices in the array.
Thank you!