0
Views
0
Downloads
0
Favorites
hotkeys
//+------------------------------------------------------------------+
//| hotKeys.mq4 |
//| Copyright 2015,Mohit Marwaha |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Mohit Marwaha"
#property link "marwaha1@gmail.com"
#property version "1.20"
#property strict
#property indicator_chart_window
#property description "Keys 1 through 9 change timeframes from 1 minute to Monthly"
#define KEY_MONTHLY 57
#define KEY_WEEKLY 56
#define KEY_DAILY 55
#define KEY_4HOUR 54
#define KEY_1HOUR 53
#define KEY_30MIN 52
#define KEY_15MIN 51
#define KEY_5MIN 50
#define KEY_1MIN 49
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
Comment("Copyright MohitMarwaha");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
if(id==CHARTEVENT_KEYDOWN)
{
switch(int(lparam))
{
case KEY_WEEKLY:ChartSetSymbolPeriod(0,NULL,10080);
break;
case KEY_DAILY:ChartSetSymbolPeriod(0,NULL,1440);
break;
case KEY_4HOUR:ChartSetSymbolPeriod(0,NULL,240);
break;
case KEY_1HOUR:ChartSetSymbolPeriod(0,NULL,60);
break;
case KEY_5MIN:ChartSetSymbolPeriod(0,NULL,5);
break;
case KEY_30MIN:ChartSetSymbolPeriod(0,NULL,30);
break;
case KEY_15MIN:ChartSetSymbolPeriod(0,NULL,15);
break;
case KEY_MONTHLY:ChartSetSymbolPeriod(0,NULL,43200);
break;
case KEY_1MIN:ChartSetSymbolPeriod(0,NULL,1);
break;
}
ChartRedraw();
}
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---