Expert Advisor Framework

Los mejores corredores de opciones binarias 2020:
  • Binarium

    1er lugar! El mejor broker de opciones binarias!
    Ideal para principiantes! Entrenamiento gratis! Bonos de registro!

  • FinMax

    2do lugar! Gran corredor!

Framework Expert Advisor

Framework Forex expert advisor uses three Commodity Channel Index (CCI) indicators crosses to determine position opening and closing. It is very simple, yet effective expert advisor. It also performs checks for available free margin to stop trading if it is bankrupt. This EA doesn’t trade if bars didn’t change or there were no 100 bars yet.

Warning! The latest backtest of this expert advisor on the period from 2006-11-20 through 2020-01-24 has shown a complete account wipeout.

Do not run this EA on a live account! Use for educational purpose only. The backtest results presented below are outdated.

My test of Framework MetaTrader expert advisor gave a very good result using GBP/JPY pair on a daily chart using just 0.1 standard lots – about $20,000 profits over $10,000 account in one year, with just about $2,000 maximum drawdown. I’ve also checked it on a three years period and its performance showed the same stability.


What are the stop-loss and take-profit used by this EA?

It uses 255 pip take-profit, but doesn’t use a stop-loss on its orders. It should be on to close your orders when they are losing. The average losing order is 503 pips.

How often does it trade?

On daily GBP/JPY chart (the optimum settings) this EA will trade 2-3 times a month on average.

This EA is ECN-compatible. You must set ECN_Mode input parameter to true in order to enable ECN-compatibility for this expert advisor. Otherwise, you will most likely be seeing OrderSend Error 130 messages when EA will be trying to open positions. This is because, if you are trading with an ECN broker (with market execution for orders), you cannot set SL/TP on position opening. You have to open a position first without SL/TP and only then modify it, adding stop-loss and/or take-profit level.



Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.

Do you have your own trading results or any other remarks regarding this expert advisor? Discuss Framework with other traders and MQL programmers on the experts forums.

MQL5 Cookbook: Developing a Framework for a Trading System Based on the Triple Screen Strategy


When searching for or developing trading systems, many traders must have heard about the Triple Screen strategy introduced by Dr. Alexander Elder. There are lots of people in the Internet whose judgment on that strategy is negative. However, many people believe that it can help one to profit. You do not have to trust either of the two opinions. Everything should always be checked first-hand. If you study programming, it’s all in your hands as you can check the trading strategy performance using back-testing.

Los mejores corredores de opciones binarias 2020:
  • Binarium

    1er lugar! El mejor broker de opciones binarias!
    Ideal para principiantes! Entrenamiento gratis! Bonos de registro!

  • FinMax

    2do lugar! Gran corredor!

In this article, we will develop a framework for a trading system based on the Triple Screen strategy in MQL5. The Expert Advisor will not be developed from scratch. Instead, we will simply modify the program from the previous article «MQL5 Cookbook: Using Indicators to Set Trading Conditions in Expert Advisors». So the article will also demonstrate how you can easily modify patterns of ready-made programs.

The Expert Advisor from the previous article already features the possibility to enable/disable the Stop Loss/Take Profit and Trailing Stop levels, position volume increase and position reversal on the opposite signal. All the necessary functions have been set in place. So our task is centered around changing the list of external parameters by adding additional options and modifying some existing functions.

For illustrative purposes, we will arrange for signals on three time frames to be generated using the Moving Average indicator. Later on, in continuing to experiment on the developed framework, you will be able to employ any other indicator by slightly modifying the code. We will also implement the opportunity to set time frames for each screen. If the parameter responsible for the indicator period has zero value, this will denote that the corresponding screen is not used. In other words, the system can be set up to have one or two time frames.

Before you start, make a copy of the folder with the files of the Expert Advisor from the previous article and rename it.

Expert Advisor Development

Let’s start with the external parameters. Below is the code of the updated list. New lines are singled out. Time frames are declared with the ENUM_TIMEFRAMES enumeration type. You will be able to select any time frame from the drop-down list.

