Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

votes: 22
2017.11.03 12:22
2018.02.22 13:00
Symbol.mqh (5.22 KB)view

The library contains functionality that allows you to understand the basics of work with custom symbols, and offers some ready-made solutions that can be useful.


When you run backtest on cross pairs, the tester uses the main symbol and an additional one allowing to convert the profit currency of the main symbol to the account currency. Access to the additional symbol, generation of its ticks, and synchronization with the main symbol take too much precious computing resources and time during a single test run and especially during optimization. However, this accuracy is almost always unnecessary. Therefore, I wanted to bypass this obtrusiveness/flaw of the MetaTrader 5 tester. It can be easily done in MetaTrader 4, because it provides the possibility to change the account currency directly in the tester. MetaTrader 5 does not provide this option.

The demo script shows an attempt to bypass this restriction of the tester, i.e. to remove unnecessary calculations. For this purpose, it creates a copy of the symbol for backtesting, and the sets profit currency equal to the account currency. Therefore conversion of testing results is not required. In this case, profit is actually calculated in pips, which can be very demonstrative in some situations.

// Creating a copy of the symbol and changing the profit currency
#property script_show_inputs

#include <Symbol.mqh>

sinput string PostFix = "_custom";

void OnStart()
  const SYMBOL Symb(_Symbol + PostFix); // Creating the symbol

  Symb = _Symbol; // Copying all properties and the bar history of the main symbol

  Symb.SetProperty(SYMBOL_CURRENCY_PROFIT, AccountInfoString(ACCOUNT_CURRENCY)); // Making the base currency equal to the deposit currency

  Symb.On(); // Enabling the symbol in Market Watch

  ChartOpen(Symb.Name, PERIOD_CURRENT); // Opening the chart of the new symbol

Translated from Russian by MetaQuotes Software Corp.
Original code:

ATRValues ATRValues

The indicator shows a text block with the values ​​of the user defined ATR period for each timeframe.

KoliErBands KoliErBands

Another version of Bollinger Bands using as the middle line the average of the High and Low over a selected period.

Last ZZ50 Last ZZ50

The strategy is based on the ZigZag indicator and pending orders.

Four_MA_Strength_HTF Four_MA_Strength_HTF

The Four_MA_Strength indicator with the timeframe selection option available in input parameters.