How to display an image in the chart?

Back to topics list To post a new topic, please log in or register
avatar
15
Flood19 2016.04.21 15:56
 

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.

avatar
Moderator
3206
angevoyageur 2016.04.21 16:38 #
 
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

 

avatar
15
Flood19 2016.04.21 17:11 #
 
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!
avatar
119
Doerk 2016.04.23 10:09 #
 
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. 
avatar
Moderator
3206
angevoyageur 2016.04.23 15:01 #
 
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 
avatar
119
Doerk 2016.04.23 22:14 #
 
Maybe, yes. I am not sure if I didn't upload a second one for CCanvas separately.
avatar
119
Doerk 2016.04.25 00:17 #
 
And uhm thank you, Alain :)
avatar
Moderator
3206
angevoyageur 2016.04.25 08:45 #
 
Doerk:
Maybe, yes. I am not sure if I didn't upload a second one for CCanvas separately.
Nope.
avatar
15
KingOfSand 2016.09.13 10:14 #
 
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..
avatar
1316
jjc 2016.09.13 10:19 #
 
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.
Back to topics list  

To add comments, please log in or register