-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChartNavigate.mq5
24 lines (22 loc) · 1.2 KB
/
ChartNavigate.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
//+------------------------------------------------------------------+
//| ChartNavigate.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//| The script will shift current chart by specified number of bars |
//| in 'Shift' parameter relative to specified origin in Position. |
//+------------------------------------------------------------------+
#property script_show_inputs
input ENUM_CHART_POSITION Position = CHART_CURRENT_POS;
input int Shift = -1;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
ChartSetInteger(0, CHART_AUTOSCROLL, false);
const int start = (int)ChartGetInteger(0, CHART_FIRST_VISIBLE_BAR);
ChartNavigate(0, Position, Shift);
const int stop = (int)ChartGetInteger(0, CHART_FIRST_VISIBLE_BAR);
Print("Moved by: ", stop - start, ", from ", start, " to ", stop);
}
//+------------------------------------------------------------------+