概要 エキスパートアドバイザー(EA)を作成し、任意のインジケーターを使用して戦略をテストすることは、テンプレートやオープンソースリソースを利用することで簡素化できます。オープンソースの利点を活用して、効果的な戦略を構築しましょう。 以下は、Expforex.comのMQLオープンソーステンプレートを使用して、わずか5分でEAを作成するためのステップバイステップガイドです。 オープンソーステンプレートを使用したEA作成のステップバイステップガイド オープンソーステンプレートのダウンロード: Expforex.comにアクセスし、オープンソースセクションに移動します。ここでMetaTrader 4 (MT4)およびMetaTrader 5 (MT5)用のMQLテンプレートを見つけることができます。 プラットフォーム(MT4またはMT5)に適したEAテンプレートを、使用したいインジケーターに基づいてダウンロードします。 テンプレート構造の理解: テンプレートには、インジケーターからのシグナルに基づいてポジションの初期化、オープン、クローズなどの基本的なEA機能を処理する事前に記述されたコードが含まれています。 テンプレートの主な要素には以下が含まれます: …
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!
関連記事
Forex Tester Padは、ストラテジーテスター用の取引シミュレーターです。インジケーターを使用した取引。
ストラテジーテスターのチャートでワンクリック取引。ユーティリティを使用すると、ストラテジーテスターで戦略を手動でテストできます。ビジュアライゼーションチャートでのワンクリック取引。 取引スキルをテストするための便利で完全な機能がストラテジーテスターにも利用可能になりました。…
The X – 標準インディケーターを使用したForex用ユニバーサルエキスパートアドバイザー (EA)
MetaTrader用の機能豊富なユニバーサルエキスパートアドバイザー (EA) エキスパートアドバイザーThe XはMetaTrader用の多用途なトレーディングツールであり、幅広い機能とカスタマイズ可能な設定を提供します。 標準インディケーターと連携し、内蔵のストラテジービルダーを含んでいるため、トレーダーは自分のニーズに合わせて戦略を作成および調整できます。…
AI Sniper。MetaTrader の自動スマートエキスパートアドバイザー。
AI Sniper は、MT4 および MT5 ターミナル用に設計されたインテリジェントで自己最適化可能な取引ロボットです。スマートなアルゴリズムと高度な取引戦略を活用して、取引の可能性を最大化します。 取引所および株式市場で15年の経験を持ち、革新的な戦略管理機能、追加のインテリジェント機能、ユーザーフレンドリーなグラフィカルインターフェースを開発しました。…
スイング戦略(ペンデュラム)。2つの反対の保留注文の自動オープン、OCO注文。
ペンデュラムまたはスイング戦略は、ロットサイズを増加させた保留注文の順次オープンを伴います。基本原理はシンプルです:2つの保留注文が配置され、1つがアクティブになると、もう1つは自動的に新しい保留注文に置き換えられます。このプロセスは、利益確定目標に達してすべての取引グループがクローズされるまで続きます。…
Extra Report Pad – トレーダーズダイアリー。あなたの取引アカウントをプロフェッショナルに分析します。ライブチャートの MyFxBook。ExtraReportPad
Extra Report Pad – 取引アカウントを分析するためのプロフェッショナルなソリューション 今日では、複数の通貨ペアで同時に取引することが不可欠です。しかし、取引が増えるほど、アカウントの収益性を分析することが難しくなります。月ごとに取引を分析することはさらに難しく、各取引の統計データを個別に計算することはさらに困難です。 私たちは解決策を見つけました:私たちのパネルは、リアルタイムであなたのアカウントを分析し、可能な限り詳細な統計をまとめることができます。…
EA The xCustomEA:ユニバーサルトレーディングアドバイザー。カスタムストラテジービルダー
MetaTrader用のカスタムインディケーターに対応するユニバーサルトレーディングアドバイザー。 Exp – The xCustomEA ユニバーサルトレーディングアドバイザーはカスタムインディケーターで動作します。The xCustomEA はカスタムインディケーターと連携し、MT5およびMT4ターミナル用の取引戦略をプログラムできます。 言い換えれば:The xCustomEA はインターネットやmql5マーケットからダウンロード可能なカスタムインディケーターと接続されています。 インターネット上の任意のカスタムインディケーター! ストラテジービルダー。…
Duplicator – MetaTraderターミナル上での取引/ポジションの複製
Exp-Duplicatorは、自動的なエキスパートアドバイザーであり、MetaTraderアカウント上で取引とポジションを事前設定された回数だけ複製するように設計されています。 手動で開かれたものでも他のEAによって開かれたものでも、すべてのポジションをシームレスにコピーし、これらのポジションのロットサイズ(ボリューム)を増やすことができます。…
EAPadPRO – 私たちのエキスパート向け情報パネル。エキスパートアドバイザーのダッシュボード
MetaTraderターミナル用のすべてのアドバイザーおよびユーティリティの情報パネル。 当社の取引エキスパートアドバイザーでEAPADPROパネルを管理および使用する基本についての詳細な指示。 当社のユーティリティを便利かつ成功裏に使用するための親しみやすく直感的なユーザーインターフェース。 戦略テスターでも!…
EAPADPROライブラリ – 当社のパネルをEAに追加する
EAPADPROライブラリ – 当社の情報パネルでエキスパートアドバイザー(EA)を強化 EAPADPROライブラリは、MetaTraderプラットフォーム上でエキスパートアドバイザー(EA)の機能を向上させたいトレーダーにとって、堅牢なソリューションを提供します。…
TickSniper と Expforex の最高のアドバイザーのトレード レポート
説明 私たちは、専門家 TickSniper, Good Santa, Tick Hamster, The X, の要約および詳細な取引結果を実際の取引口座でまとめました。 当社のエキスパートアドバイザーの取引統計です。 レポートを詳細に検討し、結論を導き出しましょう。 序文 おそらく、私たちのロボットに対する3分の1の質問は次のとおりです: あなたのアドバイザーと取引することでどれくらいの利益が得られますか? エキスパートと取引することで取引が何%増加しますか? EAは月にどれくらい稼げますか? ドローダウンはどれくらいですか? どのアドバイザーを選べば良いですか? 当社の取引 Forex プログラムの簡単な説明を試み、皆様の質問にお答えします。これらは単なる言葉ではなく、実際の取引口座のレポートです! 何がこれより良いでしょうか? どの取引エキスパートアドバイザーについて議論しますか? TickSniper – プロフェッショナル向けのオープン設定を持つ自動取引アドバイザー Good Santa – 初心者向けの小さな設定を持つ自動取引アドバイザー Tick Hamster – 初心者向けの設定なし自動取引アドバイザー The X – 21の標準インジケーターと多くのポジション管理機能を持つ汎用取引システム。 EAの助けを借りて月間利益額と最大ドローダウンについての質問に答えます: 取引ロボットの収益性とドローダウンは、取引EAだけでなく、以下の要因にも依存します: このForex取引シグナルは見積もりから来ています! すべては現在の価格に依存し、取引シグナルを形成します。 取引口座の初期残高; この取引バランスで使用されるリスク; 取引ロット; 見積もりの動きに影響を与えるグローバルな要因とニュース、およびオープンポジションの運命を決定します。 最高の取引アドバイザーがここにあります! おすすめのブローカーと取引口座 : おすすめのデポジット 低リスク $1,000 で、最低ロット0.01 3通貨ペア(例:EURUSD, USDCHF, USDJPY) おすすめのデポジット 中リスク $300 で、最低ロット0.01 1通貨ペア(例:EURUSD) おすすめのデポジット 高リスク $100 で、最低ロット0.01 1通貨ペア(例:EURUSD) フローティングスプレッド(ゼロスプレッドは禁止!) 1:300以上のレバレッジ $1,000以上のデポジットがある口座には、PRO StandardまたはECN PROタイプの口座をお勧めします。 $1,000未満のデポジットがある口座には、PRO Centタイプの口座をお勧めします。 タイムフレームは関係ありません。アドバイザーは見積もりのみで動作します。 通貨ペア:任意の通貨ペアを選択できます。私はEURUSD, USDCHF, USDJPYで取引しています。 分析ツール Extra Report Pad およびその他のソース もちろん、このようなロボットを作成する際には、その動作に関する 詳細なレポート を取得することを確認しました。 したがって、当社の 取引統計の収集および分析のための分析ツール ExtraReportPad ( リンクをクリックして当社のインジケーターをダウンロードしてください! 無料 ) このインジケーターは他のものと異なり、次の点で際立っています: 無料! リアルタイムレポートを作成します。 各取引の最も詳細なレポート 通貨ペア、マジックナンバー、コメント、月、時間などの取引活動に関する一般的なレポート。 インストールは簡単です: …
Copylot – MetaTrader用の外為取引のコピーソフト。ターミナル間のコピア
MetaTrader用トレードコピア。 あらゆるアカウントから外為の取引、ポジション、オーダーをコピーします。 COPYLOT MT4バージョンの中でMT4-MT4, MT5-MT4の最高のトレードコピアの1つです(またはCOPYLOT MT5バージョンのMT4-MT5, MT5-MT5に対応しています)。 独自のコピーアルゴリズムは、すべての取引をマスターアカウントからクライアントアカウントに正確にコピーします。…
InfoPad、MetaTrader用オンライン情報パネル
InfoPadは、MetaTraderターミナルで選択された特定の通貨ペアに関する重要な情報を提供するために設計された非常に有用な情報パネルです。 このパネルは、現在のBidおよびAsk価格、スプレッド、高値と安値などの詳細でリアルタイムなデータを提供します。…
Partial Close and Trailing. ロールバック時の部分クローズ
Partial Close and Trailingは、ロールバック中にポジションの一部(ロットの一部)をクローズするEAアシスタントです。 価格が最初に利益の方向に動き、その後リトレースすると、EAは利益の出ているポジションを部分的にクローズします。…
Assistant – 実際の/仮想のストップロス /テイクプロフィット /トレーリングストップ をサポートする最高の無料トレーディングパネル
ストップロス、テイクプロフィット、トレーリングストップ、ブレイクイーブンレベルの自動設定、仮想ストップの有効化。 Exp Assistant はあなたのポジションのメンテナンスを整理するのに役立ちます。 このエキスパートアドバイザーは、あなたのポジションに必要なすべてのストップロスとテイクプロフィットレベルを設定します。 すべてのエキスパートアドバイザーの操作はチャート上のコントロールパネルから管理されます。…
この記事は次の言語でもご覧いただけます: English Українська Portuguese Español Deutsch Chinese Русский Français Italiano Türkçe 日本語 한국어