Техническое задание
I want you to build an HFT-style algo trading bot focusing on ultra-low latency logic, fast execution, and order-book microstructure.
Follow these requirements:
———————
1. GENERAL BOT SPECIFICATIONS
-
Platform: MT5 (MQL5)
-
Execution type: High-frequency trading style
-
Strategy basis:
-
Order book imbalance
-
Tick-by-tick microtrend detection
-
Latency-optimized scalping
-
Micro-arbitrage between bid/ask pressure
-
Queue position logic (when possible)
-
-
One toolchain: provide fully functional MQL5 code that compiles.
———————
2. DATA SOURCES & SIGNALS
Include:
-
Real-time tick stream (OnTick)
-
Order Book (Level 2) using MarketBookAdd()
-
Spread tracking and spread-based signals
-
Imbalance detection:
-
Buy volume vs sell volume
-
Best bid/ask changes
-
-
Microstructure patterns:
-
Bid exhaustion
-
Ask exhaustion
-
Sudden depth disappearance
-
Quote stuffing detection (if possible)
-
———————
3. ENTRY LOGIC RULES
Create multiple entry conditions:
-
Imbalance ratio threshold (example: ask > bid by X%)
-
Price acceleration over last N ticks
-
Spread drops below threshold
-
Best bid lifts 2+ ticks in < 50 ms
-
Best ask drops 2+ ticks in < 50 ms
Make the rules tunable in input parameters.
———————
4. EXIT LOGIC
Include auto exit based on:
-
Micro take-profit (0.05%–0.10%)
-
Micro stop-loss (0.03%–0.05%)
-
Sudden spread widening
-
Reverse imbalance
-
Order book shift against the position
-
Time-based exit (milliseconds)
———————
5. RISK MANAGEMENT
Implement:
-
Max trades per second
-
Daily loss limit
-
Daily profit cap
-
Auto-disable after limit hit
-
Auto reduction of lot size when volatility spikes
———————
6. EXECUTION SPEED OPTIMIZATION
Tell the bot to:
-
Pre-allocate memory
-
Use lightweight arrays
-
Avoid heavy loops
-
Avoid indicators
-
Keep logic pure tick-based
-
Conditional checks optimized for speed
———————
7. OUTPUT REQUIREMENTS
Your response must include:
-
Clear explanation of the strategy
-
Full MQL5 code
-
Separate helper functions for:
-
Order book processing
-
Latency timing
-
Imbalance calculations
-
Fast trade execution
-
-
Comments throughout the code
-
Instructions on compiling and running it
Write everything cleanly, optimized, and ready to run.