• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language MQL5
  • License
    GNU General Publi...
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📦📈 EA31337 framework (MQL library for writing trading Expert Advisors, indicators and scripts)

EA31337 Framework

Tag License Status Status Status Channel Twitter

EA31337 framework is designed for writing trading robots for MetaTrader 4 and 5 platforms. It can be also used to convert your MQL4 code into MQL5 with minimum code changes.

Table of contents

Projects

Projects implementing this framework:

Conversion

MQL4 to MQL5 conversion

This framework can be used to convert your MQL4 code to be compatible with both MQL4 and MQL5.

Find below the table of conversion (replace code on left with the right one):

MQL4 (original) MQL4 & MQL5 (replace with) Required include file
WindowRedraw() Chart::WindowRedraw() Chart.mqh
Day() DateTime::Day() DateTime.mqh
TimeDayOfWeek() DateTime::DayOfWeek() DateTime.mqh
DayOfWeek() DateTime::DayOfWeek() DateTime.mqh
DayOfYear() DateTime::DayOfYear() DateTime.mqh
Hour() DateTime::Hour() DateTime.mqh
Month() DateTime::Month() DateTime.mqh
TimeDay() DateTime::TimeDay() DateTime.mqh
TimeDayOfYear() DateTime::TimeDayOfYear() DateTime.mqh
TimeToStr() DateTime::TimeToStr() DateTime.mqh
Year() DateTime::Year() DateTime.mqh
iAC() Indi_AC::iAC() Indicators/Indi_AC.mqh
iAD() Indi_AD::iAD() Indicators/Indi_AD.mqh
iADX() Indi_ADX::iADX() Indicators/Indi_ADX.mqh
iAO() Indi_AO::iAO() Indicators/Indi_AO.mqh
iATR() Indi_ATR::iATR() Indicators/Indi_ATR.mqh
iBWMFI() Indi_BWMFI::iBWMFI() Indicators/Indi_BWMFI.mqh
iBands() Indi_Bands::iBands() Indicators/Indi_Bands.mqh
iBearsPower() Indi_BearsPower::iBearsPower() Indicators/Indi_BearsPower.mqh
iBullsPower() Indi_BullsPower::iBullsPower() Indicators/Indi_BullsPower.mqh
iCCI() Indi_CCI::iCCI() Indicators/Indi_CCI.mqh
iDeMarker() Indi_DeMarker::iDeMarker() Indicators/Indi_DeMarker.mqh
iEnvelopes() Indi_Envelopes::iEnvelopes() Indicators/Indi_Envelopes.mqh
iForce() Indi_Force::iForce() Indicators/Indi_Force.mqh
iFractals() Indi_Fractals::iFractals() Indicators/Indi_Fractals.mqh
iGator() Indi_Gator::iGator() Indicators/Indi_Gator.mqh
iIchimoku() Indi_Ichimoku::iIchimoku() Indicators/Indi_Ichimoku.mqh
iMA() Indi_MA::iMA() Indicators/Indi_MA.mqh
iMACD() Indi_MAcD::iMACD() Indicators/Indi_MACD.mqh
iMFI() Indi_MFI::iMFI() Indicators/Indi_MFI.mqh
iMomentum() Indi_Momentum::iMomentum() Indicators/Indi_Momentum.mqh
iOBV() Indi_OBV::iOBV() Indicators/Indi_OBV.mqh
iOsMA() Indi_OsMA::iOsMA() Indicators/Indi_OsMA.mqh
iRSI() Indi_RSI::iRSI() Indicators/Indi_RSI.mqh
iRVI() Indi_RVI::iRVI() Indicators/Indi_RVI.mqh
iSAR() Indi_SAR::iSAR() Indicators/Indi_SAR.mqh
iStdDev() Indi_StdDev::iStdDev() Indicators/Indi_StdDev.mqh
iStochastic() Indi_Stochastic::iStochastic() Indicators/Indi_Stochastic.mqh
iWPR() Indi_WPR::iWPR() Indicators/Indi_WPR.mqh
RefreshRates() Market::RefreshRates() Market.mqh
delete object Object::Delete(object) Object.mqh
GetOrderProfit() Order::GetOrderProfit() Order.mqh
OrderClose() OrderStatic::Close() Order.struct.h
OrderCloseTime() OrderStatic::CloseTime() Order.struct.h
OrderCommission() OrderStatic::Commission() Order.struct.h
OrderLots() OrderStatic::Lots() Order.struct.h
OrderMagicNumber() OrderStatic::MagicNumber() Order.struct.h
OrderOpenPrice() OrderStatic::OpenPrice() Order.struct.h
OrderOpenTime() OrderStatic::OpenTime() Order.struct.h
OrderPrint() OrderStatic::Print() Order.struct.h
OrderSelect() OrderStatic::Select() Order.struct.h
OrderStopLoss() OrderStatic::StopLoss() Order.struct.h
OrderSymbol() OrderStatic::Symbol() Order.struct.h
OrderTicket() OrderStatic::Ticket() Order.struct.h
OrderType() OrderStatic::Type() Order.struct.h
OrdersTotal() TradeStatic::TotalActive() Trade.mqh

Here are the special predefined variables conversion:

MQL4 (original) MQL4 & MQL5 (replace with) Required include file
Ask SymbolInfo::GetAsk() SymbolInfo.struct.static.h
Bars ChartStatic::iBars() Chart.struct.static.h
Bid SymbolInfo::GetBid() SymbolInfo.struct.static.h
Close[] ChartStatic::iClose() Chart.struct.static.h
Digits SymbolInfo::GetDigits() SymbolInfo.struct.static.h
High[] ChartStatic::iHigh() Chart.struct.static.h
Low[] ChartStatic::iLow() Chart.struct.static.h
Open[] ChartStatic::iOpen() Chart.struct.static.h
Point SymbolInfo::GetPointSize() SymbolInfo.struct.static.h
Time[] ChartStatic::iTime() Chart.struct.static.h
Volume[] ChartStatic::iVolume() Chart.struct.static.h

Classes

Account class

The class for managing the current trading account.

Example 1 - Managing account (dynamic calls)

Account *acc = new Account();
double _balance = acc.GetBalance();
double _credit = acc.GetCredit();
double _equity = acc.GetEquity();
double _margin_free = acc.GetMarginFree();
double _margin_used = acc.GetMarginUsed();
if (acc.IsExpertEnabled() && acc.IsTradeAllowed()) {
  // Some trade code.
}
delete acc;

Example 2 - Managing account (static calls)

double _balance = Account::AccountBalance();
double _credit = Account::AccountCredit();
double _equity = Account::AccountEquity();
double _margin_free = Account::AccountFreeMargin();
double _margin_used = Account::AccountMargin();
if (Account::IsExpertEnabled() && Account::IsTradeAllowed()) {
  // Some trade code.
}

Dict class

Use this class to store the values in form of a collective attribute–value pairs, in similar way as associative arrays with a hash table work.

Example 1 - Storing string-int data structures

Example of storing key-value data with string as a key:

Dict<string, int> data1;
data1.Set("a", 1);
data1.Set("b", 2);
data1.Set("c", 3);
data1.Unset("c");
Print(data1.GetByKey("a"));

Mail class

The purpose of Mail class is to provide common functionality for managing e-mails.

Example 1 - Send e-mail on trade execution

Example sending e-mail on trade execution:

int OnInit() { // @see: https://www.mql5.com/en/docs/event_handlers/oninit
  Mail *mail = new Mail();
  mail.SetSubjectPrefix("Trading");
}
void OnTrade() { // @see: https://www.mql5.com/en/docs/event_handlers/ontrade
  if (!Terminal::IsRealtime()) {
    mail.SendMailExecuteOrder();
  }
}
int OnDeinit() { // @see: https://www.mql5.com/en/docs/event_handlers/ondeinit
  delete mail;
}

Indicator class

The purpose of Indicator class is to provide common functionality across all indicators such as storing and searching for values.

This class is used as a base class to handle technical indicator classes which can be found in Indicators/ folder.

Indicators/ classes

In Indicators/ folder there is collection of indicator classes.

Example 1 - AC indicator

The example reading value from AC indicator:

#include <EA31337-classes/Indicators/Indi_AC.mqh>
int OnInit() {
  Indi_AC ac = new Indi_AC();
  PrintFormat("%g", ac.GetValue());
  delete ac;
}

Example 2 - Alligator indicator

The example reading values from Alligator indicator:

#include <EA31337-classes/Indicators/Indi_Alligator.mqh>
int OnInit() {
  AlligatorParams alli_params(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN);
  Indi_Alligator alli = new Indi_Alligator(alli_params));
  AlligatorEntry values = alli.GetEntry(0);
  if (alli.GetFlag(INDI_ENTRY_FLAG_IS_VALID)) {
    Print("Alligator values: ", values.ToString());
  }
  delete alli;
}

IndicatorData class

The purpose of IndicatorData class is to store indicator data. It is basically alternative implementation of Indicator class.

For more details, please read: Class to hold indicator values.

For implementation example, check tests/IndicatorDataTest.mq4.

Profiler class

The purpose of Profiler class is to profile functions by measuring its time of execution. The minimum threshold can be set, so only slow execution can be reported.

Example 1 - Measure execution time of function multiple times

Example to measure execution time of function multiple times, then printing the summary of all calls which took 5ms or more.

#include "Profiler.mqh"

void MyFunction() {
  PROFILER_START
  Sleep(rand()%10);
  PROFILER_STOP
}

int OnInit() {
  for (uint i = 0; i < 10; i++) {
    MyFunction();
  }
  // Set minimum threshold of 5ms.
  PROFILER_SET_MIN(5)
  // Print summary of slow executions above 5ms.
  PROFILER_PRINT
  return (INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {
  PROFILER_DEINIT
}

Example 2 - Measure execution time of function multiple times

Example to measure execution time of function multiple times, then automatically printing all calls which took 5ms or more.

#include "Profiler.mqh"

void MyFunction() {
  PROFILER_START
  Sleep(rand()%10);
  // Automatically prints slow executions.
  PROFILER_STOP_PRINT
}

int OnInit() {
  // Set minimum threshold of 5ms.
  PROFILER_SET_MIN(5);
  for (uint i = 0; i < 10; i++) {
    MyFunction();
  }
  return (INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {
  PROFILER_DEINIT
}

SymbolInfo class

The class to manage the symbol's information.

Example 1 - Accessing symbol's data (dynamic)

SymbolInfo *si = new SymbolInfo();
string symbol = si.GetSymbol();
MqlTick tick = si.GetTick()
double ask = si.GetLastAsk();
double bid = si.GetLastBid();
uint spread = si.GetSpread();
Print("MARKET: ", si.ToString());
delete si;

Example 2 - Accessing symbol's data (static)

string symbol = SymbolInfo::GetCurrentSymbol();
MqlTick tick = SymbolInfo::GetTick(symbol)
double ask = SymbolInfo::GetAsk(symbol);
double bid = SymbolInfo::GetBid(symbol);
uint spread = SymbolInfo::GetSpread(symbol);

Timer class

The purpose ofTimer class is to measure time between starting and stopping points.

Example 1 - Single timer

Single timer:

#include "Timer.mqh"

Timer *timer = new Timer("mytimer");
timer.Start();
// Some code to measure here.
timer.Stop();
Print("Time (ms): ", timer.GetSum());
timer.PrintSummary();
delete timer;

Example 2 - Multiple timers

Multiple measurements:

#include "Timer.mqh"

Timer *timer = new Timer(__FUNCTION__);
  for (uint i = 0; i < 5; i++) {
    timer.Start();
    Sleep(10); // Some code to measure here.
    PrintFormat("Current time elapsed before stop (%d/5): %d", i + 1, timer.GetTime());
    timer.Stop();
    PrintFormat("Current time elapsed after stop (%d/5): %d", i + 1, timer.GetTime(i));
  }
timer.PrintSummary();
delete timer;

Support

More Repositories

1

EA31337

🤖📈 EA31337 Lite, Advanced and Rider - Forex multi-strategy trading robot for MT4/MT5 platforms
MQL5
714
star
2

EA31337-Libre

🤖📈 EA31337 Libre - free and open source Forex trading robot for MT4/MT5 platforms
MQL5
123
star
3

EA-Tester

🐳📈 Headless Forex backtesting for MetaTrader platform using Docker
Shell
97
star
4

EA31337-strategies

🤖📈 EA31337 strategies.
C
76
star
5

Strategy-ElliottWave

Strategy based on the Elliot Wave indicator.
Jinja
21
star
6

Birt-CSV2FXT

📄 Scripts to convert CSV data format into MT FXT.
C++
11
star
7

MT-Formats

Header files for MT4/MT5 platform.
C
10
star
8

EA31337-indicators-other

Collection of 3rd party indicators used for EA31337 strategies.
MQL4
10
star
9

Strategy-ZigZag

Strategy based on the ZigZag indicator.
Jinja
7
star
10

Dukascopy2FXT

📄 Script to do the converting to HST and FXT files.
6
star
11

Strategy-ATR_MA_Trend

Strategy based on the Average True Range (ATR) and Moving Average (MA) indicators.
MQL5
6
star
12

EA31337-optimization-rules-old

📈 Optimization rules for EA31337 trading robot.
Shell
5
star
13

Strategy-ADX

Strategy based on the Average Directional Movement Index indicator
Jinja
5
star
14

EA31337-indicators-common

Collection of common indicators used for EA31337 strategies.
MQL5
5
star
15

MT-Platforms

Unofficial mirror of MT Platforms
MQL5
4
star
16

Strategy-SuperTrend

Strategy based on the SuperTrend indicator
MQL5
4
star
17

EA31337-Lite-Sets

📈 Set files for EA31337 Lite trading robot.
Shell
4
star
18

Strategy-OBV

Strategy based on the On Balance Volume indicator.
Jinja
3
star
19

Strategy-Meta_Multi

Multi meta strategy which runs multiple other strategies.
MQL5
3
star
20

Strategy-HeikenAshi

Strategy based on the Heiken Ashi candlesticks.
Jinja
3
star
21

EA31337.github.io

EA31337 hub site
3
star
22

Strategy-TMA_CG

Strategy based on TMA+CG mladen NRP indicator.
MQL5
3
star
23

MQL5-MQL4-Common

📄 Provides common MQL4 back-compability for MQL5.
3
star
24

Strategy-AD

Strategy based on the Accumulation/Distribution indicator
Jinja
3
star
25

CSVtoHCC

CSV to HCC MT5 file converter
C++
3
star
26

ansible-role-wine

Ansible role for installing Wine on UNIX-like platforms.
Jinja
2
star
27

Strategy-Alligator

Strategy based on the Alligator indicator.
Jinja
2
star
28

EA-Tester-Docker

💻 Docker containers for EA-Tester project.
Dockerfile
2
star
29

Strategy-SAR

Strategy based on the Parabolic Stop and Reverse system indicator.
Jinja
2
star
30

Strategy-MFI

Strategy based on the Money Flow Index indicator.
Jinja
2
star
31

Strategy-Momentum

Strategy based on the Momentum indicator.
Jinja
2
star
32

Strategy-Fractals

Strategy based on the Fractals indicator.
Jinja
2
star
33

ansible-role-metatrader

Ansible role to automate MetaTrader platform installation
Shell
2
star
34

EA31337-indicators-sandbox

Sandbox for 3rd party indicators being proposed for EA31337 strategies.
MQL4
2
star
35

ansible-role-mt-runner

Ansible role to run MetaTrader platform (with Expert Advisors, Script and Indicators)
Jinja
2
star
36

EA31337-Jenkins-config

Jenkins config for EA backtesting. No longer in use.
1
star
37

CI-Test

Test repository for CI.
MQL5
1
star
38

Strategy-MA_Cross_Candle

Strategy based on the MA price indicators implementing candle cross signal.
MQL5
1
star
39

Strategy-Hull_MA_MTR

Hull Master 22 Next MTF Strategy
MQL4
1
star
40

EA31337-strategies-sandbox

📄 Playground for EA strategies.
MQL4
1
star
41

Backtest-Tests

Playground repository for testing and performing backtests
1
star
42

EA31337-Lite-optimization-tests

📈 Optimization tests for EA31337 Lite trading robot.
1
star
43

Strategy-SAWA

Strategy based on SAWA indicator
Jinja
1
star
44

EA31337-strategies-meta

🤖📈 EA31337 meta strategies.
C
1
star
45

EA31337-Advanced-optimization-tests

📈 Optimization tests for EA31337 Advanced trading robot.
1
star
46

Strategy-MA

Strategy based on the moving average price indicators.
MQL5
1
star
47

MQ-classes

MetaQuotes class files.
1
star
48

Support

✉️ Place to report general suggestions or issues with EA31337 related projects
1
star
49

Strategy-Pinbar

Strategy based on pinbar pattern scanner with CCI/RSI filter
MQL5
1
star
50

Strategy-RSI

Strategy based on the Relative Strength Index indicator.
Jinja
1
star
51

Strategy-Envelopes

Strategy based on the Envelopes indicator.
Jinja
1
star
52

Strategy-TMA_True

Strategy based on Triangular Moving Average (TMA) indicator.
Jinja
1
star
53

Strategy-Meta_News

Meta News strategy to run different strategies based on the economic news impact.
MQL5
1
star
54

Strategy-Volume_Price_Change

Strategy based on the Volume Price Change oscillator
MQL4
1
star
55

Strategy-TMAT_SVEBB

TMA Band True (Contrarian) Strategy
MQL5
1
star
56

Strategy-Chaikin

Strategy based on the Chaikin Oscillator (CHO) indicator
MQL5
1
star
57

Strategy-CCI_Arrows

Strategy based on the Commodity Channel Index Arrows indicator (CCI Arrows).
MQL5
1
star
58

Strategy-Meta_RSI

RSI meta strategy to trade with different strategies based on the current daily RSI value.
MQL5
1
star