Libraries: Easy Canvas - page 16

 

Greetings, Nikolay.

While using the library I encountered a problem: if several programmes with iCanvas are used in one terminal, then after reloading the terminal the images start to change spontaneously from one to another. At first I looked for reasons in my code, but found nothing. Then one of my clients accidentally noticed that iCanvas object names coincide on different charts.

I looked at how the object name is generated for iCanvas and found the following:

Name+=IntegerToString(GetTickCount());

This way of loading the terminal leads to the same object names on different charts, if we are talking about Expert Advisors, because all Expert Advisors in the terminal receive the same GetTickCount() value when loading. Indicators do not have such a problem.

To solve the problem, I propose this method of generating a unique object name:

   Name += IntegerToString(ChartID()) + IntegerToString(GetTickCount());

Here uniqueness is guaranteed by the following considerations:

  1. Indicators get different GetTickCount() values even if all of them are launched on the same chart. Therefore, this method works for them.
  2. Expert Advisors get the same GetTickCount() value, but since an Expert Advisor can only be on one chart, its object gets uniqueness due to the chart identifier.
 
Ihor Herasko using the library I encountered a problem: if several programmes with iCanvas are used in one terminal, then after reloading the terminal the images start to change spontaneously from one to another. At first I looked for reasons in my code, but found nothing. Then one of my clients noticed by chance that the names of iCanvas objects coincide on different charts.

I looked at how the object name is generated for iCanvas and found the following:

This way of loading the terminal leads to the same object names on different charts, if we are talking about Expert Advisors, because all Expert Advisors in the terminal receive the same GetTickCount() value when loading. Indicators do not have this problem.

To solve the problem, I suggest this method of generating a unique object name:

Here uniqueness is guaranteed by the following considerations:

  1. Indicators get different GetTickCount() values even if they are all run on the same chart. Therefore, this method works for them.
  2. Expert Advisors get the same GetTickCount() value, but since an Expert Advisor can only be on one chart, its object gets uniqueness due to the chart ID.

I agree.
Thanks, Igor!
Uploaded the corrected version.

Strange, I thought that's how the name was formed. :))

 
Last version 1.49
Files:
iCanvas.mqh  58 kb
 
updated version to 1.49
shortened the resource name, because it was too long.
 

 Nikolai Semko #:
 обновил версию до 1.49
 укоротил имя ресурса, т.к. нарвался на слишком длинное имя

Good afternoon!
In the file iCanvas.mqh (on the link to MT5 version) there is "#property version "1.09"...
Where can I download the latest actual version?
And about the version for MT4 also a question - in the downloaded archive the version "#property version "1.47"
- is it the latest forMT4? And if not - where can Idownload thelatest actual version?

Thanks.

 
Maksims Ignatovs #:

Good afternoon!
In the file iCanvas.mqh (on the link to MT5 version) there is "#property version "1.09"...
Where can I download the latest actual version?
And about the version for MT4 also a question - in the downloaded archive the version "#property version "1.47"
- is it the latest forMT4? And if not - where can Idownload thelatest actual version?

Thanks.

Greetings!
You must be downloading a zip file. Never download it. It's a bug in MQ. When I update the version, the zip file is not overwritten and I don't have access to it.
Click on the iCanvas.mqh file itself or copy it from the viewer.



 
Nikolai Semko #:

Greetings!
You must be downloading a zip file. Never download it. This is a bug in MQ. When I update the version, the zip file is not overwritten and I don't have access to it.
Click on the iCanvas.mqh file itself or copy it from the viewer.



Thank you!
 


Thank you for sharing it.
I've been thinking about making such a tool for some time, and now I can use your code as a basis for mine.

Good job!
 
Guilherme Mendonca #:


Thank you for sharing it.
I've been thinking about making such a tool for some time, and now I can use your code as a basis for mine.

Good job!
Thank you!
 
Latest version 1.53
Files:
iCanvas.mqh  71 kb