Hey there, fellow traders! Today, we're diving into the MTC Combo, an innovative EA designed for MetaTrader 5. I’ve added a few tweaks to the original descriptions to make things clearer and more relevant to our trading environment.
Understanding the Goal of MTC Combo
Let’s start by laying down the basics. Imagine we have a Basic Trading System (BTS). Our goal is to enhance this system with a Neural Network (NN) that can execute trades in ways the BTS simply can’t. The result? A powerful trading duo: the BTS and NN working hand in hand.
There’s no need to reinvent the wheel. Why teach someone to run when there’s a car available? Similarly, if we’ve got a trend-based trading system, we want the neural network to focus on a counter-trend strategy. Remember, trend systems struggle during sideways markets and can miss rollbacks and reversals. We could run both a trend and counter-trend strategy on a single chart, but why not let the NN complement our existing system instead?
Building the Neural Network
We’ve crafted a two-layer neural network that consists of two bottom-layer perceptrons and one upper-layer perceptron. The NN can be in one of three states:
- Entering long
- Entering short
- Undefined
When the NN is in the 'Undefined' state, control defaults back to the BTS, while it generates trading signals when in the long or short states.
Stages of Neural Network Training
The training process for the neural network is divided into three distinct stages, each focusing on a different perceptron. The BTS is optimized at each stage to guide the perceptrons. This separate training is necessary due to the limitations of the genetic algorithm, which can only optimize a limited number of parameters at once. Luckily, since our NN isn’t overly complex, the optimization process is efficient.
Stage 1: Optimizing the Basic Trading System
Before we dive into training the NN, we need to optimize the BTS. Set the initial deposit in your tester to $100 to prevent any artificial margin calls during optimization. We’ll optimize for the Balance + Max Sharpe Ratio and use the Fast Genetic Algorithm for optimization.
Head over to the Inputs tab in the EA properties:
- Set the lot size to 0.01 by adjusting the lots parameter.
For optimization, we’ll use the Open Prices Only model for speed and efficiency.
Moving on to the Optimization
Set the 'pass' input to 1 and optimize only the parameters that end with 1:
- tp1 - BTS take profit (optimized from 100 to 1000, step of 10)
- sl1 - BTS stop loss (optimized from 100 to 1000, step of 10)
- p1 - CCI oscillator period (optimized from 3 to 100, step of 1)
Start the training process using the genetic algorithm optimization.
Stage 2: Training the Short Position Perceptron
Now, set the 'pass' input to 2 and remove the previous stage’s optimization marks. Save your previous inputs for backup.
Optimize the parameters for this stage (IDs ending in 2):
- x12, x22, x32, x42 - weight ratios for short positions (optimized from 0 to 200, step of 1)
- tp2 - take profit for short positions (optimized from 100 to 1000, step of 10)
- sl2 - stop loss for short positions (optimized from 100 to 1000, step of 10)
- p2 - period of price difference values (optimized from 3 to 100, step of 1)
Again, start the training using genetic algorithm optimization.
Stage 3: Training the Long Position Perceptron
Set the 'pass' input to 3, remove previous optimization marks, and save the inputs as before.
For this stage, focus on parameters that end in 3:
- x13, x23, x33, x43 - weight ratios for long positions (optimized from 0 to 200, step of 1)
- tp3 - take profit for long positions (optimized from 100 to 1000, step of 10)
- sl3 - stop loss for long positions (optimized from 100 to 1000, step of 10)
- p3 - period of price difference values (optimized from 3 to 100, step of 1)
Commence training using genetic algorithm optimization once again.
Final Stage: Training the Upper-Layer Perceptron
Now we’ve reached the last stage. Set the 'pass' input to 4, clear previous optimization marks, and save your inputs.
For this stage, focus on parameters ending in 4:
- x14, x24, x34, x44 - weight ratios for the first-layer perceptron (optimized from 0 to 200, step of 1)
- p4 - period of price difference values (optimized from 3 to 100, step of 1)
Start the training process using genetic algorithm optimization.
And that’s a wrap! Your neural network is now trained and ready to go. Just a heads-up: the EA has a 'mn' input for a magic number that helps it recognize its own orders, so make sure each magic number is unique to avoid confusion.
P.S.
- Initially set the deposit size to twice the absolute drawdown for a safety margin.
- The EA's source code isn’t optimized yet.
- If you plan to swap out the built-in BTS for another trading system, tweak the basicTradingSystem() function.
- Re-optimize the EA during weekends if the previous week wasn’t profitable. Losses indicate market changes, while consistent profits mean your robot is on point!
Related Posts
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- Mastering Bullish and Bearish Harami Patterns with Stochastic in MT5
- Harnessing MQL5 Wizard for Bullish and Bearish Harami Signals with CCI Confirmation
- Creating a Stochastic-Based EA for Hammer and Hanging Man Patterns in MetaTrader 5