Errors, bugs, questions - page 1499

 
Alexey Kozitsyn:
The road to programming hell is paved withglobalvariables" (Steve McConnell)
Only an example of the absence of this warning is shown. Creating a variable as global or local is a matter of programmer taste and experience.
 
Ilyas:
A warning about no real use of local and global variables (simple type or "complex" without constructors) will be added, but the priority of this task is low.
Understood, thanks. Just in case, I'll try to get the developers' attention here.
 
Alexey Kozitsyn:
One activation per PC. It does not matter how many terminals there are.
Is there any confirmation anywhere ?
 
Vladimir Pastushak:
Is there any confirmation anywhere ?

Buyer acquires the right to activate the Product as many times as specified by Vendor at the time of purchase or rental of the Product. For example, if 20 activations are allowed for the Product at the time of purchase, Buyer will be able to install it on 20 different hardware configurations, even if Seller subsequently reduces this number.

https://www.mql5.com/ru/market/rules

Правила покупки торговых роботов, индикаторов, книг и журналов в MetaTrader Market
Правила покупки торговых роботов, индикаторов, книг и журналов в MetaTrader Market
  • www.mql5.com
Общие положения и правила пользования сервисом Market
 
This post automatically reduces the resolution of the picture by as much as 6 times the size (bytes) of the original. Why?
 
Alexey Kozitsyn:
Slawa, good afternoon, can you comment on the library (question above)?

That's the way to fix it.

long CChart::Open(const string symbol_name,const ENUM_TIMEFRAMES timeframe)
  {
   m_chart_id=ChartOpen(symbol_name,timeframe);
   if(m_chart_id==0)
      m_chart_id=-1;
   return(m_chart_id);
  }
 
Slawa:

That's the way to fix it

Yes, thank you, that's optimal. For the library. What about error 4024?
 
Slawa:

That's the way to fix it.

What is the point of doing this? The standard library must be used not as the user pleases, but in strict accordance with the ideology of its structure.Alexey Kozitsyn uses it incorrectly and that's why he gets a lot of bugs in the output. You just need to attach the chart to the object of class using Attach method after you have created CCart object. This method is overloaded and can attach both, the current chart and the needed one. Your change to the Open method will kill the ability to work with the current chart.

And the request to the developers of the standard library - please make a description of the structure of the library. Many do not understand it and begin to make mistakes, and you go along with them, begin to break everything that has been done.

 
Alexey Kozitsyn:

Question on the standard MT4 library.

Chart.mqh file

I want to open chart. I use method Open(const string symbol_name,const ENUM_TIMEFRAMES timeframe).

1. If you use an unavailable symbol, the ChartOpen() function will return error #4024 - internal error. No doubt, the error may be an internal one, but there is a much more exact error code - #4106 - an unknown symbol. Perhaps we should change the returned error code? Since 4024 doesn't tell the developer anything about where to look for the error.

2. In the case of failure, ChartOpen() assigns the value 0 to the m_chart_id field, i.e. it turns out that we start working with the current chart, but this is not correct, because we have failed to open the desired chart for work. Consequently, if we don't call the Detach() method, the current chart will simply close after work. I also think this is not the right approach. The ChartOpen() function would better return -1 in case of an error.

Before working with a chart, it needs to be attached to a class object using the Attach method !!! If you do not want to work with the current chart ( 0 ) then implement this check and prohibit using the current chart in your work.

And what does it mean to work with the chart and not close it using the Detach method to exit? Is it really difficult to write one line in the destructor of your classes or in OnDeinit? Work with objects must be strictly controlled, then you can avoid mistakes.

 
coderex:

What is the point of doing this? The standard library should be used not as the user wants, but in strict accordance with the ideology of its structure.Alexey Kozitsyn doesn't use it correctly and that's why he gets a lot of bugs in the output. You just need to attach the chart to the object of class using Attach method after you have created CCart object. This method is overloaded and can attach both, the current chart and the needed one. Your change to the Open method will kill the ability to work with the current chart.

And the request to the developers of the standard library - please make a description of the structure of the library. Many people don't understand it and start making mistakes, and you are following their lead and starting to break everything you've done.

I clearly wrote above what is the point of doing it. If there is an error when opening chart (for example, if you set invalid symbol), then, for some reason, by analogy with the Attach(void) method, the Open() method will bind current chart identifier to the object. Why should it do that? If I want to work with the current chart, I will call the Attach(void) method { m_chart_id=ChartID(); } and that's all. But here I've got an obviously erroneous situation where for some reason I start working with the wrong thing. In general, it's a problem with ChartOpen() function itself, but since they won't change it, at least let it be changed in the library.

Another argument. Please think logically. The method is called Open(). It implies that something new will be opened! And we will start working with this new item. But here we are working with the old one. I do not see any logic. And you seem to use this inaccuracy for your own purposes.

This method is overloaded and can bind both the current chart and the needed one. And your change to the Open method will kill the ability to work with the current chart.

What will it kill? You will still have the Attach() method, it will continue to do what it was doing. As you have said, check the return ID of the Open() function and if it is less than 0, call the Attach(void) method. That's all. I just do not understand why you need to make such a mess, if you can just call the Attach(void) method and attach the current chart.

Perhaps I don't understand you. Then give me an example.

Please also ask the developers of the standard library to make a description of the library's structure. Many people don't understand it and start making mistakes, and you go along with them and start breaking everything you've done.

What a loud statement... Don't think that you are smarter than others, you may not be.
Reason: