Changing the size of the chart from code ... not possible?

 

Hi all,

I would like to know how to change the size of the chart using MQL5. It seems that chart properties related to width and height are read-only. I can not believe that this is not possible, despite the fact that I have tried to search for a solution for a long time. The problem is that I want to take a screenshot of a specific size that spans all the chart. If I take a screenshot with a specific resolution different from the chart window, it will only span through that area. The simple solution would be to set by hand the chart size but I guess it is also not possible to do it with specific pixel values. Furthermore, I want to be able to set the chart size using code.

 

Thanks very much for your attention and hope anybody gives me a solution,

 

Javier 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Properties - Documentation on MQL5
 
jquijano:

Hi all,

I would like to know how to change the size of the chart using MQL5. It seems that chart properties related to width and height are read-only. I can not believe that this is not possible, despite the fact that I have tried to search for a solution for a long time. The problem is that I want to take a screenshot of a specific size that spans all the chart. If I take a screenshot with a specific resolution different from the chart window, it will only span through that area. The simple solution would be to set by hand the chart size but I guess it is also not possible to do it with specific pixel values. Furthermore, I want to be able to set the chart size using code.

 

Thanks very much for your attention and hope anybody gives me a solution,

 

Javier 

I don't understand your problem, you can do that without any problem seems to me :

MetaTrader Trading Platform Screenshots

AUDUSD, M5, 2013.05.02

MetaQuotes Software Corp., MetaTrader 5, Demo

A chart with custom dimensions

AUDUSD, M5, 2013.05.02, MetaQuotes Software Corp., MetaTrader 5, Demo

I sized the chart by mouse, then Save as Picture, "Active Chart as is".
 

MetaTrader Trading Platform Screenshots

AUDUSD, M5, 2013.05.02

MetaQuotes Software Corp., MetaTrader 5, Demo

Same chart, maximized, but choosing "Active chart 940 x 160 pixels"

AUDUSD, M5, 2013.05.02, MetaQuotes Software Corp., MetaTrader 5, Demo


 
jquijano:

Hi all,

I would like to know how to change the size of the chart using MQL5. It seems that chart properties related to width and height are read-only. I can not believe that this is not possible, despite the fact that I have tried to search for a solution for a long time. The problem is that I want to take a screenshot of a specific size that spans all the chart. If I take a screenshot with a specific resolution different from the chart window, it will only span through that area. The simple solution would be to set by hand the chart size but I guess it is also not possible to do it with specific pixel values. Furthermore, I want to be able to set the chart size using code.

You don't need to change the size of the chart window to be able to take a screenshot of a specific size.  Use ChartScreenShot() and specify the X and Y sizes  ( width and height ) in pixels.
 
angevoyageur:

Thanks really much. My concern was about the fact of changing the size of the chart from code. Anyway, I have just realized that there was a bug in my code that did not allowed me to call chartscreenshot correctly.

Thanks anyway for the replay 

Documentation on MQL5: Chart Operations / ChartScreenShot
Documentation on MQL5: Chart Operations / ChartScreenShot
  • www.mql5.com
Chart Operations / ChartScreenShot - Documentation on MQL5
 
RaptorUK:
You don't need to change the size of the chart window to be able to take a screenshot of a specific size.  Use ChartScreenShot() and specify the X and Y sizes  ( width and height ) in pixels.

Hi,  I have just realized that there was a bug in my code and that is the reason why I couldnt get a proper image using ChartScreenShot. It was an stupid bug but your answer made me check it again, so I found the problem. Thanks very much

 
jquijano:

Hi,  I have just realized that there was a bug in my code and that is the reason why I couldnt get a proper image using ChartScreenShot. It was an stupid bug but your answer made me check it again, so I found the problem. Thanks very much

Glad to hear you found a fix  :-) 
 
jquijano:

Thanks really much. My concern was about the fact of changing the size of the chart from code. Anyway, I have just realized that there was a bug in my code that did not allowed me to call chartscreenshot correctly.

Thanks anyway for the replay 

Sorry, I read too fast.
 

RaptorUK:
Glad to hear you found a fix  :-) 

Hello again,

 

I did not finally find a bug in my code!!! Actually, Metatrader5 is not indeed performing well. The problem arises when you want to save the image with a "width" resolution smaller than the one of the chart window. Then, it will only take the portion of the image corresponding to that resolution. If the "height" resolution is smaller, then no problem. It will scale the image perfectly. This problem happens either by code or just by saving the image with "save as picture".

image with original resoution

 

image saved with lower resolution than the original 

 

 

 

 
jquijano:

Hello again,

 

I did not finally find a bug in my code!!! Actually, Metatrader5 is not indeed performing well. The problem arises when you want to save the image with a "width" resolution smaller than the one of the chart window. Then, it will only take the portion of the image corresponding to that resolution. If the "height" resolution is smaller, then no problem. It will scale the image perfectly. This problem happens either by code or just by saving the image with "save as picture".

As I understand, MQL5/MT5 works as intended by the documentation, so it perform well but not as YOU intend ;-)

EDIT: Seems there is no way to change the width of chart (window) by code.

 
jquijano:

Hello again,

 

I did not finally find a bug in my code!!! Actually, Metatrader5 is not indeed performing well. The problem arises when you want to save the image with a "width" resolution smaller than the one of the chart window. Then, it will only take the portion of the image corresponding to that resolution. If the "height" resolution is smaller, then no problem. It will scale the image perfectly. This problem happens either by code or just by saving the image with "save as picture".

My chart window gives a full size image of 1679 x 672

 1679 x 672

so I shouldn't be able to save a chart of   1600 x 700 ? like this one ?

 

 

Width is smaller,  height is larger . . .  did I misunderstand the issue ? 

Reason: