I Upgraded the HFT Bot (Advanced Trailing Logic + Full Code)
Introduction to High-Frequency Trading Robot Modifications
Overview of Previous Work
- The speaker previously shared the complete coding for a high-frequency trading (HFT) robot and demonstrated its application in live trading.
- Due to health issues, modifications to the Expert Advisor (EA) were delayed, but the speaker is now ready to share updates.
New Features and Modifications
- The primary modification discussed is implementing an aggressive trading stop-loss from a scalping strategy, aligning with the bot's aggressive nature.
- The EA is designed for short-term use due to its high order generation; prolonged usage may lead to broker restrictions.
Key Considerations for Using the EA
Trading Conditions
- Optimal performance occurs during high momentum periods, such as market openings or news releases; otherwise, profits may diminish.
- The speaker emphasizes that they are not endorsing any specific trading bot for guaranteed success but sharing insights based on personal experience.
Coding Changes: Trailing Stop-Loss Management
Implementation Steps
- The session begins by revisiting the original code and planning to add trailing stop-loss management features.
- An enumeration (enum) will be created for different trailing types: default trailing, scalping trail, previous candle trail, fast moving average trail, and Ichimoku 10% trail.
User Input Configuration
- Users will select their preferred trailing type through an input dropdown menu integrated into the EA settings.
- Additional user inputs will determine trigger points and distances for trailing stop-loss activation based on selected methods.
Detailed Variable Definitions
Customization Options
- For each trailing method selected by users, specific variables must be defined—such as how many candles to consider or which moving average period to apply.
Initialization of Indicators
Setting Up Indicators
- Handles for moving averages and Ichimoku indicators are initialized within the code structure based on user-defined parameters.
Functionality Expansion: On-Tick Processing
Creating Separate Functions
- A new function called
trail_stopis introduced to manage all conditions related to trailing stop-losses separately from other operations in the main loop.
Position Processing Logic
Handling Open Positions
- Existing logic processes open positions based on whether they are buy or sell orders while integrating new trailing mechanisms without cluttering code complexity.
Finalizing Stop-Loss Adjustments
Conditional Checks
- For buy positions: checks if current prices allow adjustments above opening prices while ensuring compliance with broker requirements.
- For sell positions: similar checks ensure that adjustments do not violate market price constraints.
Testing New Features
Live Testing Results
- After implementing changes, initial tests show successful execution of modified stop-loss strategies under various market conditions.
Turn any video into a summary like this
YouTube links, meetings, lectures — with transcripts, search, and chat.