Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
nojiko70-4
29
nojiko70-4 2016.08.27 09:50 

Hi!

Is there a way to get/set the default background color of a chart in mql4?

Thank you!

whroeder1
13617
whroeder1 2016.08.27 14:11  
nojiko70-4: Is there a way to get/set the default background color of a chart in mql4?
  1. Set the chart the way you want. Save a template with the name default.tpl
  2. User Interface - MetaTrader 4 Help
peter.MT4Web
158
peter.MT4Web 2016.08.27 14:21  

No, because MQL4 has no default background. You only can get and set the background of the chart the EA is attatched to.

You can set the background in the MT4 default template. There are also templates for debuging and testing - see documentation.

whroeder1
13617
whroeder1 2016.08.27 19:49  
eddie: No, because MQL4 has no default background. You only can get and set the background of the chart the EA is attatched to.
Or by code EA or script or indicator.
  1. ChartApplyTemplate - Chart Operations - MQL4 Reference
  2. ChartSetInteger - Chart Operations - MQL4 Reference using chart_color_background
peter.MT4Web
158
peter.MT4Web 2016.08.27 21:44  
WHRoeder:
eddie: No, because MQL4 has no default background. You only can get and set the background of the chart the EA is attatched to.
Or by code EA or script or indicator.
  1. ChartApplyTemplate - Chart Operations - MQL4 Reference
  2. ChartSetInteger - Chart Operations - MQL4 Reference using chart_color_background

1. As far as i know, if you apply a template to the same chart the program is running, the program will be removed from the chart.

2. Thanks for clearifying and the details.

nojiko70-4
29
nojiko70-4 2016.08.28 10:21  
eddie:

1. As far as i know, if you apply a template to the same chart the program is running, the program will be removed from the chart.

Yes, this is one of the problems using "ChartApplyTemplate" in this context, as it basically resets everything of the chart (not only the background color...).
Fernando Carreiro
1468
Fernando Carreiro 2016.08.28 11:19  
nojiko70-4:
Yes, this is one of the problems using "ChartApplyTemplate" in this context, as it basically resets everything of the chart (not only the background color...).

Then use ChartSetInteger() as WHRoeder has suggested!

nojiko70-4
29
nojiko70-4 2016.08.28 16:05  
FMIC:

Then use ChartSetInteger() as WHRoeder has suggested!

Ehm, I already intend to use ChartSetInteger() to set the background color, but the question was not how to set the background color, but how to get/set the default background color.

As indirectly suggested by WHRoeder one could apply the default template - which would apply the default background color - and then get the default background color with ChartGetInteger(). But the operation of using ChartApplyTemplate, as mentioned, would have unwanted consequences.

Fernando Carreiro
1468
Fernando Carreiro 2016.08.28 16:40  
nojiko70-4:

Ehm, I already intend to use ChartSetInteger() to set the background color, but the question was not how to set the background color, but how to get/set the default background color.

As indirectly suggested by WHRoeder one could apply the default template - which would apply the default background color - and then get the default background color with ChartGetInteger(). But the operation of using ChartApplyTemplate, as mentioned, would have unwanted consequences.

You still don't understand. The default template ("default.tpl") does not need to be applied either manually or via ChartApplyTemplate() because it is the default template.

When you open any new Chart, the default template is automatically applied, therefore the default background color is what is in the "default.tpl" file.

So, just setup a new chart as you wish it to be (change colours, scaling, volume, indicators, etc.) and then save it to the default template "default.tpl". From that moment on, any new charts opened, will have those default everything.

/
To add comments, please log in or register