-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartIndicatorMove.mq5
52 lines (49 loc) · 1.99 KB
/
ChartIndicatorMove.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
//+------------------------------------------------------------------+
//| ChartIndicatorMove.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property script_show_inputs
//+------------------------------------------------------------------+
//| Move direction |
//+------------------------------------------------------------------+
enum DIRECTION
{
Up = -1,
Down = +1,
};
//+------------------------------------------------------------------+
//| Inputs |
//+------------------------------------------------------------------+
input DIRECTION MoveDirection = Up;
input bool JumpOver = true;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
const int w = ChartWindowOnDropped();
if(w == 0 && MoveDirection == Up)
{
Alert("Can't move up from window at index 0");
return;
}
const int n = ChartIndicatorsTotal(0, w);
for(int i = 0; i < n; ++i)
{
const string name = ChartIndicatorName(0, w, i);
const string caption = EnumToString(MoveDirection);
const int button = MessageBox("Move '" + name + "' " + caption + "?",
caption, MB_YESNOCANCEL);
if(button == IDCANCEL) break;
if(button == IDYES)
{
const int h = ChartIndicatorGet(0, w, name);
ChartIndicatorAdd(0, w + MoveDirection * (JumpOver + 1), h);
ChartIndicatorDelete(0, w, name);
IndicatorRelease(h);
break;
}
}
}
//+------------------------------------------------------------------+