-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenChartsShowingSpread.mq5
40 lines (36 loc) · 1.25 KB
/
OpenChartsShowingSpread.mq5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#property script_show_inputs true
input ENUM_TIMEFRAMES timeFrame = PERIOD_H1; //Timeframe
input string tplName = "Momentum.tpl"; //Template
input uint ptsSpread = 20; //Spread Filter
int symIndex = 0;
int symSpread = 0;
string symName = "";
long chartID = 0;
void OnStart()
{
for(symIndex = 0; symIndex < SymbolsTotal(false); symIndex++)
{
symName = SymbolName(symIndex, false);
if(SymbolInfoInteger(symName, SYMBOL_SELECT) == false) SymbolSelect(symName, true);
}
Sleep(1000);
for(symIndex = 0; symIndex < SymbolsTotal(false); symIndex++)
{
symName = SymbolName(symIndex, false);
symSpread = SymbolInfoInteger(symName, SYMBOL_SPREAD);
if(symSpread > ptsSpread)
{
SymbolSelect(symName, false);
continue;
}
chartID = ChartOpen(symName, timeFrame);
ChartApplyTemplate(chartID, "//Profiles//Templates//" + tplName);
ChartSetInteger(chartID, CHART_SHIFT, 0, true);
}
}
/*First script selects symbols having spread below specified value on the marketwatch, then opens corresponding charts by appyling timeframe and template stated.
To Open Charts;
Double-click or drag-drop OpenCharts on a chart.
Enter inputs. (Timeframe, Template, Spread)
Click Ok.
*/