You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You can insert a file as an array and then access that array.
Attached example
Yes, by the way, this works. I didn't know about this possibility. Thanks!
But the size of mq4 or mqh file will be 5 times larger than the png file itself. But it is quite a working option, because it does not affect the size of the ex4 file itself. (it will be the same as ex5 file).
Ask developers to insert PNG here.
I'm sure they will agree.
I doubt that any wishes and requests will be implemented for MT4, especially when it is already announced that MT4 support will end soon.
External PNGs sorted out, loading, scaling, transparency works. But...
Is it even realistic to compile a PNG inside a file?
The standard functionality ...
#resource "\\Files\\123.png"
string nam_img = "::Files\\123.png"
... generates a compilation error
I didn't get into the fact that the software works with an external file, but how to make the whole final product to be one file?
Otherwise the practical sense of such a feature is lost. I have not tried it in MT5. In MT4 there is a connection error.
P.S. I assume that it is theoretically possible to write a script that will convert PNG into code and we will put it, say, in MQH and work with them in one container. But I can't write such a script. Picture arrays are a blind forest for me.
Apart from what Alexander suggested (through inserting uchar[] array), there is also a crutch method through pseudo BMP, which I have already talked about
Forum on trading, automated trading systems and testing trading strategies
Canvas is cool!
Nikolai Semko, 2023.09.25 17:09
Unfortunately, in MQL4 there is no possibility to attach a resource as an array. But everything else works.You can write a script that performs such conversion from png to bmp (the size of the pseudo-image of such a file will be equal in width to the size of the png file itself, and 1 pixel in height).
But you can do with another algorithm: Convert PNG with transparency into a real BMP with transparency and attach it via a resource. The size of ex4 file will be slightly larger than the size with png file, because in ex4 the bmp file resource is stored in packed format. I checked - the increase of ex4 size with bmp will be 10-30% more than ex4 with the same image in png format.
Personally, I would prefer the variant suggested by Slavsky. To put a separate uchar array in a separate mqh file, which will contain the png file itself, and then insert it into the code via an include, so that the giant array does not clutter the code.
Moreover, the advantage of this method is that you do not need to put any graphic files in the MQL4 sandbox, as in the case of resources.
Ask the developers to insert a PNG here.
I'm sure they'll agree.
Let's add it to MQL5.
You can insert a file as an array and then access that array.
Attached example
amazing, how long has this "Insert" menu been in ME? :O
live and learn...
Let's add it to MQL5.
Market shows that all products are duplicated for both platforms. Most likely, they will not use the non-cross-platform variant, but will remain sitting on BMP, unfortunately.
You can attach any file in MQL5 even now.
Such attachment will create a static array with data, not a resource. In the second case, it seems to be available from other EX4/5.Convert PNG with transparency to real BMP with transparency and attach it via resource.
This option does not work in MT4, because BMP with alpha channel is attached but not displayed.
Market shows that all products are duplicated for both platforms. Most likely will not use the non cross-platform variant, and will remain sitting on BMP, unfortunately.
I think PNG has already become cross-platform. It already works with external files. Examples above from Nikolay.
You can insert a file as an array and then access this array.
Indeed, it does. I was directly surprised.
It remains to try to realise in Canvas all the stuff with rubberiness, transparency and that's it - a small mq4 miracle is ready.
Of course, this is done for cross-platform. Because on MT4 - BMP, and on MT5 - PNG. No good. Everything should be PNG.
It remains to try to implement in Canvas the whole rubbery, transparent thing and that's it - a small mq4 miracle is ready.
So everything is already ready. You can take an example test from the PNG library. Only the line with the resource
change it to the line
#include <PNG\iconspng.mqh>
where in the iconspng.mqh file we insert the png_data[] array.
Only it is necessary to remember that in MT4 it is important to output all costly calculations from OnChartEvent to the timer, otherwise it will lag terribly. Purely MQL4 bullshit.
I will now drop a non-lagging version.
I'm about to upload a non-lagging version.
Yeah, it doesn't even lag if the CPU is in "best perfomance" mode.
amazing, how long has this "Insert" menu in ME been there? :O
live and learn...
Among my files, where I experimented with such file insertion, I found a file created in November 2019. I was interested in it even earlier. Unfortunately, I have not found the script where the image file was saved from such an array.
Among my files, where I experimented with such file insertion, I found a file created in November 2019. I was interested in it even earlier. Unfortunately I didn't find the script where the image file was saved from such an array.