Beginner Programming: Moving Average Crossover with and without Martingale functionality – EA MetaTrader 5

Beginner Programming: Moving Average Crossover with and without Martingale functionality - expert for MetaTrader 5
All of the functions used in the Expert Advisor are found in the ImportantFunctions.mqh include file. There are 2 Expert Advisors, both using the price crossing the moving average as their entry signal, with a simple difference: one uses Martingale when losses occur, and the other does not. I don’t recommend using any of the … Read more

Programming Patterns – Decorator – script MetaTrader 5

Programming Patterns - Decorator - script for MetaTrader 5
 • Inheritance is not always flexible.  • Composition and delegation is sometimes a good alternative to dynamically add new behavior.  • Decorator type matches component type.  • Decorators change component behavior without changing the component code.  • A component may have arbitrary number of decorators.  • Decorators are transparent to the client, unless the client … Read more

Programming Patterns – Strategy – script MetaTrader 5

Programming Patterns - Strategy - script for MetaTrader 5
A good architecture is extendable, supportable, and reusable. Patterns help build hq systems. Patterns are proven to be good by experience. Patterns are generic solitions for software engineering challenges. Choose your pattern, don’t invent it. Most patterns are designed to manage changes of the architecture. Most patterns incapsulate variable aspects of the systems. Developers know … Read more

Programming Patterns – Observer – script MetaTrader 5

Programming Patterns - Observer - script for MetaTrader 5
Subjects update observers through interface. Subjects knows nothing about the observers (one-to-many weak relation). New data can be broadcast by the subject, or requested by the observers (better). Order of notification is not guaranteed. RULE: Use weak connection between communicating objects. Programming Patterns – Observer – script MetaTrader 5

Programming Patterns – Abstract Factory – script MetaTrader 5

Programming Patterns - Abstract Factory - script for MetaTrader 5
Many architectures start with Factory method, then evolve to AF, Prototype, Builder Builder makes complex objects step-by-step. AF makes families of related products. Builder returns the object after all steps are complete. AF returns its object at once. AF classes are often made with Factory Method/Prototype AF can be used instead of Facade to hide … Read more

Programming Patters – Builder (classic) – script MetaTrader 5

Programming Patters - Builder (classic) - script for MetaTrader 5
/*********************************************************************                                                            MQL5 Script                                                 Copyright 2019, dmipec                                                       792112@gmail.com Classic Builder Programming Pattern    This pattern was published in the “Design Patterns: Elements of    Reusable Object-Oriented Software”, 1st Edition, by Erich Gamma    (Author), Richard Helm (Author), Ralph Johnson (Author), John    Vlissides (Author), Grady Booch (Foreword). These authors are    collectively known as Gang … Read more

Programming patterns – Composite – library MetaTrader 5

Programming patterns - Composite - library for MetaTrader 5
/**************************************************************** Programming patterns: Composite pattern Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. /**/ /****************************************************************/ class Component //abstract (interface)   { public:    virtual void         Operation()=0;    virtual void         Add(Component*)=0;    virtual void         Remove(Component*)=0;    virtual Component*   GetChild(int)=0;                      Component() {}                      Component(string name):mname(name)  {} … Read more

Programming patterns – Facade – library MetaTrader 5

Programming patterns - Facade - library for MetaTrader 5
/**************************************************************** Programming patterns – Facade Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher- level interface that makes the subsystem easier to use. /**/ /****************************************************************/ class SubSystemA {public:void OperationA() {Print(“SubSystem A”);}}; /**/ class SubSystemB {public:void OperationB() {Print(“SubSystem B”);}}; /**/ class SubSystemC {public:void OperationC() {Print(“SubSystem C”);}}; /****************************************************************/ class Facade … Read more

MQL5 Programming for Traders – Source Codes from the Book. Part 1 – EA MetaTrader 5

Editing, Compiling, and Running Programs
Part 1. Introduction to MQL5 and development environment The first book part entitled “Introduction to MQL5 and development environment” describes the basics of the MQL5 languages and development environment. One of the new features introduced in the MQL5 language compared to MQL4 (MetaTrader 4 language) is support for object-oriented programming (OOP), which makes it similar … Read more