Discussing the article: "Market Profile indicator (Part 2): Optimization and rendering on canvas"

 

Check out the new article: Market Profile indicator (Part 2): Optimization and rendering on canvas.

The article considers an optimized version of the Market Profile indicator, where rendering with multiple graphical objects is replaced with rendering on a canvas - an object of the CCanvas class.

In the previous article, we delved into the Market Profile indicator. As it turns out, constructing a market profile diagram using ordinary graphical objects consumes quite a lot of resources. Each price point from Low to High of the daily bar is filled with rectangle graphical objects in the number of bars that reached this price level throughout the day. This is true for each item - they all contain many graphical objects, and all these objects are created and drawn for each day where the profile diagram is drawn. When an indicator creates thousands of graphical objects, this may cause significant slowdowns when handling other graphical objects and redrawing the chart. 

For three trading days, the market profile will ultimately look like this:


Author: Artyom Trishkin

 
Why not write the perfect volume profile
 
__zeus__ #:
Why not write a perfect volume profile

What is meant by "perfect"?

 
__zeus__ #:
Why not write the perfect volume profile
I support Igor in his question
 

This is an interesting topic. I also switched to Canvas to display my profile. But this method has some disadvantages. If graphical figures are "drawn and forgotten", mt5 will scale them by itself when moving the chart, changing the TF, etc. actions, then Canvas should be redrawn always, at any CHARTEVENT_CHART_CHANGE, even if VP is somewhere in history, on already unchanged data. And these data must be obtained and not always they (tick data) are in the mt5 cache, here either store the memory and check if the VP boundaries have changed or constantly request from mt5 (now I have it so implemented), which does not work quickly and so the data is not always given completely, and not immediately for sure.

Drawing is one part of the issue. The second part is that a trader does not always need only a picture to admire it, he needs signals based on this picture, such as POC, VHL, VLL, "entry into the void", etc. And we can bind events only to graphical objects (conditionally, we can keep them in an array somewhere in the indicator, but it is still desirable to visualise where this level is, where the alert was triggered). That is, we still need graphical objects to the kanvas VP, although of course they will be an order or even several orders of magnitude less than in the case of displaying VP through graphical objects.

In general, the summary is as follows - we can't get a volumetric terminal from mt5 (yet?) (and we need clusters, deltas, etc.).

The picture is an example of how VP looks like on an impulse wave, POC is shown by a line, here are tick volumes, if there were real volumes I would work on them (finam, amp global). As the practice of comparing tick and real volumes on senior TFs has shown, they either coincide or are very close to each other, except for cases of large volumes passing through the high or low candles, here tick volumes are powerless to help us.



 
Nikolay Kuznetsov #:

This is an interesting topic. I also switched to Canvas to display my profile. But this method has some disadvantages. If graphical figures are "drawn and forgotten", mt5 will scale them by itself when moving the chart, changing the TF, etc. actions, then Canvas should be redrawn always, at any CHARTEVENT_CHART_CHANGE, even if VP is somewhere in history, on already unchanged data. And this data must be obtained and not always they (tick data) are in the mt5 cache, here either store the memory and check if the VP boundaries have changed or constantly request from mt5 (now I have it so implemented), which does not work quickly and the data is not always given completely, and not immediately for sure.

Drawing is one part of the issue. The second part is that a trader does not always need only a picture to admire it, he needs signals based on this picture, such as POC, VHL, VLL, "entry into the void", etc. And we can bind events only to graphical objects (conditionally, we can keep them in an array somewhere in the indicator, but it is still desirable to visualise where this level is, where the alert was triggered). I.e. we still need graphical objects to the canvas VP, although of course they will be an order or even several orders of magnitude less than in the case of displaying VP through graphical objects.

In general, the summary is as follows: we can't get a volumetric terminal from mt5 (yet?) (and we need clusters, deltas, etc.).

The picture is an example of how VP looks like on an impulse wave, POC is shown by a line, here are tick volumes, if there were real volumes I would work on them (finam, amp global). As the practice of comparing tick and real volumes on senior TFs has shown, they either coincide or are very close to each other, except for cases of large volumes passing through the high or low candles, here tick volumes are powerless to help us.



It's not exactly like that. These are not disadvantages, but features that you need to know in order to use the tool with maximum possibilities and freedom of action.
Everything can be done, even though 3D clusters.
Here is an MQL5 example using only Canvas without using OpenCL. If you use OpenCL (i.e. a graphics card), you can achieve significant speedup (dozens of times).