The IndicatorSegments parameter, as well as the AllowedNumberOfSegments variable and the CorrectInputParameters() function have been removed to simplify the example. Those of you who are interested in this condition can try to implement it on your own. You should also remove the enumeration of indicators in the Enums.mqh file as this Expert Advisor will only employ one indicator.

Since there will be a separate indicator on each time frame, we will need a separate variable to get a handle of each of the indicators:

The new bar will be checked using the minimum time frame. When setting the minimum time frame in the external parameters, we do not have to follow a specific order, i.e. maximum, intermediate, minimum. The reverse order and basically any order would do. So we need a function that will identify the minimum time frame out of all time frames specified.

Since the Expert Advisor can be set to operate on three time frames, as well as on one or two, all options need to be considered when determining the minimum time frame. Below if the code of the GetMinimumTimeframe() function:

To save the minimum time frame value, we will create another global scope variable:

The GetMinimumTimeframe() function will need to be called when initializing the Expert Advisor in the OnInit() function.

The MinimumTimeframe variable value is then used in the CheckNewBar() and GetBarsData() functions.

The GetIndicatorHandle() function now looks as shown below. The period and time frame is specified for each indicator.

Further, we need to add arrays for getting indicator values (separately for each time frame):

The GetIndicatorsData() function for getting indicator values now looks as shown below. The obtained handles are checked for accuracy and if everything is fine, the arrays are filled with indicator values.

The GetTradingSignal() and GetSignal() functions should be modified according to the task at hand. Below is the code of these functions for your consideration.

The GetSignal() function, just like in determining the minimum time frame, takes into account all possible variants of external parameter states relating to position opening conditions. The code of the function is provided below:

Now, we only need to make small changes to the OnInit() and OnDeinit() functions. You can see the changes highlighted in the below code:

The framework for trading systems based on the Triple Screen strategy is ready. It can be modified at any time, by changing the indicators or adding some additional conditions, if necessary.

Optimizing Parameters and Testing Expert Advisor

Let’s proceed to parameter optimization and check the results. The Strategy Tester is set as shown below (be sure to specify the lowest of the three time frames):

Fig. 1. Strategy Tester settings.

The Expert Advisor parameters for optimization have been set as shown below. Time frames can be set for optimization but I prefer to set them manually.

Fig. 2. Settings of the Expert Advisor.

The optimization has been completed in about 30 minutes on a dual-core processor. The Optimization Graph is provided below:

Fig. 3. Optimization Graph.

Maximum balance test results show less drawdown than the maximum recovery factor test results, which is why the maximum balance test results are used for demonstration purposes:

Fig. 4. Maximum balance test results.

Fig. 5. Maximum balance test graph.


The article has demonstrated that the Expert Advisor can be fairly quickly modified, if the main functions are available. You can get a new trading system by only changing the signal block and indicators. Attached to the article is a downloadable archive containing the source codes of the Expert Advisor described herein above for your further self-study, as well as a set-file with the input parameter settings.

Expert Advisor Testing with Smart Forex Tester 1.0

Expert Advisor testing can be done with the Smart Forex Tester 1.0 – both on historical data and on live streaming prices.

The release 1.0 will use a new platform (similar to that used by the Forex Simulator).

Smart Forex Tester 1.0 supports Expert Advisor Testing

The main focus of this release is on the integration of EA testing functionality to the new Tester framework. Expert Advisor testing is possible as the source (MQ4) code.

The Tester supports C++ trading strategies. As MQL language is essentially C++, we can compile a bulk of EA source code in the Tester. The non-compiling part needs to be changed. Which is not difficult, as C++ is a more powerful language.

Separately we need to change trading functionality. The Tester provides a C++ trading strategy with a set of interfaces to the Tester engine. They are used for receiving ticks and exchanging trading commands between a strategy and the Tester.

In the next releases, more functions and interfaces will be supported. Check our roadmap.

Los mejores corredores de opciones binarias 2020:
  • Binarium

    1er lugar! El mejor broker de opciones binarias!
    Ideal para principiantes! Entrenamiento gratis! Bonos de registro!

  • FinMax

    2do lugar! Gran corredor!

Escuela de opciones binarias
Deja un comentario

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: