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!

SAWA Framework EA

SAWA Framework is the perfect tool for automatic or manual trading ! But this is only the DEMO version. check out the full version here!

How does it work?

You can trade manually or use it in automatic mode with your own strategy. The expert advisor opens a position when all signals enabled agree on the direction of the trend.

It includes

  • 3 types of Money Management:
    1. Fix Lot.
    2. Auto-lot calculated with a percentage of the account Balance in risk.
    3. Auto-lot calculated with a multiplier of the previous position.
  • 3 types of Martingales:
    1. Disable.
    2. Enable adding in profit.
    3. Enable adding against.
    4. Enable adding in opposite directions in a range.
  • +30 indicators of 5 types with:
    1. Custom indicators.
    2. Trend Indicators.
    3. Oscillators indicators.
    4. Volumes indicators.
    5. Bill Williams indicators (With signals according with some of the B.W. Dimensions).

Information Panel

Trade Settings info:

  • Trade Type.
  • Money Management.
  • Martingale.
  • Stop-loss / Distance to average (add against) / Tunnel Martingale Range.
  • Take-Profit / Distance to average (add in profit).

Market Conditions info:

  • Server time.
  • Current Spread.
  • Average Spread of the last 100 ticks.
  • Stop Level: minimum distance to set the Stop-Loss/Take-Profit.
  • Tick Latency: Time in MS from the last Tick of the price.
  • Code Execution time: Time in MS that takes to the computer to read and execute the actions of the expert’s code. A good performance would be a value under 20 MS.

Current Exposure info:

  • Total Trades: Number of orders open by the EA ( Magic Number ).
  • Profit: of the current trades in account currency.
  • Break-even price.
  • Exposure: ( Long Lots – Short Lots ) .
  • Max Net Exposure: Absolute value of the maximum exposure according with the Money Management and Martingale settings.
  • Maximum drawdown: maximum loss according to the maximum net exposure and stop-loss. In live trading you have to count the margin requirements that are not included in the Maximum drawdownin order to control your free margin.

Input Parameters

  • Trade Type: Auto Trade / Manual trade ( with trade panel ).
  • Allow Buy / Sell: for Auto Trade mode.
  • Close Positions Without Open More.
  • Time Filter to trade.
  • Max Spread.
  • Max Slippage.
  • Magic Number.

Money management settings

  • Martingale Type:
    1. Disable.
    2. Add in Profit.
    3. Add Against.
    4. Tunnel Martingale.
  • Max Trades: if martingale is enable.
  • Money Management (type):
    1. Fix Lot.
    2. Auto-lot Risk Per cent.
    3. Auto lot Multiplier.
  • Risk Per cent: for Risk Per cent MM.
  • Profit Per cent to close all.
  • Lot Size: for Fix lot MM.
  • Lot Multiplier: if martingale is enable.

Stop Loss Settings

  • Lock Profit: Disable / Trailing stop / Break even.
  • Trailing Stop / Break-even Distance (in pips).
  • Take Profit / Stop Loss Mode:
    1. Manual.
    2. ATR Multiplier (only available if martingale is disable).
  • Manual TP–SL.
  • ATR SL-TP Multiplier.
  • ATR Period for TP-SL.
  • Use Indicator: Enable or Disable the indicator signal.
  • Indicator Input Settings.
  • Indicator Shift: Shift = 0 will generate the signal in real time ticks. Shift = 1 will generate the signal at the open of the next candle.
  • Indicator Signal (if any).

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.

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.

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!

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.

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.

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!

Opciones binarias: estrategias, robots e indicadores
Deja un comentario

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