hotkeys
Download scriptThis tool is designed to streamline your trading experience by providing a high-speed navigation system for switching between different timeframes on your trading charts. Instead of manually navigating through various menus or settings to change the visual scale of the market data, this script allows you to toggle instantly using your keyboard.
How it Works
The core logic of this script is based on "Hotkey" detection. It listens for specific physical key presses on your keyboard and maps them to predefined time intervals. When you press a designated number key (ranging from 1 through 9), the script identifies that specific input and immediately updates the chart's display period.
Supported Timeframes
The script is programmed to recognize a comprehensive range of market views, allowing you to jump between different analytical scales with a single tap:
- Short-term Scalping: Options for 1-minute, 5-minute, 15-minute, and 30-minute intervals.
- Intraday Trading: Shortcuts for 1-hour and 4-hour timeframes.
- Swing & Long-term Analysis: Quick switches to Daily, Weekly, and Monthly views.
User Experience
When a key is pressed, the script performs three actions nearly instantaneously:
- Identification: It recognizes which timeframe corresponds to the button you pushed.
- Execution: It commands the platform to switch the active chart to that specific period while maintaining your current asset (symbol).
- Refresh: It forces a visual redraw of the screen so that the new data appears immediately without delay.
By automating this transition, the tool eliminates repetitive clicks, allowing for faster technical analysis and smoother transitions between different trading styles during live market sessions.
//+------------------------------------------------------------------+
//| 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