Extra Report Pad – 거래 계정 분석을 위한 전문 솔루션 오늘날 여러 통화쌍을 동시에 거래하는 것이 필수적입니다. 하지만 거래가 많을수록 계정의…
EA SUPER TESTER Expert Advisor를 위한 멀티스레드 테스트 프로그램
Table of Contents (click to show)
List
- Description
- Open Source
- The Real Value of Our Advisor
- Programming Your Forex Trading Strategy
- Programming THE X for MetaTrader 5
- MetaTrader 5 Step 0: Loading Indicators into Resources!
- MetaTrader 5 Step 1: Specify the Signal Name!
- MetaTrader 5 Step 2: Specify the Signal Display Name!
- MetaTrader 5 Step 3: Specify the Filter Name!
- MetaTrader 5 Step 4: Specify the Parameters of the Indicator or Strategy in External Variables!
- MetaTrader 5 Step 5: Create Indicator Handles to Load into the Expert Advisor!
- MetaTrader 5 Step 6: Declare Variables to Load the Indicator(s) of the Strategy!
- MetaTrader 5 Step 7: Declare Variables for Storing Indicator Data!
- MetaTrader 5 Step 8: Create Strategies and Signals for Opening Positions!
- Error Codes
- MetaTrader 5 Step 9: Specify Filters from Your Indicators or Use Your Indicator as a Filter for the Strategy!
- MetaTrader 5 Step 10: This is the final step!
- MetaTrader 5 Conclusions and Verification of the Strategy
- Programming THE X for MetaTrader 4
- MetaTrader 4 Step 0: Loading Indicators into Resources
- MetaTrader 4 Step 1: Specify the Signal Name
- MetaTrader 4 Step 2: Specify the Signal Name for Display on Screen
- MetaTrader 4 Step 3: Specify the Filter Name
- MetaTrader 4 Step 4: Specify Indicator or Strategy Parameters in External Variables
- MetaTrader 4 Steps 5, 6, 7: Relax!
- MetaTrader 4 Step 8: Creating Strategies and Signals for Opening Positions
- MetaTrader 4 Step 9: Specify Filters from Your Indicators or Use Your Indicator as a Filter for the Strategy
- MetaTrader 4 Step 10: This is the Final Step!
- MetaTrader 4 Conclusions and Strategy Check
- What Else Can Be Changed in the Expert Advisor?
- Debugging a Strategy
Description
The X is a builder of trading strategies.
We have developed a Universal Expert Advisor that encompasses all the most intriguing and essential functions.
Additionally, a signal module utilizing standard indicators has been incorporated.
This is a strategy builder, allowing you to program your own strategy.
It started as a project that gained significant popularity. For 15 years, we have been refining the algorithm, adding new functions and indicators, and correcting function errors.
This article will guide you through programming your strategy, integrating indicators into the advisor, and adding new signals and filters.
Open Source
A recurring question we receive is:
- Can I integrate my indicators into an advisor?
- How much does the open-source code of the Expert Advisor cost?
It’s no secret that we offer the open-source code of our advisor for sale. This is intended for traders who wish to develop their own advisors or build their own signals.
Furthermore, traders often purchase open-source code to implement their proprietary strategies and resell the advisor.
- The open-source code of the advisor The X can be purchased in our Market of Trade Advisors.
- Open Source The X for MetaTrader 5 (Not available)
- Open Source The X for MetaTrader 4 (Not available)
- By the way, we have many open-source codes for our advisors. Section: Strategy Advisors (Open Source)
- Try our Open Source Templates.
Programming advisors with indicators is a complex process.
We offer programming services for trade advisors. However, the development process often faces delays because clients are unsure of the functions they require.
The X is a collection of blocks and functions for trading on the FOREX market, utilized globally. We have developed functions that are frequently used, enabling the advisor to meet 90% of each trader’s needs.
Naturally, there are unique strategies that experienced programmers need to develop.
Such strategies are rare and require meticulous preparation. The cost of this work depends on its complexity.
The Real Value of Our Advisor
Starting with our article on the cost of a programmer’s work, we can estimate the approximate cost of our trading robot, The X:
Our EA contains over 10,000 lines of code. While this may seem extensive, it’s manageable because we do not write advisors using PL/SQL (Programming Language/Structured Query Language). Why? Because OOP (Object-Oriented Programming) is unfamiliar to many, and handling OOP can be quite challenging!
So, let’s calculate:
- The cost of 1 hour of a programmer’s work = $20 when programming functions and algorithms.
- The cost of 1 hour of error correction = $5.
- The cost of writing texts and videos = $10 (This price is based on internet rates; I create all instructions and videos myself).
- Assume that writing functions and blocks for The X took over 1,000 hours!
- Programming signals using indicators is straightforward. Therefore, we assume it took us 10 hours!
However, some aspects cannot be completed immediately:
- Debugging functions can take an additional 1,000 hours!
- Developing instructions, videos, and promotions also requires 1,000 hours!
In total, we have invested over 3,000 hours!
If we were to commission such an algorithm, we would decline. It is neither reasonable nor profitable.
The total cost of such a custom expert advisor is over $35,000! However, our advisor is sold at a price ten times lower!!!!
The cost of our open-source is TEN times less!
Such custom orders are never fulfilled:
- Firstly, because customers are unwilling to invest such a significant amount of money.
- Secondly, programmers are reluctant to dedicate so much time to development.
I assure you that programming such a complex trading robot requires more time than creating a trading strategy.
Debugging all the blocks and functions demands extended time.
We are extremely grateful to our customers who have identified mistakes and provided corrections over the past five years, as well as contributed their functions and indicators to enhance the functionality of the advisor THE X.
Programming Your Forex Trading Strategy
Firstly, I want to mention that we have updated our expert advisor’s code. It is now very easy to understand and well-commented.
You don’t need to delve into every function in detail. You can program your strategy in just 10 steps.
We have prepared a very user-friendly method for working with our open source.
Remember: We do not program strategies for the advisor for free. If you want to develop code for your strategy, please refer to the Programming section to place an order!
First Steps:
- Open the open-source code of the advisor that you purchased from our Market of Advisors;
- Press Ctrl + F to activate the search bar;
- Enter the term Step – This keyword will help you navigate our source code and quickly write your strategy.
- Each step is well-commented and provides an example.
- To learn how to program your strategy, you can gradually uncomment lines marked with an asterisk // *.
In total, there are 10 steps in the open-source code for the advisor to work with your indicators.
We will analyze each step in detail!
Since programming differs between the MT4 and MT5 terminals, we will divide our article into two parts:
If you are using the advisor THE X for the MT4 terminal, you can proceed directly to the Programming section for The X on the MetaTrader 4 terminal.
Programming THE X for MetaTrader 5
You need to understand the basic programming rules to develop your strategy or add a ready-made strategy using indicators from existing files (e.g., Expert Advisors from the Internet).
Programming advisors for MetaTrader 5 is more complex than for MetaTrader 4. However, the MT5 terminal allows for the creation of more powerful strategies and features a more advanced strategy tester.
In any case, you should purchase the open-source code on which the terminal will operate.
MetaTrader 5 Step 0: Loading Indicators into Resources!
// Step 0 ############################################## // This part of the code is for programming your strategy in open source // // To embed the indicator into the Expert Advisor during compilation, you need to load it into the resources of the Expert Advisor // // For example: // * #resource "\\Indicators\\Examples\\MACD.ex5" // ################################################ ###########################
Here, we must add the indicators required by us to the resources.
This ensures that the advisor can be compiled for the market and prevents unnecessary issues where the compiled advisor cannot locate the desired indicator on another computer.
Rules for Naming in the Market: Use the full folder names, starting with Indicators!
The folder is denoted by \\.
For example:
If the path to your indicator is:
C:\ROBO MT5\MQL5\Indicators\Examples\MACD.ex5
Then, the path to this indicator in the programming language is written as:
“\\Indicators\\Examples\\MACD.ex5”
MetaTrader 5 Step 1: Specify the Signal Name!
// Step 1 ############################################## // This part of the code is for programming your strategy in open source // // Enter the name of your signal after // // ################################################ #################### // For example: // * Custom = 77, // Signal For open source // ################################################ ############################
At this step, we must add our signal or strategy to the list of possible signals in the Expert Advisor.
This facilitates convenient management of signals during the expert setup phase.
For example:
- You want to name your strategy MY STRATEGY
- The strategy number must also be unique. Signals from standard indicators occupy the first 22 numbers! Remember this number as we will need it later.
- The name must also be unique. For example, MYSTRATEGY1
In the end, we should write in the code as follows:
MYSTRATEGY1 = 77, // MY STRATEGY
You can also add more strategies and write, for example:
- MYSTRATEGY1 = 77, // MY STRATEGY a
- MYSTRATEGY2 = 78, // MY STRATEGY b
- MYSTRATEGY3 = 79, // MY STRATEGY c
MetaTrader 5 Step 2: Specify the Signal Display Name!
// Step 2 ############################################## // This part of the code is for programming your strategy in open source // // Enter the name of your signal, which will be displayed on the screen after // // ################################################ #################### // For example: // * if (i == 77) s1 = "Custom"; // ################################################ ###########################
This step is to display the name of your strategy in our EAPADpro EA panel.
It’s straightforward! However, you must use the numbers from the previous step.
For example:
- if (i == 77) s1 = “My1”;
- if (i == 78) s1 = “My2”;
- if (i == 79) s1 = “My3”;
MetaTrader 5 Step 3: Specify the Filter Name!
// Step 3 ############################################## // This part of the code is for programming your strategy in open source // // Enter the name of your filter after // // ################################################ #################### // For example: // * FILTERCustom = 77, // Filter For open source // ################################################ ###########################
At this step, we need to add our filter to the list of possible filters in the Expert Advisor.
This ensures convenient management of filters during the expert setup phase.
Typically, the Filter uses the same indicator as the Signal, but with the condition that the Filter determines the current position of the Signal, and the Signal reflects the actual signal.
For example:
- Do you want to name your Filter MY FILTER?
- The filter number should also match the strategy number (This prevents confusion with other figures in the future). Filters occupy the first 22 numbers from standard indicators! Remember this number as we will need it later.
- The name must also be unique. For example, MYFILTER1
In the end, we should write in the code as follows:
MYFILTER1 = 77, // MY FILTER
You can also add more filters and write, for example:
- MYFILTER1 = 77, // MY FILTER a
- MYFILTER2 = 78, // MY FILTER b
- MYFILTER3 = 79, // MY FILTER c
MetaTrader 5 Step 4: Specify the Parameters of the Indicator or Strategy in External Variables!
// Step 4 ############################################## // This part of the code is for programming your strategy in open source // // Specify all external variables of your indicator or indicators that will be used in your strategy // // For example: // * input string IndicatorName = "-------- Custom Indicator ----------------"; // * input int CUSTOMMAFastPeriod = 1; // * input int CUSTOMMASlowPeriod = 100; // * input ENUM_APPLIED_PRICE CUSTOMMAprice = PRICE_CLOSE; // ################################################ ###########################
At this step, you must enter all external settings of the indicators in your strategy, which can be modified from the Expert Advisor. This is useful for optimization purposes.
Additionally, you can extract specific strategy parameters here. For example, the levels where lines intersect, limiting the indicator’s operation to MAX and MIN prices on the chart, and so on.
You do not need to enter all parameters for the indicators. It’s sufficient to make those that you may want to change in the future from the Expert Advisor settings. All other parameters can be set to their default values.
MetaTrader 5 Step 5: Create Indicator Handles to Load into the Expert Advisor!
// Step 5 ############################################## // This part of the code is for programming your strategy in open source // // Create an entry in the array so that the Expert Advisor can assign the indicator handle during initialization // // For example: // * case 77: // * h_custom[tf_num][sym_num] = iCustom(array_symbol, array_tf, "::Indicators\\Examples\\MACD", CUSTOMMAFastPeriod, CUSTOMMASlowPeriod, 9, CUSTOMMAprice); // * if (h_custom[tf_num][sym_num] == INVALID_HANDLE) // * { // * PrintToLogs("Could not get MACD indicator handle"); // * return(INIT_FAILED); // * } // ################################################ ###########################
This step ensures that our indicators are loaded once during the initialization of the Expert Advisor. In MetaTrader 5, there is no need to constantly load the indicator on the chart.
When creating a handle, we store the handle of an already opened indicator for future use.
Be very careful here. When creating a handle, you must specify all external variables of the indicator and use the correct name. Otherwise, the Expert Advisor will not be able to load the indicator.
Remember that we loaded the indicator into the Expert Advisor resources. Therefore, we will call the indicator from the resources!
You can refer to the MQL5 documentation on calling indicators using iCustom.
A strategy number is also required for writing this code. If your strategy uses multiple indicators, you need to specify each indicator with the same number. This ensures that the advisor correctly loads your strategy.
According to our examples above, we need to do the following:
case 77: h_custom[tf_num][sym_num] = iCustom(array_symbol, array_tf, "::Indicators\\Examples\\MACD", CUSTOMMAFastPeriod, CUSTOMMASlowPeriod, 9, CUSTOMMAprice); if (h_custom[tf_num][sym_num] == INVALID_HANDLE) { PrintToLogs("Could not get MACD indicator handle"); return(INIT_FAILED); } break;
Here, I explicitly specified only two external parameters. I replaced the parameter of this Indicator, InpSignalSMA, with a default number to demonstrate the essence of programming!
Similarly, you can add multiple indicators and handles.
If the strategy uses several indicators, you need to declare each one.
For example:
case 77: h_custom[tf_num][sym_num] = iCustom(array_symbol, array_tf, "::Indicators\\Examples\\MACD", CUSTOMMAFastPeriod, CUSTOMMASlowPeriod, 9, CUSTOMMAprice); h_custom2[tf_num][sym_num] = iCustom(array_symbol, array_tf, "::Indicators\\Examples\\MACD", CUSTOMMAFastPeriod, CUSTOMMASlowPeriod, 15, CUSTOMMAprice); if (h_custom[tf_num][sym_num] == INVALID_HANDLE || h_custom2[tf_num][sym_num] == INVALID_HANDLE) { PrintToLogs("Could not get MACD indicator handle"); return(INIT_FAILED); } break;
Additionally, for other strategies you wish to integrate into the Expert Advisor!
MetaTrader 5 Step 6: Declare Variables to Load the Indicator(s) of the Strategy!
// Step 6 ############################################## // This part of the code is for programming your strategy in open source // // Declare the handle array variables // // For example: // * int h_custom[6][12]; // * int h_custom2[6][12]; // ################################################ ###########################
Here, we specify the names of our handles that were created above!
It’s straightforward.
Handles are created as arrays to support multi-currency in the EA and to allow specifying up to six signals or filters simultaneously!
MetaTrader 5 Step 7: Declare Variables for Storing Indicator Data!
// Step 7 ############################################## // This part of the code is for programming your strategy in open source // // Declare the array variables for indicator values // // For example: // * double custom1_buffer[]; // * double custom2_buffer[]; // ################################################ ###########################
Here, we specify the names of our data buffers!
It’s straightforward.
These arrays will store data about the indicator values for each bar. If you need to use multiple buffers, you can declare several variables.
In our case, for example, we need two buffers for the signal line and the main line of the MACD indicator.
MetaTrader 5 Step 8: Create Strategies and Signals for Opening Positions!
This step is crucial for the Expert Advisor. While all other steps are mandatory, without this step, the advisor will not function.
I have included comments in the code to explain each part!
The strategy number must match the one used in previous steps!
- Program the code for each strategy and signal individually. It depends on the chosen strategy and indicators. Handling buffers for strategies involves…
- Note that in this block, you can specify any strategy.
- All the indicators declared in the handles will be loaded into memory and used to build the strategy.
This step can be divided into three substeps:
- 1. We need to copy data buffers to our datasets. In the copy parameters, we must specify the line numbers (In our case, these are MACD indicator lines).
- We use two lines: MAIN and SIGNAL.
- You can read the documentation on the CopyBuffer function.
- 2. Programming the strategy. In this case, it’s the intersection of two lines.
- Important: The signal for BUY is 1, and for SELL, it is -1.
- 3. Here, we record the information that will be displayed in the log when a position is opened based on the signal. Strategy Information.
If you have correctly filled all the handles and buffers, the following should appear on the screen:
Alert(“Congratulations, you’ve completed a lesson demonstrating the programming of your strategy!”);
Alert(“Congratulations! You have completed a lesson demonstrating the programming of your strategy!”);
If you receive an error message, you need to identify and resolve the cause of this error.
Error Codes
Most common errors:
ERR_INDICATOR_UNKNOWN_SYMBOL | 4801 | Unknown symbol |
ERR_INDICATOR_CANNOT_CREATE | 4802 | The indicator cannot be created |
ERR_INDICATOR_NO_MEMORY | 4803 | Insufficient memory to add an indicator |
ERR_INDICATOR_CANNOT_APPLY | 4804 | The indicator cannot be applied to another indicator |
ERR_INDICATOR_CANNOT_ADD | 4805 | Error while adding the indicator |
ERR_INDICATOR_DATA_NOT_FOUND | 4806 | The requested data was not found |
ERR_INDICATOR_WRONG_HANDLE | 4807 | Incorrect indicator handle |
ERR_INDICATOR_WRONG_PARAMETERS | 4808 | Incorrect number of parameters when creating an indicator |
ERR_INDICATOR_PARAMETERS_MISSING | 4809 | Missing parameters when creating the indicator |
ERR_INDICATOR_CUSTOM_NAME | 4810 | The first parameter in the array must be the name of the custom indicator |
ERR_INDICATOR_PARAMETER_TYPE | 4811 | Incorrect parameter type in the array when creating the indicator |
ERR_INDICATOR_WRONG_INDEX | 4812 | Invalid index of the requested indicator buffer |
MetaTrader 5 Step 9: Specify Filters from Your Indicators or Use Your Indicator as a Filter for the Strategy!
The programming code in this step is straightforward and similar to the previous step.
The only difference is that at this stage, you program your indicators as a Filter.
You cannot specify signals using the indicator, but only specify the filter, or vice versa! It all depends on the strategy.
MetaTrader 5 Step 10: This is the final step!
// Step 10 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // This is the end of our code. If you have reached this step, then you have created your strategy. // For example, I entered a secret strategy. If you did everything correctly, you will receive the result in the form of an alert on the screen! // Thank you for choosing our product. We are working for you! // // Our website: // Our store: /shop // MQL5 store: https://www.mql5.com/users/vladon/seller // // // This is the end of our code. If you have reached this step, then you have created your strategy. // For example, I entered a secret strategy. If you did everything correctly, you will receive the result in the form of an alert on the screen! // Thank you for choosing our product. We are working for you! // // Our website: // Our store: /shop // MQL5 store: https://www.mql5.com/users/vladon/seller // ################################################ ###########################
This indicates that the programming of your strategy is complete.
Good luck and profits to you!
MetaTrader 5 Conclusions and Verification of the Strategy
If you do everything correctly, your strategy will be integrated into the Expert Advisor, and you will be able to trade using my advisor.
Now, we need to test our advisor and strategy.
- Load the terminal;
- Open a demo account;
- Attach the Expert Advisor to the chart;
- If all is OK, you will receive a message about the successful addition of the strategy:
- Or you will receive an error. In that case, you need to carefully review your code and repeat all the steps!
Checking the Expert Advisor in the Strategy Tester:
- Open the terminal;
- Open the Strategy Tester;
- Choose your Expert Advisor, currency pair, time frame, and date range. Enable Every Tick testing based on real ticks;
- Open the Settings tab;
- Select your strategy;
- Enable Visualization;
- Press START;
- A graph should open;
- If the Expert Advisor opens positions, you did everything correctly!
Programming THE X for MetaTrader 4
You must understand the basic programming rules to write your strategy or add a ready-made strategy for indicators from an existing file (e.g., Expert Advisors from the Internet).
Programming Expert Advisors for MetaTrader 5 is more complex than for MetaTrader 4. However, the MT5 terminal allows you to create more powerful strategies and features a more advanced Strategy Tester.
On the other hand, there are numerous strategies and indicators available for the MetaTrader 4 terminal online. Therefore, you can use the code for MT4!
Another important reminder: Coding a strategy in MT4 is much easier than coding in MT5!
In any case, you should purchase the open code based on the terminal you will be working with.
MetaTrader 4 Step 0: Loading Indicators into Resources
// Step 0 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // To embed the indicator into the Expert Advisor during compilation, you need to load it into the resources of the Expert Advisor // To embed the indicator into the Expert Advisor during compilation, you need to load it into the resources of the Expert Advisor // ################################################ #################### // for example: // * #resource "\\ Indicators \\ MACD.ex4" // ################################################ ###########################
Here, we must add the indicators required by us to the resources.
This will allow us to compile an advisor for the market and prevent unnecessary issues when the compiled Expert Advisor cannot find the desired indicator on another computer!
Rules for writing the indicator path: Use the full folder names, starting with Indicators!
The folder is indicated by \\
For example:
If the path to your indicator looks like this:
C:\ROBO MT4\MQL4\Indicators\Examples\MACD.ex4
Then, the path to this indicator in the programming language is written like this:
“\\Indicators\\Examples\\MACD.ex4”
MetaTrader 4 Step 1: Specify the Signal Name
// Step 1 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Enter the name of your signal after // // Enter the name of your signal after // // ################################################ #################### // for example: // * Custom = 77, // Signal for open source // ################################################ ############################
At this step, we must add our Signal or strategy to the list of possible signals in the advisor.
This allows for convenient management of signals during the Expert Advisor setup phase.
For example:
- You want to name your strategy MY STRATEGY
- The strategy number must also be unique. Signals from standard indicators occupy the first 22 numbers! Remember this number for future reference.
- The name must also be unique. For example, MYSTRATEGY1
In the end, you should write in the code like this:
MYSTRATEGY1 = 77, // MY STRATEGY
You can also add more strategies and write, for example, like this:
- MYSTRATEGY1 = 77, // MY STRATEGY a
- MYSTRATEGY2 = 78, // MY STRATEGY b
- MYSTRATEGY3 = 79, // MY STRATEGY c
MetaTrader 4 Step 2: Specify the Signal Name for Display on Screen
// Step 2 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Enter the name of your signal, which will be displayed on the screen, after // // Enter the name of your signal, which will be displayed on the screen, after // // ################################################ #################### // for example: // * if (i == 77) s1 = "Custom"; // ################################################ ###########################
This step serves to display the name of your strategy in our EApadpro EA panel.
There is nothing complicated! But you must use the numbers from the previous step.
For example:
- if (i == 77) s1 = “My1”;
- if (i == 78) s1 = “My2”;
- if (i == 79) s1 = “My3”;
MetaTrader 4 Step 3: Specify the Filter Name
// Step 3 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Enter the name of your filter after // // Enter the name of your filter after // // ################################################ #################### // for example: // * FILTERCustom = 77, // Filter for open source // ################################################ ###########################
At this step, we need to add our Filter to the list of possible filters in the Expert Advisor.
This allows for convenient management of filters during the Expert Advisor setup phase.
Usually, the Filter uses the same indicator as the Signal, with the condition that the Filter determines the current position of the Signal, and the Signal confirms the trading action.
Examples of differences between filters and signals
For example:
- Do you want to name your Filter MYFILTER?
- The number of the filter should also match the number of the strategy (This is done to avoid confusion with standard indicator numbers in the future). Filters occupy the first 22 numbers reserved for standard indicators! Remember this number for future reference.
- The name must also be unique. For example, MYFILTER1
In the end, you should write in the code like this:
MYFILTER1 = 77, // MY FILTER
You can also add more filters and write, for example, like this:
- MYFILTER1 = 77, // MY FILTER a
- MYFILTER2 = 78, // MY FILTER b
- MYFILTER3 = 79, // MY FILTER c
MetaTrader 4 Step 4: Specify Indicator or Strategy Parameters in External Variables
// Step 4 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Specify all external variables of your indicator or indicators that will be used in your strategy // Specify all external variables of your indicator or indicators that will be used in your strategy // ################################################ #################### // for example: // * input string IndicatorName = "-------- Custom Indicator ----------------"; // * input int CUSTOMMAFastPeriod = 1; // * input int CUSTOMMASlowPeriod = 100; // ################################################ ###########################
At this step, you must enter all external settings of the indicators used in your strategy, which can be changed from the Expert Advisor. This is useful for optimization.
Additionally, you can extract specific parameters of the strategy, such as the levels of line intersections, the limitation of the indicator’s operation based on MAX and MIN prices on the chart, and so on.
You do not need to enter all parameters for the indicators. It is sufficient to include those that you may want to change in the future from the Expert Advisor settings. For all other parameters, you can leave the indicator with its default settings.
MetaTrader 4 Steps 5, 6, 7: Relax!
// Step 5 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Step 5 is only needed for the MT5 terminal. So at this step, you can relax and have a coffee // Step 5 is only necessary for the MT5 terminal. So at this step, you can relax and have a coffee // ################################################ ########################### // Step 6 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Step 6 is only needed for the MT5 terminal. So at this step, you can relax and have a snack // Step 6 is only necessary for the MT5 terminal. So at this step, you can relax and have a snack // ################################################ ########################### // Step 7 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // Step 7 is only needed for the MT5 terminal. Take a workout break // Step 7 is only necessary for the MT5 terminal. Take a workout break // ################################################ ###########################
Note: MetaTrader 4 does not require loading indicators into memory for further work. When the indicator is called again in MT4, the Expert Advisor uses the same handle.
MetaTrader 4 Step 8: Creating Strategies and Signals for Opening Positions
This step is very important for the Expert Advisor. Although all other steps are mandatory, without this step, the advisor will not function.
I have added comments in the code!
The strategy number matches the one from the previous steps!
- Programming code for strategy and signal individually. It depends on the chosen strategy and indicators. Setting up strategy buffers…
- I want to note that in this block, you can specify any strategy.
- All the indicators that we declared in the handles will be loaded into memory and used to build the strategy.
This step can be divided into 2 substeps:
- 1. Programming the strategy. In this case, it is the intersection of two lines.
- Important: The Signal for BUY is 1, and for SELL, it is -1.
- 2. Record the information that will be displayed in the log when a position is opened. Strategy Information
If you receive an error message, you need to identify the cause of the error.
Most common errors:
ERR_INDICATOR_UNKNOWN_SYMBOL | 4801 | Unknown symbol |
ERR_INDICATOR_CANNOT_CREATE | 4802 | The indicator cannot be created |
ERR_INDICATOR_NO_MEMORY | 4803 | Not enough memory to add an indicator |
ERR_INDICATOR_CANNOT_APPLY | 4804 | The indicator cannot be applied to another indicator |
ERR_INDICATOR_CANNOT_ADD | 4805 | Error while adding the indicator |
ERR_INDICATOR_DATA_NOT_FOUND | 4806 | The requested data was not found |
ERR_INDICATOR_WRONG_HANDLE | 4807 | Wrong indicator handle |
ERR_INDICATOR_WRONG_PARAMETERS | 4808 | Incorrect number of parameters when creating an indicator |
ERR_INDICATOR_PARAMETERS_MISSING | 4809 | Missing parameters when creating the indicator |
ERR_INDICATOR_CUSTOM_NAME | 4810 | The first parameter in the array must be the name of the custom indicator |
ERR_INDICATOR_PARAMETER_TYPE | 4811 | Incorrect parameter type in the array when creating the indicator |
ERR_INDICATOR_WRONG_INDEX | 4812 | Invalid index of the requested indicator buffer |
MetaTrader 4 Step 9: Specify Filters from Your Indicators or Use Your Indicator as a Filter for the Strategy
In this step’s code programming, there is nothing complicated, and it is similar to the previous step.
The only difference is that at this stage, you program your indicators as a Filter.
You cannot specify signals using the indicator, but only specify the filter, or vice versa! It all depends on the strategy.
MetaTrader 4 Step 10: This is the Final Step!
// Step 10 ############################################## ###################### // This part of the code for programming your strategy in open source // This part of the code for programming your strategy in open source // // This is the end of our code. If you have reached this step, then you have created your strategy. // For example, I entered a secret strategy. If you did everything correctly, you will receive the result in the form of an alert on the screen! // Thank you for choosing our product. We are working for you! // // Our website: // Our store: /shop // MQL5 store: https://www.mql5.com/users/vladon/seller // // // This is the end of our code. If you have reached this step, then you have created your strategy. // For example, I entered a secret strategy. If you did everything correctly, you will receive the result in the form of an alert on the screen! // Thank you for choosing our product. We are working for you! // // Our website: // Our store: /shop // MQL5 store: https://www.mql5.com/users/vladon/seller // ################################################ ###########################
This step was created so that you are not lost when using the search.
This indicates that the programming of your strategy is complete.
Good luck and profits to you!
MetaTrader 4 Conclusions and Strategy Check
If you do everything correctly, your strategy will be integrated into the Expert Advisor, and you will be able to trade using my advisor.
Now, we need to test our advisor and strategy.
- Load the terminal;
- Open a demo account;
- Attach the Expert Advisor to the chart;
Checking the Expert Advisor in the Strategy Tester:
- Open the terminal;
- Open the Strategy Tester;
- Choose your Expert Advisor, currency pair, time frame, and date range. Enable Every Tick testing based on real ticks;
- Open the Settings tab;
- Select your strategy;
- Enable Visualization;
- Press START;
- A graph should open;
- If the Expert Advisor opens positions, then you did everything correctly!
What Else Can Be Changed in the Expert Advisor?
Of course, you may want to personalize your strategy and give our advisor a unique appearance!
Parameters that you can change at your discretion:
// Change 1: Version of Expert Advisor // Version of EA #define versionea "18.008" // Change 2: Advisor's logo // LOGO of EA #define BMPLOGO "Images\\dollar.bmp" // Change 3: Icon of the Expert Advisor // Icon of EA // #property icon "\\Images\\dollar.bmp" // Change 4: Name of the Expert Advisor on the chart // Name of EA on Chart #define defEANAME "EXP-The X (OS)" // Change 5: Link to the full instruction // Link to the full instruction #define linkTOfull "www.expforex.com/publ/4-1-0-166" // Change 6: Demo version of the Expert Advisor. Works only on a demo account or on a live account with the USDJPY pair // Demo version of the advisor. Works only on a demo account or on a live account with the USDJPY pair bool DEMO = false;
All other parameters are recommended not to be changed, as this may disrupt the functionality of the Expert Advisor!
Debugging a Strategy
The next step is to test and optimize The X and find your best settings.
Alternatively, debug and upgrade your strategy.
Sometimes, it takes days or weeks. Sometimes, even months.
Forex Market – Risk Notifications! This is a very risky way of earning. Improve your strategy.
Good luck and profit!
Outputting Additional Information in the Strategy Block
This is an optional feature in our open-source code.
You can output any value of any parameter in the EAPADPRO Strategy block.
1. To do this, create a local variable,
e.g., double EAPADPRO_StrategyValue1 = 0; double EAPADPRO_StrategyValue2 = 0;
2. Assign a value to this variable,
for example, assign the value of the ATR indicator (find the line double atr = iATR):
EAPADPRO_StrategyValue1 = atr; EAPADPRO_StrategyValue2 = atrma;
Full filter code:
3. Next, add the value of the variable to the information output block:
Find the function CreateStrategy() in the code and add a new line:
ArrayAddStrategy("StrategyValue1", DoubleToString(EAPADPRO_StrategyValue1, 5), "", ""); ArrayAddStrategy("StrategyValue2", DoubleToString(EAPADPRO_StrategyValue2, 5), "", "");
The first parameter of the function is the name of the variable.
The second parameter of the function is the value of the variable in a convenient format!
Attention! Add an even number of parameters to ensure a neat display on the screen!
관련 게시물
Market Time Pad. 거래 세션이 포함된 MetaTrader용 지표
타임 인디케이터는 주요 글로벌 시장의 현재 시간을 표시하고 활성 거래 세션을 강조합니다. 사용이 간편하며 차트에서 공간을 최소화하여 Expert Advisors…
Tester Pad은(는) 전략 테스터용 Forex 거래 시뮬레이터입니다. 지표를 사용한 거래.
전략 테스터 차트에서 원클릭 거래. 유틸리티를 사용하여 전략 테스터에서 전략을 수동으로 테스트할 수 있습니다. 시각화 차트에서 원클릭 거래. 거래 기술을 테스트하기…
Duplicator – MetaTrader 터미널에서 거래/포지션 복제
Exp-Duplicator는 MetaTrader 계정에서 거래 및 포지션을 미리 설정된 횟수만큼 복제하도록 설계된 자동 전문가 고문(Expert Advisor)입니다. 수동으로 열리든 다른 EA에 의해 열리든…
Tick Hamster 자동 거래 로봇. 추가 기능 없음!
Tick Hamster – MetaTrader의 모든 거래 심볼에 대한 자동 최적화를 갖춘 전문가 고문 Tick Hamster는 신규 트레이더 및 설정이 필요 없는…
AI Sniper. MetaTrader용 자동 스마트 전문가 어드바이저.
AI Sniper는 MT4 및 MT5 단말기를 위해 설계된 지능적이고 자기 최적화가 가능한 거래 로봇입니다. 스마트 알고리즘과 고급 거래 전략을 활용하여…
Averager. 거래 포지션 평균화. 추세에 반대하고 추세에 맞춰 거래 개시!
포지션 평균화. 일반적인 트레일링 스톱 기능을 사용하여 추세에 맞춰 및 추세에 반대하여 추가 포지션을 개설! 어드바이저는 추세에 맞춰 및…
SafetyLOCK PRO 반대의 보류 주문을 열어 포지션을 잠금으로써 보호합니다. 헤지
SAFETYLOCK: 급격한 시장 반전에 대비하여 거래를 보호하세요 금융 시장에서의 거래는 특히 급격한 시장 반전 시에 높은 위험을 수반합니다. SAFETYLOCK은 기존 포지션에…
TickSniper와 Expforex의 최고 자문가의 거래 보고서
설명 우리는 전문가 TickSniper, Good Santa, Tick Hamster, The X, 의 요약 및 상세 거래 결과를 실제 거래 계좌에서 요약했습니다. 우리의 전문가 어드바이저의 거래 통계입니다. 보고서를 자세히…
EA The xCustomEA: 범용 거래 어드바이저. 맞춤형 전략 빌더
MetaTrader용 맞춤형 지표에 대한 범용 거래 어드바이저. Exp – The xCustomEA 범용 거래 어드바이저는 맞춤형 지표에서 작동합니다. The xCustomEA는 맞춤형 지표와…
스윙 전략 (펜듈럼). 2개의 반대 보류 주문 자동 개설, OCO
펜듈럼 또는 스윙 전략은 로트 크기를 증가시킨 보류 주문의 순차적 개설을 포함합니다. 핵심 원리는 간단합니다: 두 개의 보류 주문이 설정되고,…
CLP CloseIfProfitorLoss. 트레일링 프로핏을 사용한 총 이익 또는 손실 관리.
Expert Advisor (EA)는 MetaTrader에서 포지션을 관리하고 종료하기 위한 고급 기능을 제공하며, 특히 사전에 설정된 총 이익 또는 손실 수준에 도달할…
TickSniper MetaTrader용 자동 전문가 어드바이저. Tick 스캘퍼
Exp-TickSniper는 각 통화 쌍마다 별도로 매개변수를 자동으로 선택하는 빠른 Tick 스캘퍼입니다. 이 EA는 거의 10년간의 EA 프로그래밍 경험을 바탕으로 개발되었습니다. 이 EA는…
Close Minus by Plus, 수익성 있는 포지션을 검색하고 종료하여 손실
수익성 있는 포지션을 식별하고 종료하여 손실 포지션을 종료합니다. 전문가 고문(EA)은 수익성 있는 포지션을 식별하고 종료하여 손실 포지션을 종료하도록 설계되었습니다….
Assistant – 실제/가상 스탑로스 / 테이크프로핏 / 트레일링 스탑을 지원하는
스탑로스, 테이크프로핏, 트레일링 스탑, 브레이크이븐 레벨 자동 설정, 가상 스탑 활성화. Exp Assistant는 포지션 유지 관리를 조직하는 데 도움을 줍니다. 이 전문가…
이 게시물은 다음 언어로도 제공됩니다: English Українська Portuguese Español Deutsch Chinese Русский Français Italiano Türkçe 日本語 한국어