Loading…

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

SettingDefaultWhat it does
Key buy66Virtual key code for Buy (default 66 = 'B')
Key sell83Virtual key code for Sell (default 83 = 'S')
Key close all67Virtual key code for Close All (default 67 = 'C')
Key close half72Virtual key code for Close Half (default 72 = 'H')
Key breakeven71Virtual key code for Breakeven All (default 71 = 'G')
Require ctrl modifiertrueRequire Ctrl held down for a key to trigger a trade
Fixed lots0.10Lot size for Buy/Sell
Stop loss pips20Stop loss for Buy/Sell, in pips (0 = none)
Magic number20260104Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds
Action cooldown ms700Minimum gap between any two hotkey actions, milliseconds
Show legendtrueShow an on-chart label listing the key bindings

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Trailing Stop & Break-even · News Trading · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria