ChartApplyTemplate applying to _Symbol chartID, not desired ChartID
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
You agree to website policy and terms of use
I want to apply a template on a chart other than the default chart for _Symbol. I can successfully create a new chart and pass that chartID down to a function of mine which is supposed to apply a template in the Template directory, based on a constructed name, to the new chart.
In the debugger I can step down to the last If test in the function below, which is true and a template is loaded on the default chart, not the chartID passed to ChartApplyTemplate and my EA restarts -- does not load the template on the new chart I createds.
I've put a couple log (Print) statements just to confirm what I see. Any ideas on what is happening in ChartApplyTemplate in my code and any workarounds?
string sym = ChartSymbol(chartid);
if (per == PERIOD_CURRENT) per = getBotPeriod();
long c = ChartID();
string terminal_path = "";
log("reloadTemplate(): Attempting Template " + terminal_path + co + "_" + sym + "_" + curr_template_name + " reload");
if (!ChartApplyTemplate(chartid, terminal_path + co + "_" + sym + "_" + curr_template_name)) {
log("reloadTemplate(): WARNING failed to apply template " + terminal_path + co +"_" + sym + "_" + curr_template_name);
log("reloadTemplate(): Attempting Template " + terminal_path + sym + "_" + curr_template_name + " reload");
if (!ChartApplyTemplate(chartid, terminal_path + sym + "_" + curr_template_name)) {
log("reloadTemplate(): WARNING failed to apply template " + terminal_path + sym + "_" + curr_template_name);
log("reloadTemplate(): Attempting Default Template " + terminal_path + curr_template_name + " reload");
if (!ChartApplyTemplate(chartid, curr_template_name)) {
log("reloadTemplate(): failed to apply template "+ terminal_path + curr_template_name+" : "+ErrorDescription(GetLastError()));
}
} else {
}
} else {
}
return (false);