Errors, bugs, questions - page 1177

 
svds75:

Hello. Can you tell me why when I query the properties of a trendline, the variable res is always true, although I manually set the flag to show only W1, or only MN1?

It needs to be shown only on one of the halves.

...get... - is getting properties. And if res=true, it is only an indication of successful property fetching.

To set the properties, use ...set...

 

As a continuation of my previous post, I managed to find the problem area causing the bug using the scientific method.

We have such a library with the function:

//---- testbuglib.mq5 ------

#property library

class A { }; class B   { private:    A* a; public:    A* b; }; int Test() export {   return 0; }

Here is the main file:

#include <Files\File.mqh>  // тут можно указать любой файл mqh

#import "testbuglib.ex5"
  int Test();
#import  

int OnInit() {  Test(); return 0; }

The resulting Expert Advisor does not work and displays in the log: "EX5 loading failed".

Files:
TestBug.mq5  1 kb
 
svds75:

Hello. Can you tell me why the variable res is always true when requesting the trendline properties, although I manually set the flag to show only W1, or only MN1?

I want it to be shown only on one of the halves.

Incorrect number of parameters, you are calling the function as 1 option and should be calling it as 2 or comparing the result.
 
TheLiteShadow:
That's true, but does it mean that with each new bar all the last "indexes" of the given buffers must be "cleaned"? The question is why? In MT4 there was no such a situation, I understand, during the initialization I had cleaned it, but then it should be done by MT itself, by the same token, in the initialization it should be done by MT and not by the programmer, for what purpose the indicator buffer is simply a memory allocation I do not quite understand...
When I asked this question some years ago, I was told that this is done for optimization purposes. You initialize exactly as much as you need. And if you fill in some calculation data right away, you don't have to pre-write zeros at all. MT5 is different from MT4 in many ways.
 
marketeer:
When I asked this question a few years ago, I was told that it was for optimisation purposes. You initialise exactly as much as you need. And if you fill in some calculation data right away, you don't need to pre-write zeros at all. MT5 is different from MT4 in many ways.
The fact that MT4 is different from MT5 is understood by everyone, but I would not agree about the optimization, and the programmer has too much to keep track of in addition, not comparable to low-level languages, but to me it is superfluous, in general, it is clear, thanks...
 
TheLiteShadow:
Incorrect number of parameters, you are calling the function as 1 option and you should be calling it as 2 or comparing the result.
Tried it this way too. Although flags really work (line only shows on one time), and Expert Advisor sees that both flags are enabled.
long res;
ObjectGetInteger(0,"line",OBJPROP_TIMEFRAMES,OBJ_PERIOD_W1|OBJ_PERIOD_MN1,res);
if((bool)res) Alert("линия line показывается на OBJ_PERIOD_W1 и OBJ_PERIOD_MN1");
 
svds75:
Tried it this way. Although, real flags work (line is shown only on one timeframe), Expert Advisor sees that both flags are enabled.

What do you actually want? You are asking for visibility on weekly OR monthly timeframes. So the program will return true if at least one of them is on.

Request it separately in 2 calls.

 
svds75:
Tried it this way too. Although real flags work (line only shows on one half) and EA sees that both flags are enabled.

So maybe you need to set the visibility directly?

 ObjectSetInteger(0,"line",OBJPROP_TIMEFRAMES,OBJ_PERIOD_W1);
 
svds75:

Hello. Can you tell me why the variable res is always true when requesting the trendline properties, although I manually set the flag to show only W1, or only MN1?

I want it to be shown only on one of the halves.

Because the line always exists, it always reads the value. Invisible line does not mean there is no line.
 
barabashkakvn:

So maybe you need to set the visibility directly?

No, I need to set the visibility manually and check it programmatically.
Reason: