Default background chart color

 

Hi!

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

Thank you!

 
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
 

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.

 
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
 
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.

 
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...).
 
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!

 
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.

 
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.

Reason: