-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartScaleTime.mq5
61 lines (56 loc) · 2.4 KB
/
ChartScaleTime.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//+------------------------------------------------------------------+
//| ChartScaleTime.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include <MQL5Book/ChartModeMonitor.mqh>
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
int flags[] =
{
CHART_SCALE,
CHART_VISIBLE_BARS,
CHART_FIRST_VISIBLE_BAR,
CHART_WIDTH_IN_BARS,
CHART_WIDTH_IN_PIXELS
};
ChartModeMonitor m(flags);
Print("Initial state:");
m.print();
m.backup();
while(!IsStopped())
{
m.snapshot();
Sleep(500);
}
m.restore();
}
//+------------------------------------------------------------------+
/*
Initial state:
[key] [value]
[0] 5 4
[1] 100 35
[2] 104 34
[3] 105 45
[4] 106 715
// 1) the chart is scaled down:
CHART_SCALE 4 -> 3 // - the "scale" property changed
CHART_VISIBLE_BARS 35 -> 69 // - number of visible bars increased
CHART_FIRST_VISIBLE_BAR 34 -> 68 // - index of first visible bar increased
CHART_WIDTH_IN_BARS 45 -> 90 // - potential chart capacity in bars increased
// 2) right-side shift is switched off
CHART_VISIBLE_BARS 69 -> 89 // - number of visible bars increased
CHART_FIRST_VISIBLE_BAR 68 -> 88 // - index of first visible bar increased
// 3) window is squeezed
CHART_VISIBLE_BARS 89 -> 86 // - number of visible bars decreased
CHART_WIDTH_IN_BARS 90 -> 86 // - potential chart capacity in bars decreased
CHART_WIDTH_IN_PIXELS 715 -> 680 // - width in pixels decreased
// 4) "End" key is pressed to go to latest quotes
CHART_VISIBLE_BARS 86 -> 85 // - number of visible bars decreased
CHART_FIRST_VISIBLE_BAR 88 -> 84 // - index of first visible bar decreased
*/
//+------------------------------------------------------------------+