Agustinus, but I must warn you that you have taken a difficult way. I also tried to go down this way before, but I gave up and did not find a solution that satisfied me in everything. This is a way to create canvas objects tied to price-time. This way has an advantage - there is no lag when scrolling the chart, but a lot of difficulties arise when there are a large number of objects. Perhaps you can find a working scheme for working with an array of such objects, but I have little faith in this due to serious shortcomings in MQ in managing the object table. My recommendation, as has already been said several times in this thread, is to use one canvas for the entire window, and draw all graphic objects in it. The ideal solution would be my iCanvas library, in which one Cavnas object has already been created, which automatically stretches to fit the entire chart. With this library it will be as simple as possible to work with Canvas with maximum productivity. See this example and this.
The disadvantage of working with a canvas object tied to pixels is that the canvas lags behind the chart when it is scrolled. This problem can be solved radically, while greatly increasing the performance of the canvas, by disabling the native chart and drawing this chart in the same canvas. You need to understand that creating your own canvas chart will take about 1-3 milliseconds, which has an excellent performance margin. The disadvantage of this approach is that it will be difficult to add third-party indicators to such a chart.
Agustinus, but I must warn you that you have taken a difficult way. I also tried to go down this way before, but I gave up and did not find a solution that satisfied me in everything. This is a way to create canvas objects tied to price-time. This way has an advantage - there is no lag when scrolling the chart, but a lot of difficulties arise when there are a large number of objects. Perhaps you can find a working scheme for working with an array of such objects, but I have little faith in this due to serious shortcomings in MQ in managing the object table. My recommendation, as has already been said several times in this thread, is to use one canvas for the entire window, and draw all graphic objects in it. The ideal solution would be my iCanvas library, in which one Cavnas object has already been created, which automatically stretches to fit the entire chart. With this library it will be as simple as possible to work with Canvas with maximum productivity. See this example and this.
The disadvantage of working with a canvas object tied to pixels is that the canvas lags behind the chart when it is scrolled. This problem can be solved radically, while greatly increasing the performance of the canvas, by disabling the native chart and drawing this chart in the same canvas. You need to understand that creating your own canvas chart will take about 1-3 milliseconds, which has an excellent performance margin. The disadvantage of this approach is that it will be difficult to add third-party indicators to such a chart.
I made a mistake. Frame formation (without Erase()and Update()) takes not 1-3 milliseconds, but 0.02-0.3 milliseconds, depending on the scale.
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.
Hey @Nikolai Semko, do you know why I get stack over flow error when use the library?
Thanks
Hey @Nikolai Semko, do you know why I get stack over flow error when use the library?
Thanks
Using strings to pass parameters is very unwise from a performance point of view. Create an additional array of structures for the parameters.
I made a mistake. Frame formation (without Erase()and Update()) takes not 1-3 milliseconds, but 0.02-0.3 milliseconds, depending on the scale.
I made a mistake. Frame formation (without Erase()and Update()) takes not 1-3 milliseconds, but 0.02-0.3 milliseconds, depending on the scale.
Wow, thank you so much for your support & help. I will consider your advise using a single canvas and update the object inside the canvas.