Keyboard Hotkey Trader
Fast discretionary trading benefits from not switching focus to a mouse click for every action. This EA listens for chart key events and maps five configurable virtual key codes to Buy, Sell, Close All, Close Half and Breakeven, all on the chart's own symbol. Two decisions matter more than the mapping itself. First, Windows repeats a held key many times a second - a naive handler bound directly to key events would open a burst of separate market orders from one moment of a finger resting too long on the key. Every action here shares a single cooldown timer, so no combination of keys, held or tapped quickly, can fire more than one action within the cooldown window. Second, trading from a bare keystroke with no confirmation is inherently more exposed to a stray input than a button click is, so InpRequireCtrlModifier is on by default and checked via the terminal's live key-state, not guessed from the key event itself. Close All, Close Half and Breakeven manage both this EA's own orders and any hand-opened trade with magic number 0, since the point of a keyboard aid is to manage everything visible on the chart, not just what this EA placed. Notes and limitations - RISK WARNING: this sends live orders and closes real positions from a single keystroke with no confirmation step. Keep InpRequireCtrlModifier on unless you have deliberately decided otherwise, and be aware of what else on the machine can send keystrokes to the terminal window. - Key events only reach this EA while the chart window has keyboard focus. Clicking into another window or a text field elsewhere stops it firing, which is expected, not a bug. - Close All, Close Half and Breakeven act on this EA's own magic number and on magic number 0 (manual trades) only, on the chart's own symbol. Orders from another EA's magic number are left untouched. - Close Half skips a position where half the volume would round to less than the broker's minimum lot, or to the full remaining size, rather than closing the whole thing. - The cooldown is global across all five actions, not per-key: pressing Buy immediately followed by Close All within the cooldown window only the first of the two fires.
Expert advisor · MT5 · v1.0 · Free
About Keyboard Hotkey Trader
Keyboard Hotkey Trader is an expert advisor (trading robot) for MetaTrader 5. It moves the stop loss behind price (trailing stop / break-even) and has a news filter. It has 14 settings, such as Key buy, Key sell and Key close all. MQL source code included.
Files in the download: HotkeyTrader.ex5, HotkeyTrader.mq5, HotkeyTrader.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Key buy | 66 | Virtual key code for Buy (default 66 = 'B') |
| Key sell | 83 | Virtual key code for Sell (default 83 = 'S') |
| Key close all | 67 | Virtual key code for Close All (default 67 = 'C') |
| Key close half | 72 | Virtual key code for Close Half (default 72 = 'H') |
| Key breakeven | 71 | Virtual key code for Breakeven All (default 71 = 'G') |
| Require ctrl modifier | true | Require Ctrl held down for a key to trigger a trade |
| Fixed lots | 0.10 | Lot size for Buy/Sell |
| Stop loss pips | 20 | Stop loss for Buy/Sell, in pips (0 = none) |
| Magic number | 20260104 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Action cooldown ms | 700 | Minimum gap between any two hotkey actions, milliseconds |
| Show legend | true | Show an on-chart label listing the key bindings |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Trailing Stop & Break-even · News Trading · MT5 Expert Advisor · MQL5 Source Code