Skip to content
📄 EA31337 framework (MQL library for writing EAs)
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Adds static for Profiler to merge the results (as it was before) Feb 27, 2019
.gitattributes Added git normalization file with eol=lf. May 22, 2016
.gitignore Ignores log files Feb 26, 2019
.travis.yml Adds ProfilerTest Feb 27, 2019
Account.mqh Fixes GetRiskMarginLevel() as per regression in ceaad2b Jan 22, 2019
Array.mqh Corrects sign mismatch Feb 25, 2019
BasicTrade.mqh Corrects mismatched #ifdef/#endif pair Jan 17, 2017
Chart.mqh Uses ENUM_TIMEFRAMES_INDEX instead of uint Feb 21, 2019
ChartTest.mq5 Renames Chart test file Jan 20, 2019
Check.mqh Improves class hierarchy Jan 21, 2017
Collection.mqh Adds static for Profiler to merge the results (as it was before) Feb 27, 2019
Condition.mqh General code improvements Jan 18, 2019
Convert.mqh Adds Convert.mq4 for testing Jul 1, 2018
DateTime.mqh Adds compiler defines to avoid circular dependencies Jan 21, 2018
Draw.mqh Minor improvements related to bar and time Jan 29, 2017
File.mqh Minor code improvements Jan 20, 2019
Indicator.mqh Adds ZigZag to indicator enum Jun 26, 2018
Indicators.mqh Adds compiler defines to avoid circular dependencies Jan 21, 2018
Inet.mqh
LICENSE Create LICENSE Apr 19, 2018
Log.mqh Minor code improvements Jan 20, 2019
MD5.mqh Moves some convert functions to Convert Dec 27, 2016
MQL4.mqh Fixes warning 30: macro redefinition Feb 18, 2019
MQL5.mqh Improves compability for MT5 Feb 10, 2019
Mail.mqh
Market.mqh Minor code improvements Jan 20, 2019
Math.mqh Refactors code in order to improve support for MQL5 Jan 5, 2017
Misc.mqh
Msg.mqh Improves class hierarchy Jan 21, 2017
Object.mqh Object methods improvements Jan 18, 2019
Order.mqh Moves GetOpenOffer/GetCloseOffer from Market to SymbolInfo Jan 18, 2019
Orders.mqh Fixes CI tests Jul 6, 2018
Profiler.mqh Adds static for Profiler to merge the results (as it was before) Feb 27, 2019
README.md Removes argument from PROFILER_PRINT Feb 27, 2019
Registry.mqh Improves class hierarchy Jan 21, 2017
RegistryBinary.mqh Type conversion fixes Jul 2, 2016
Report.mqh Improves class hierarchy Jan 21, 2017
SVG.mqh Fixes code formatting and typos Jan 7, 2017
Session.mqh Improves class hierarchy Jan 21, 2017
SetFile.mqh Moving code around between Trade and Order, added few new methods. Jun 15, 2016
Stats.mqh Adds Stats.mq4 for testing Jul 1, 2018
Strategies.mq5
Strategies.mqh
Strategy.mqh Object methods improvements Jan 18, 2019
String.mqh Adds compiler defines to avoid circular dependencies Jan 21, 2018
SummaryReport.mqh Minor fixes in SummaryReport Feb 2, 2017
SymbolInfo.mqh Adds support for tick_data to SymbolInfo along with methods Jan 20, 2019
Task.mqh Improves class hierarchy Jan 21, 2017
Terminal.mqh Renames GetPath() to GetTerminalPath() Feb 21, 2019
Test.mqh Adds assertTrueOrReturn/assertFalseOrReturn to Test Feb 25, 2019
Tester.mqh Doc block formatting Feb 18, 2017
Tests.mqh Corrects error 280 in Tests.mqh(42,20): '=' - object required, for bu… Jul 22, 2018
Ticker.mqh Fixes invalid pointer access in TickerTest Feb 18, 2019
Timer.mqh Adds static for Profiler to merge the results (as it was before) Feb 27, 2019
Trade.mqh Adds TerminalTest.mq4 Feb 21, 2019
appveyor.yml Uses ruby to test the compilation results Feb 18, 2019

README.md

EA31337-classes

EA31337 framework for writing trading robots for MetaTrader 4 and 5 platforms.

Build status

Type Status
Travis CI build Build Status
AppVeyor build Build status

Class hierarchy

.
|-- Account (Orders)
|-- Terminal (Log)
|   |-- SymbolInfo
|   |   |-- Market
|   |   |   |-- Chart
|   |   |   |   |-- Draw
|   |   |   |   |-- Indicator
|   |-- Tester
|   |-- Session
|   |   |-- Check
|   |   |-- Registry
|   |   |-- RegistryBinary
|   |   |-- File
|-- Trade (Account, Chart, Log)
|-- Order (Market)
|-- Strategy (String, Trade)
|-- Indicators
|-- Strategies
|-- Rules (Condition, Action)
|-- Array
|-- DateTime
|-- BasicTrade
|-- Convert
|-- Inet
|-- MD5
|-- MQL4
|-- Mail
|-- Math
|-- Misc
|-- Msg
|-- Report
|-- SVG
|-- SetFile
|-- Stats
|-- SummaryReport
|-- Task
|-- Tests
|-- Ticker
|-- Timer (Object)

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

Example to measure execution 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

Example to measure execution 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
}

Timer class

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

Example 1

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 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

You can’t perform that action at this time.