Portfolio Maker is easy to use. However, there are a number of steps to follow — so, please pay close attention. The reason why these steps are necessary is because we are taking the source code (*.mq4) from many stand-alone Expert Advisors, extracting the strategies and indicators, and rearranging the source code so it can be re-built as a single, portfolio EA.
Here are the steps we’ll be performing:
- Use FSB Pro to create the strategies you wish to combine into a single, portfolio EA.
- From FSB Pro, export the strategies in the form of their *.mq4 source files.
- Launch Portfolio Maker and add all the *.mq4 strategy files that will be combined into a single, EA.
- Specify the location of your MetaTrader ‘MQL4’ folder so that Portfolio Maker will know where to create all the intermediate files necessary to build a single EA.
- From Portfolio Maker, press the ‘Create’ button to actually create all the *.mq4 and *.mqh source code files.
- From within the MetaEditor program, locate (in the ‘Experts’ folder) the *.mq4 file that was just created and press the ‘Compile’ button. This will compile the main *.mq4 along with all the support *.mqh files necessary to build this single EA that now includes all your strategies.
Before we begin, there is one important requirement that must be followed in order for this all to work — and that is you must use magic numbers as the filenames for all your individual strategies. This is how Portfolio Maker helps you keep track of strategies and their corresponding magic number — we do this by using magic numbers as filenames. Also, it is possible for Portfolio Maker to programmatically determine the filenames and, in this way, frees you from having to manually input magic numbers. Below is an example:
As as example, we use the following format to name strategy files — you can choose something completely different. The only requirement is the filename must be a valid magic number — that is, it can only include numerals (no letters, punctuation, spaces, etc):
We follow a particular format when creating filenames — again, you can choose something different, whatever you think works best:
We use the format S-P-GGG-NNN, where
S => Symbol
P => Period
G => Group Number
N => Strategy Number (within the group)
For ‘S’ we use:
1 => EURUSD
2 => USDCHF
3 => USDJPY
4 => GBPUSD
For ‘P’ we use:
1 => M1
2 => M5
3 => M15
4 => M30
5 => H1
6 => H4
7 => D1
Examples:
16018001 => EURUSD, H4, Group 18, Strategy #1
26002005 => USDCHF, H4, Group 2, Strategy #5
And then we’ll save the strategies in folders with names such as ‘16018xxx’ — e.g. folder 16018xxx includes 26 strategies, with filenames 16018001.xml through 16018026.xml.
Once you’ve created your strategies (*.xml) and exported the corresponding *.mq4 files, then we are ready to begin…
Step 1: Enter a name for the new, portfolio EA *.mq4 file. This is how it will appear in MetaTrader. Do not include the *.mq4 extention — Portfolio Maker will automatically add that.
Step 2: Enter a short description of the portfolio. This will be displayed near the top of the MetaTrader chart.
Step 3: Very important — enter the location of your MetaTrader’s ‘MQL4’ folder. This is easily found from within the MetaTrader terminal using the main menu: File / Open Data Folder / and select the ‘MQL4’ folder. The reason this is important is because within the MQL4 folder lives the ‘Experts’ and ‘Include’ folders where Portfolio Maker creates the *.mq4 and *.mqh files you’ll need for building the single EA.
Step 4: Using the ‘Add’ button, navigate to the folder where all the *.mq4 strategy files were located and select the ones you wish to add to the portfolio EA.
Step 5: Decide whether the entry size of each position will be based on lots or percent (of account). A portfolio can NOT be a mixture of strategies that use lots and percentages — choose one. If using lots, the 4 input values should be in terms of lots. If using percent, the 4 input values should be percentages. These input values are applied globally and do overwrite the original values that were used when the strategy was created by FSB-Pro. Please keep in mind when using percent the strategy code treats these values as percentages and the algorithm used to convert to lots will divide by 100. So, if you specify a percent that is too small — e.g. 0.01 — then the conversion will fail because the computed lot size will be zero. We’ve tested using percentages of 1 or greater.
Step 6: Press the ‘Create’ button. This creates the *.mq4 and *.mqh files you’ll subsequently need for building the single, portfolio EA.
Step 7: You are almost done. What remains is to launch MetaEditor, locate the *.mq4 file that you named in ‘Step 1’ and press the ‘Compile’ button. If all goes well then a new *.ex4 file will be created — this is your new portfolio EA that includes all your strategies. This file is completely self-contained and you can copy it to other MetaTrader installations without any other requirements.
Step 8: This step is optional — though very useful. You can now use MetaTrader’s Strategy Tester to back-test your portfolio EA. We do not recommend using the ‘Every tick’ model — since that would probably take a few years. But using ‘Open prices’ or ‘Control points’ will usually complete within a few minutes — depending on how many strategies are included in your portfolio, the data horizon, and the period. The more data points that are included in your back test, then the longer it will take. To give you an idea, our favorite period is H4 and we’ll use a data horizon of 6 – 12 months, which may take around 3 minutes to complete on a fast machine. And, finally, when the back-test completes it will create a special log file that includes all the trades. This log file can then be used by MT4 Tracker to further analyze how each of your strategies performed during the back-testing period.