Best way to graphically implement a "heat map" for a custom indicator

 

Hey everyone, 

I am creating a custom indicator where the information output only really makes sense when displayed as a heat map (example attached below). On each iteration, an array of 50 values is generated and I'd like to color the indicator window from range 1-50 on the y-axis according to each corresponding value in the array.

The only way I believe this can be done in MQL5 is to create a separate buffer for each of the 50 values. However, that is far to inelegant for my liking. Does anyone else have any insight into how I can accomplish this in the most efficient manner?

Best,

Joe

 
Joey Smith:

Hey everyone, 

I am creating a custom indicator where the information output only really makes sense when displayed as a heat map (example attached below). On each iteration, an array of 50 values is generated and I'd like to color the indicator window from range 1-50 on the y-axis according to each corresponding value in the array.

The only way I believe this can be done in MQL5 is to create a separate buffer for each of the 50 values. However, that is far to inelegant for my liking. Does anyone else have any insight into how I can accomplish this in the most efficient manner?

Best,

Joe

So its like a "matrix" type of display and the display has 50 rows per bar always?

 
Lorentzos Roussos:

So its like a "matrix" type of display and the display has 50 rows per bar always?

Yes exactly, Its a matrix that always displays 50 rows per bar and each value in the matrix ranges between 0 and 1.

I am looking to color the display at each row depending on the value.

Example:

If value is more than .5 color row red or green (color depending on another conditional)

If value is less than .5 color row black

 
Joey Smith:

Yes exactly, Its a matrix that always displays 50 rows per bar and each value in the matrix ranges between 0 and 1.

I am looking to color the display at each row depending on the value.

Example:

If value is more than .5 color row red or green (color depending on another conditional)

If value is less than .5 color row black

Alright then , the best option is to deploy a background canvas (or memory resource) that you draw to .
Each time the chart changes you redraw it ,getting its size and splitting it to 50rows.
It would be best visually if the heat map was on a separate window since its not relative to the price chart 

 
Lorentzos Roussos:

Alright then , the best option is to deploy a background canvas (or memory resource) that you draw to .
Each time the chart changes you redraw it ,getting its size and splitting it to 50rows.
It would be best visually if the heat map was on a separate window since its not relative to the price chart 

Aha, perfect. This will be my first dive into the CCanvas class as detailed in Alexander's article. Thank you very much Lorentzos, excited to create more visually stunning and information-packed indicators.
Developing custom indicators using CCanvas class
Developing custom indicators using CCanvas class
  • www.mql5.com
Let's use the "simple-to-complex basis" in order to grasp the principles of developing custom graphics. First, we are going to develop a simple circular indicator featuring a frame, numerical value and description. The Fig. 1 shows the structure of the basic elements. Frame (border). An outlined edging. Background. The space the text elements...
 
Joey Smith:
Aha, perfect. This will be my first dive into the CCanvas class as detailed in Alexander's article. Thank you very much Lorentzos, excited to create more visually stunning and information-packed indicators.

It is fun yes :) . Enjoy

Reason: