Hi, I've written this short script to open 5 charts on the 15 min timeframe and apply a template to those charts, then open another 5 charts on the 5 min timeframe so that I can apply a different template to those. The script runs but the last part doesn't work. What am I doing wrong? Thanks in advance.
Your condition: if(Period()== 5) is wrong. Period() returns the current chart period. Instead you have to use:
if(ChartPeriod(chartfirst)==PERIOD_M5)
Your condition: if(Period()== 5) is wrong. Period() returns the current chart period. Instead you have to use:
Hey, thanks very much for that, I had been looking in MQL4 reference for that but completely overlooked it. Your answer has helped me to the next set of issues I have. Hopefully get those sorted. As part of the "while" loop I think i need to use "continue" also but the following seems to work for me. Also I found the insert code button for this reply. Thanks again.
Another quick question, is there a bit of code to arrange the windows? Something that mimics the Tile Windows shortcut "ALT + R"?
void OnStart() { ChartOpen("AUDCAD",5); ChartOpen("AUDCHF",15); ChartOpen("AUDJPY",30); ChartOpen("AUDNZD",60); ChartOpen("AUDUSD",5); ChartOpen("AUDCAD",15); ChartOpen("AUDCHF",30); ChartOpen("AUDJPY",60); ChartOpen("AUDNZD",5); ChartOpen("AUDUSD",5); long scriptchart=ChartID(); //the chart the script is added to long firstchart=ChartFirst(); while(firstchart>0) { if(firstchart==scriptchart) { firstchart=ChartNext(firstchart); continue; } if(ChartPeriod(firstchart)==5) { ChartApplyTemplate(firstchart,"S_colour1.tpl"); firstchart=ChartNext(firstchart); continue; } if(ChartPeriod(firstchart)==15) { ChartApplyTemplate(firstchart,"S_colour2.tpl"); firstchart=ChartNext(firstchart); continue; } if(ChartPeriod(firstchart)==30) { ChartApplyTemplate(firstchart,"S_colour3.tpl"); firstchart=ChartNext(firstchart); continue; } ChartApplyTemplate(firstchart,"S_colour4.tpl"); firstchart=ChartNext(firstchart); } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I've written this short script to open 5 charts on the 15 min timeframe and apply a template to those charts, then open another 5 charts on the 5 min timeframe so that I can apply a different template to those. The script runs but the last part doesn't work. What am I doing wrong? Thanks in advance.