Include all EA development stages to the Requirements Specification —
1. The idea of the trading system is as follows: market entries are performed when MACD's
main and signal lines intersect in the current trend direction.
2. Trend is determined based on the Exponential
Moving Average with the specified period (InpMATrendPeriod). If the current EMA value is greater than the previous one, the trend is
seen as growing (ema_current > ema_previous). Alternatively, if current EMA is below the previous one, the trend is considered to be
falling (ema_current< ema_previous).
3. Trading Signals:
4. Positions are closed at opposite signals: Buy positions are closed at Sell signals, and Sell positions are closed at Buy signals.
5. Positions are opened at the market price, when a new bar emerges. The Expert Advisor is to be tested using Open prices, so
there is no need to add functions for disabling operations inside the bar.
6. Additional filters for opening a position:
The absolute value of MACD's main line will be used to filter out weak signals: the signal is only confirmed if this value is greater than
open_level (in points). Signal confirmation conditions are as follows:
7. Additional filters for closing a position:
The absolute value of MACD's main line will also be used to confirm position closure: the signal is confirmed if this value is greater than
close_level (in points). Close signal confirmation conditions are as follows:
8. Close by Take Profit — during position opening, a Take Profit level is set at a fixed distance from the open price, specified
in points. The value is set in the InpTakeProfit input parameter.
9. Position management
is used to protect profit. Stop Loss is set if profit in points exceeds the value specified in the InpTrailingStop parameter. If the price
continues to move in the profit direction, Stop Loss should be trailed at the given distance. Stop Loss cannot be moved towards the loss
direction, i.e. the Stop Loss value cannot be increased. If none of protective orders (Take Profit or Stop Loss) triggers, the position
should be closed by an opposite signal. No other position exit methods are available.
Describe the general underlying idea in the first part of the Requirements Specification. Example: "If the price approaches the resistance level twice and rolls back from it, the next time it is likely to break resistance." Here you can add a chart with the resistance/support lines, indicators and explanatory notes. Exact numbers or calculation algorithms are not required in the idea description. So, in this example we do not need to explain how to determine:
Some abstraction at the initial stage will help focus on the idea rather than on technical details. This way you can generate multiple modifications of your trading strategy by replacing or combining strategy blocks, indicators and filters. With the common general idea, you will use different input parameters for your trading robots.
If trend is important for your strategy, clearly define what indicator should be used to determine the trend direction and strength. The numerical characteristics of these definitions form the basis of Expert Advisor's input parameters, and can be optimized in the Strategy Tester. So, the first section of the Requirements Specification is "The Trading Idea".
Terms and definitions
It is recommended to create a separate section in the Requirements Specification for explaining related terms and definitions. Explain terms in separate paragraphs. Use bold font to highlight the key concepts of your trading strategy. Where applicable, you may add an image. Input parameters of the desired EA can be written in italics.
This is the most important section of Requirements Specification. It provides the description of conditions, market states and indicator
values, under which a Buy deal should be performed. To describe each condition required for generating a Buy signal, choose the numeric
parameter affecting the emergence of a signal. For example, this may be the smoothing type and period for a
Average. These important parameters will be used as your Expert Advisor's input parameters.
(Provide a separate description of sell conditions, even if they are opposite to buying. This may have specific features, which the programmer may misinterpret. For example, your Buy condition may be set to "Value > 0". Make sure to indicate an exact condition for selling, such as "Value < 0.1" or "Value <= 0.1".)
Additional conditions and filters are often used for confirming or canceling trading signals. Use screenshots for various market situations with
visual explanation of indicators and setups. In future, such visualization may help you to analyze situations, when your EA ignores
a seemingly obvious signal or performs a deal at an unfavorable moment.
Screenshots and flow charts
You may use any of free programs for creating screenshots and flow charts. Tips on what programs to choose and how to use them are provided in the article How to create Requirements Specification for ordering an indicator. Also, the article provides recommendations on ordering an arrow indicator generating buy and sell signals. Such an indicator running separately from the Expert Advisor, makes it easier to check and monitor your trading robot both during real-time operation and in visual testing.
The lifetime of signals/orders/positions
The second important part of a trading strategy is exiting an open position and deleting pending orders. Trading signals can also be canceled
after some time or under certain events. Therefore, you need to describe conditions to close a buy/sell position, remove a pending order or
cancel a signal.
Management of open positions and pending orders
If your trading strategy implies closing by Stop Loss and Take Profit, describe the calculation algorithm. Optionally, you can request a
trailing mechanism for a flexible modification of these levels. In this case, you need to describe Trailing Stop conditions and
algorithms. SL/TP modification can be performed at a bar opening or on every tick. Specify the desired option in the Requirements
Specification. Also, the on-tick and on-bar options influence strategy testing. Make sure to read the article
Testing trading strategies on real ticks.
A poorly drafted Requirements Specification or its absence often indicates that the trading system rules have not been formulated. So, what the Customer calls a trading system is actually only an idea. All nuances and absence of required logic descriptions will be revealed during the development process. The developer will have to think out possible options, which were not provided by the Customer.
The Developer may program a trading robot at his own risk in this case. But you are likely to lose much time discussing every possible issue. If the robot's behavior then differs from the Customer's expectations due to a lack of a proper description, such an order may be sent for an Arbitration. Customers often accuse the Developer for the incorrect programming of the robot. However, the Arbitration decision will be based on the Requirements Specification. According to the Freelance Rules, any other correspondence will not be taken into consideration during disputes:
Sometimes, a customer may have clear trading rules, but may not be able to create the Requirements Specification for some reasons. Problems may arise with the correct description, math formulas, neural network or machine programming related issuers, and other aspects. In this case, the creation of the Requirements Specification can be ordered. This can be done in the "Programming Advice" or "Other" sections of the Freelance service.
Choose one of these categories, create an order named "Creating Requirements Specification for a trading robot order" and specify the initial cost of the work. An experienced developer of trading systems will help you to describe your strategy Rules in a clear and easy-to-understand form. Use screenshots to show setups of your trading signals based on charts, indicators and graphical objects you use.
The programmer will try to understand your trading system and help you prepare a description of the trading algorithm. If you cannot
formulate any concepts (for example, "momentum" or "rebound from the level"), the programmer can suggest ready ideas based on his
experience. As a rule, any market situation can be described logically (and then programmatically) by some simple model with variation
parameters. Such a variation can be expressed by a certain parameter, which you will later optimize in your Expert Advisor.
Perfect patterns do not exist, because the market never repeats. However, similar situations can be found in history. Your cooperation should
result in a ready Requirements Specification, which you may use to order a trading robot.
Often, trading systems contain a number of key concepts or terms describing the market state or price behavior. Even if you think that you use generally accepted and simple concepts in the Requirements Specification, better provide its clear description. Add one description paragraph per each term.
For example, according to Bill Williams, an uptrend occurs when all three Alligator lines appear in the following order from bottom up: Blue, Red, Green.
Another classic definition of an uptrend was suggested by Larry Williams: each new peak is higher than the previous peak and each new trough is not lower than the previous trough.
You may additionally use chart screenshots in term descriptions. Use bold fonts for the terms in the Requirements Specification to help programmer find them in the text whenever necessary.
Do not use place links to other resources (such as websites, publications, forum topics, etc.) instead of explanations. A complete
detailed explanation of all points should be available straight in the Requirements Specification. Take your time to describe all terms
used - this will save the robot development time.
When creating an order, describe the general essence of your trading idea, so that potential developers understand what you need. Do not reveal your trading system rules or details of indicators in the order description.
The description might look like this:
Develop an Expert Advisor trading trend reversals. Reversal signals will be generated based on Price Action patterns. Trend will be determined based on ADX, Alligator and MACD, while the indicator selection should be available in the EA's input parameters.
You may mention symbols to be traded, trend identification specifics and other information. For trend following EAs, specify entry methods
- during a rollback, at a breakout or other methods.
Generally, there are two large types of financial trading strategies: expecting movement continuation or return to the average value. Your trading
idea should relate to one of these two types. Explain how deals should be opened: by market, after a confirmation of a breakout/rollback or at
a more appropriate price.
Simple signals can be easily described using algorithms. For example, popular simple patterns include "Engulfing" and "Pin bar". However, it is practically impossible to create a profitable strategy based on such simple formations. Such patterns are used for determining trend reversal points. The setup for waiting for the Bearish Engulfing pattern is the presence of an uptrend.
So, in addition to describing the trading signal, you should explain an appropriate setup in the Requirements Specification.
A buy or sell signal emerges when a certain condition is met. For example, a classic Buy signal appears when the price crosses the Moving Average upwards. You should indicate the following parameters in this signal description:
Also, the phrase "the price crosses the Moving Average" needs explanation, because it is not as simple as it may seem. A signal can emerge at the very moment of intersection. Alternatively, you may choose to wait for the candlestick to break the MA and close above it. This affects your Expert Advisor code, as well as the tick generation mode to be used during testing.
Therefore, you need to clearly explain the concepts of trend, level, breakout, crossover and similar ones, i.e. choose between operations with
ticks, bars and Close prices. Provide formal descriptions and numeric parameters which you will optimize in the Strategy Tester. For
example, trend strength can be measured using the
indicator, while Ichimoku
Kinko Hyo is not suitable for this purpose.
The more conditions and filters your trading system needs, the more complex the robot turns out. Also, complex strategies normally have a large number of input parameters, which may require a lot of passes during optimization. Although the MetaTrader 5 Strategy Tester allows speeding up the optimization time through the use of the genetic algorithm and MQL5 Cloud Network, the volume of resulting data will also be huge.
Therefore, we recommend following some EA developing and debugging rules.
Also, you can optimize the parameters of the strategy separately for buying and selling, and then combine the algorithms in a single trading
robot. This way, search for optimal parameters will be performed faster with fewer errors. However, in this case you will need to pay
additionally for the creation of indicators and intermediate Expert Advisors. But a good trading idea is worth it, isn't it?
In some trading systems, a position is not opened immediately after the emergence of a signal. Such system may require confirmation by additional signals. For example, after the breakout of the resistance level, you may want to wait till the price returns to the broken level, in order to enter the market under better conditions. You should define the time parameter here: how long the Level Breakout signal will be valid. Systems may wait for 5 bars or until the trading session end, after which the signal is canceled.
Add the Lifetime parameter to use additional filters, which may improve trading system quality.
You may provide additional functions in advance, when developing functions sending trade orders. For example, you may use different MagicNumbers
and comments for further analysis of trading and
optimization results. You may use MagicNumber based on entry hour and day, a trading pattern number and other details, which enable
additional analysis. So, you can implement multiple trading strategies in one Expert Advisor and optimize all of them, to find the best
parameters for your trading robot. If you want to request such functionality, describe the MagicNumber calculation algorithm for each
A trading order is not always executed successfully. It is necessary to provide for situations when the position cannot be opened/closed during the first attempt. How should the EA handle such a situation: should it make a pause or wait for a new tick? How many attempts are allowed? What information should be written to logs? In what format should information be written? Should a notification be sent to a trader? How often should messages be sent to avoid DDoS attack situations?
Use comments to trading orders for quick analysis of trading history. Sometimes, trade servers write specific comments to this field. Therefore, your robot may additionally write its own daily log of trading operations.
If your trading strategy uses protective Stop Loss and Take Profit levels, describe an algorithm for their calculation and placing
methods. For example, Stop Loss can be set only when the price moves by a specified number of points in the profit direction. If SL and TP are to
be set after a successful position opening, describe the procedure to check the position opening - immediately after sending a trading
order or at the next tick.
The basic rule of trader: let your profits run and cut your losses. In algorithmic terms, this means that you should set a protective Stop Loss for each position without limiting potential profits by Take Profit orders.
The stop order size can greatly affect trading results. Often, traders try to find optimal SL/TP distances to maximize profits. Try to find distance calculation algorithms which take into account market volatility, trend direction and support/resistance levels.
You may study existing trading systems to find a suitable SL/TP idea. Many programmers have ready-made libraries, which can be used when
creating a trading robot based on your idea.
Consider and describe the following points in the Requirements Specification:
Another position and order management method is based on time and opposite signals. You may describe additional closure and deletion options,
Some traders include trading lot calculation algorithms at the first stage of robot creation. However, it is not recommended to include the
money management algorithms for calculating the lot at this stage, since additional input parameters can lead to history-based
overfitting during EA optimization.
Better test your first EA version using a fixed lot. Only forward testing using history data and several-month real trading will enable you to reveal the weaknesses and strengths of your algorithm, after which you can add money management methods.
Here are some approaches to calculating position lot size:
In any case, before adding lot calculation algorithms to the Expert Advisor, make sure that your trading system has an advantage over random
trading. Otherwise you will only deceive yourself. A losing system cannot be turned into a profitable one only through money management
A trading robot is an autonomous program, which operates 24 hours a day. Therefore, provide mechanism to control its operation. Your Expert Advisor actions can be written to the Experts journal using the Print() function. In general, it is recommended to record the emergence of signals, patterns and setups, the current market price and trade request parameters before sending an order for execution.
If trade request execution fails, its results should also be written to the log. Analyze trade server return codes to understand the reason for the failure and to fix it. Describe the following in the Requirements Specification:
Detailed logs of trade orders and execution results will allow you to quickly identify trade errors and save your money.
An important point often forgotten by beginning algo traders is the restart of the terminal and loss of Internet or server connection. In
such cases you may request the possibility of notification via
messaging functions or e-mail.
With each price change, the robot starts processing the NewTick event by the OnTick() function. A lot of ticks can be received during a bar lifetime, so the EA will execute its logic at each incoming bar. If your strategy produces signals only at the opening of the bar, then you need to decide the following:
Let's analyze a simple example: a signal at the intersection of moving averages. If your EA checks a signal at each tick, then there may be a situation where the signal appears and then disappears. As a result, the EA will open and close the position several times during one bar. This may cause problems during online trading.
To avoid such problems, test the Expert Advisor in the "Every Tick" or "Every
Tick Based on Real Ticks" mode. If you see a lot of similar operations within one bar, then revise your robot's code. Make sure to perform
testing of the Expert Advisor and used indicators, to check their operation on different history intervals directly on the chart.
If you are a beginner, choose systems operating at new bar opening. Such strategies are easier to develop and debug, while you will only need
to provide a proper handling of the
New Bar event. You can check the correctness of the Expert
Advisor trading at bar opening: testing results in the "Open Price Only" must match results in the "Every Tick"/"Every Tick Based on Real
Trading systems operating inside a bar are more difficult. We recommend reading the article How
to quickly develop and debug a trading strategy in MetaTrader 5, which contains the description of all steps required to create, debug
and optimize the code of a strategy based on the analysis of the continuous tick flow.
When developing a scalping robot, note that such strategies are extremely sensitive to spread, commission, network delays, history quality and performance speed. Any worsening in trading conditions can "kill" such a strategy.
Do not confuse scalping strategies which try to quickly enter the market and catch small guaranteed profit, with so-called pipsing
strategies. Pipsing strategy can be targeting a few pips and tolerate a drawdown of tens and hundreds of pips. Developers of such systems
believe that the price is likely to pass several points in the open position direction than 50-100-300 points in an unfavorable direction.
As a result of optimization, they can achieve impressive results on history, with 90-99% of trades winning. When you run this robot on a real
account, the strategy may show expected profits for some time. But the market can make a sharp move at some point, and everything earned will
Sometimes, algo traders try to improve results by increasing the number of orders/positions in one direction and manipulating lot value depending
on price level/drawdown/loss (technical solutions), rather than improving the quality of signals (strategic solutions).
Additions in the form of order grids, martingale/anti-martingale elements and losing position averaging techniques complicate the code and increase the possibility of a program error. Also, such additional parameters increase the risk of overfitting. The use of such methods does not increase the stability or profitability of a trading system, but can only delay the collapse.
Instead of using such tricks, we recommend choosing another way:
A portfolio of simple trading systems will be more resistant to market changes than one complex system with multiple optimizable input
So, you want to implement your trading system in the form of an Expert Advisor: you have created an order in Freelance and received
applications from different developers. How to choose the optimal Developer in terms of cost and quality?
An experienced developer will not tell you about the complexity of previously developed systems or trading system variations, but will ask
your Requirements Specification. In other words, he will not try to impress you. Professionals appreciate time, so they usually do
not waste it on philosophical discussions about the nature of trading or difficulties of programming.
The developer may request more details, in addition to the provided short description. If the order is generally clear, the programmer will
provide information on the order cost and time.
A responsible Developer will point to unclear points in your Requirements Specification. If your order lacks detail, you can clarify them
later with the programmer, as well as pay for consulting services, increasing the time and cost of the order.
A good programmer appreciates time, so he will try to clarify unclear points in order to start working with a clearly and thoroughly
prepared Requirements Specification.
It may happen that a trading robot based on your system will show losses during testing, although you checked it manually and were sure
that the strategy would be profitable. As a rule, the reason is that the Customer was able to check the system manually using a short time
interval. The Strategy Tester allows getting trading results for any available historic interval. What can be done in this case? A
programmer cannot make a profitable strategy out of a losing one, but he can suggest some ideas for improving the quality of entries. For
example, you may add some trend, volume or other filters to avoid false signals.
Also, your strategy may work better with other parameters which may suit better for given market condition. Optimize the EA to study
dependence of optimal values on the year, volatility and other factors. This will help you identify weaknesses or limitations of your
system. But you will have to do it yourself, because the Developer is only a code programmer, but not a trading system analyst.
The last part concerns programmer's errors. It is almost impossible to develop a program without errors. These may include code errors, when a wrong code is written for a correct algorithm, as well as logical errors. In both cases, you will have to find them yourself.
Also provide a video on how to install the EA on my pc and also make yourself available when i want you to install the EA for me on my PC using Team
Viewer .Thank you