Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 600
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This is not a telepathic club. You haven't attached your code, so it's up to you to decide where to place delete.
Wrong.
Well, here is the code, what else do you need? What if it is incorrect?
Thank you.
You've got it all mixed up. Incorrect planning of the task is exactly what leads to these consequences.
If objects are created in a class, it must delete them in its destructor upon completion. Other classes, on the other hand, before getting a pointer to an object, should check its validity. And in principle there shouldn't be such an intertwined relationship. It's a bit of a tangle. Complicated doesn't mean quality. Everything should be transparent and traceable. First and foremost - for you.
Let's show the code instead.
Here, I'm reading some data from a file at the program's start.
That is, I create a CCandleCondition *candle_cond object at iteration and then add it to the candles_one_rules collection.
Here is the AddCondition method of the CCandlesOneRules class:
CCandleRule is just a container class for conditions. I add conditions to rules and rules to CCandlesOneRules, which in turn to CCandlesOneRules....
But this while loop fails on start and crashes with out of memory error. And there aren't too many of these conditions, only 7 are read before stopping. If we reduce the number of data in the read file, it works, without any errors, undeleted objects and so on.
Let's have a better show of the code.
I'm starting to lose patience.
Where is the definition of Add method?
Judging by the code you have a complete lack of understanding of what you are doing.
I'm starting to lose patience.
Where is the definition of the Add method?
Judging by the code you have a complete misunderstanding of what you are doing.
CCandleOneRules, CCandlesOneRules, CCandleRule are all classes inherited from CArrayObj.
Judging by your generic answers, you just don't understand my questions. On array with CArrayObj you still haven't answered the right way. Once again I will repeat that problem. There is a class, in the class method global objects of the class are added to the array (object of type CArrayObj), which is declared there in this method. In this method some actions are performed in this array. Upon completion, the array object is not needed, the array members are needed. How to get rid of this array object correctly, keeping the array members? If you don't get rid of it, you will get a message like undeleted objects in the log. I gave you my solution; you said it incorrectly. How is it correct? How can I place delete in OnDeinit (or in Deinit method of class which will be called from OnDeinit), if this array object is visible only within class method?
Moreover, if objects are deleted only in OnDeinit, you can also run into out of memory...
Hello colleagues.
Please help me with this question. Where should I use the ArraySetAsSeries() function to specify the order of elements numbering in the indicator buffer? In the indicators, which are preinstalled in the terminal, I have often noticed that it is used inside OnCalculate(). But the indicator buffer is declared globally. Isn't it logical to use ArraySetAsSeries() inside OnInit() for a single call in this case? Or because of replenishment of the indicator buffer with new elements the order of numeration can be lost and it is necessary to call ArraySetAsSeries() each time inside OnCalculate()? I want to write an optimal code without unnecessary function calls, when it is not necessary. I will be grateful for help.
Hello colleagues.
Please help me with this question. Where should I use the ArraySetAsSeries() function to specify the order of elements numbering in the indicator buffer? In the indicators, which are preinstalled in the terminal, I have often observed that it is used inside OnCalculate(). But the indicator buffer is declared globally. Isn't it logical to use ArraySetAsSeries() inside OnInit() for a single call in this case? Or because of replenishment of the indicator buffer with new elements the order of numeration can be lost and it is necessary to call ArraySetAsSeries() each time inside OnCalculate()? I want to write an optimal code without unnecessary function calls, when it is not necessary. I will be grateful for help.
IMHO, I would write indicators without these functions at all (if from zero, of course). For buffers - in OnInit(), for timeseries - in OnCalculate().
And to talk about optimal code, you need to know how long this function takes to execute. So, the profiler should go first, and only then performance questions.
IMHO, I would write indicators without these functions at all (if from scratch, of course). But for buffers - in OnInit(), for timeseries - in OnCalculate().
And, in order to talk about optimal code, you need to know how long this function takes to execute. So, the profiler should go first, and only then the performance questions.
That's the conclusion I was leaning towards. Thanks for the tip.
Good afternoon. I have a question: why, when I apply the bolinger bars to the MACD, I take the values of the signal line and not the histogram itself?
Good afternoon. I have a question: why when I apply the bolinger bars to MACD, I take the values of the signal line and not the histogram itself?
Do you have the possibility to specify which graphical buffer to use for calculation?