Download MetaTrader 5

How to display an image in the chart?

To add comments, please log in or register
Guillermo
108
Guillermo  

Hi,

I'm trying to display a .bmp file in a chart (not relative to a time/price, but to its coordinates from the top-left corner).

I have tried this script  https://docs.mql4.com/constants/objectconstants/enum_object/obj_bitmap_label but haven't managed to get it working. I got my file, called "30x28.bmp" in the Images folder from the data folder.

This is my current try:

    ObjectCreate(0, "logo", OBJ_BITMAP_LABEL, 0, 0, 0);
    ObjectSetString(0, "logo", OBJPROP_BMPFILE, "\\Images\\30x28.bmp");

 
Any help would be appreciated. Thank you.

Alain Verleyen
Moderator
32007
Alain Verleyen  
Flood19:

Hi,

I'm trying to display a .bmp file in a chart (not relative to a time/price, but to its coordinates from the top-left corner).

I have tried this script  https://docs.mql4.com/constants/objectconstants/enum_object/obj_bitmap_label but haven't managed to get it working. I got my file, called "30x28.bmp" in the Images folder from the data folder.

This is my current try:

 
Any help would be appreciated. Thank you.

You need to set the modifier parameter :

    ObjectSetString(0, "logo", OBJPROP_BMPFILE, 0, "\\Images\\30x28.bmp");

 modifier: 0-state ON, 1-state OFF

Guillermo
108
Guillermo  
Thanks you, got it working. I had that missing, but I think my .bmp file was in another format (I think it was the color depth, 24 vs 32) as well, got it working by overriding it via Paint... Thank you again!
Doerk Hilger
1188
Doerk Hilger  
If you want, check the code base for my uploads. There is a modified version of CCanvas which also supports bitmaps which are loaded as resources. By this, you don´t need to distribute the bitmap separately, you rather may include it into the EX4/EX5 file. 
Alain Verleyen
Moderator
32007
Alain Verleyen  
Doerk:
If you want, check the code base for my uploads. There is a modified version of CCanvas which also supports bitmaps which are loaded as resources. By this, you don´t need to distribute the bitmap separately, you rather may include it into the EX4/EX5 file. 
Here is your "product" https://www.mql5.com/en/code/13936 
Doerk Hilger
1188
Doerk Hilger  
Maybe, yes. I am not sure if I didn't upload a second one for CCanvas separately.
Doerk Hilger
1188
Doerk Hilger  
And uhm thank you, Alain :)
Alain Verleyen
Moderator
32007
Alain Verleyen  
Doerk:
Maybe, yes. I am not sure if I didn't upload a second one for CCanvas separately.
Nope.
KingOfSand
58
KingOfSand  
Is it possible to use an image from the web instead of one that is stored locally using the above method? I tried to simply change the position to "http://www.******.com/test/image.bmp" but no success of course..
JC
1498
JC  
KingOfSand:
Is it possible to use an image from the web instead of one that is stored locally using the above method? I tried to simply change the position to "http://www.******.com/test/image.bmp" but no success of course..
Yes, but you have to download the image, using something like WebRequest(); save it as a file; and then display the image as above. You can't set OBJPROP_BMPFILE to a URL.
To add comments, please log in or register