Guarda come scaricare robot di trading gratuitamente
Ci trovi su Twitter!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Librerie

Mediator - behavioral design pattern - libreria per MetaTrader 5

Visualizzazioni:
2629
Valutazioni:
(12)
Pubblicato:
2020.10.28 09:44
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance
//+------------------------------------------------------------------+
//|                                                201028_095428.mq5 |
//|                                    2019-2020, dimitri pecheritsa |
//|                                                 792112@gmail.com |
//+------------------------------------------------------------------+
//   from: design patterns: elements of reusable object-oriented software
//   by gof: erich gamma, richard helm, ralph johnson, john vlissides
//   published in 1994
//+------------------------------------------------------------------+
//| mediator - behavioral design pattern                             |
//+------------------------------------------------------------------+
//   define an object that encapsulates how a set of objects interact
//   mediator promotes loose coupling by keeping objects from referring
// to each other explicitly, and it lets you vary their interaction
// independently
//+------------------------------------------------------------------+
//| applicability                                                    |
//+------------------------------------------------------------------+
//   a set of objects communicate in well-defined but complex ways.
// the resulting interdependencies are unstructured and difficult to
// understand
//   reusing an object is difficult because it refers to and communicates
// with many other objects
//   a behavior that's distributed between several classes should be
// customizable without a lot of subclassing
//+------------------------------------------------------------------+
//| structure                                                        |
//+------------------------------------------------------------------+
//
//                             mediator
//    |Mediator|<-----------------------|Colleague|
//        ^                                  ^
//        |                                  |
//        |                    +-------------+------------+
//        |                    |                          |
//|ConcreteMediator|-->|ConcreteColleague1|  +-->|ConcreteColleague2|
//               |                           |
//               +---------------------------+
//
//+------------------------------------------------------------------+
//| typical object structure                                         |
//+------------------------------------------------------------------+
//
//                                 |aColleague|
//                                 |----------|
//                                 |* mediator|
//                                  |
//                                  |                |aColleague|
//                                  |                |----------|
//      |aColleague|                v            +---|* mediator|
//      |----------|                             |         ^
//      |mediator *|----->|aConcreteMediator|<---+         |
//                        |-----------------|              |
//                        | *           * *-|--------------+
//                          |  ^     ^  |
//                          |  |     |  |
//                          |  |     |  |
//   |aColleague|<----------+  |     |  |
//   |----------|              |     |  +--->|aColleague|
//   |mediator *|--------------+     |       |----------|
//                                   +-------|* mediator|
//
//+------------------------------------------------------------------+
//| participants                                                     |
//+------------------------------------------------------------------+
//   mediator
//      defines an interface for communicating with colleague objects
//   concrete mediator
//      implements cooperative behavior by coordinating colleague objects
//      knows and maintains its colleagues
//   colleague classes
//      each colleague class knows its mediator object
//      each colleague communicates with its mediator whenever it would have
// otherwise communicated with another colleague
//+------------------------------------------------------------------+
//| collaborations                                                   |
//+------------------------------------------------------------------+
#include <Mqh\201028_103044.mqh> //colleague
#include <Mqh\201028_102459.mqh> //mediator
#include <Mqh\201028_102504.mqh> //concrete colleague 1
#include <Mqh\201028_103427.mqh> //concrete colleague 2
#include <Mqh\201028_102503.mqh> //concrete mediator
//   colleagues send and receive requests from a mediator object
//   the mediator implements the cooperative behavior by routing requests
// between the appropriate colleague(s)
//---
void OnStart()
  {
   ConcreteMediator mediator;
   Colleague* colleague_1=new ConcreteColleague1(mediator);
   Colleague* colleague_2=new ConcreteColleague2(mediator);
   mediator.colleague_1=colleague_1;
   mediator.colleague_2=colleague_2;
   colleague_1.Send("message 1");
   colleague_2.Send("message 2");
//---
   delete colleague_1;
   delete colleague_2;
  }
//+------------------------------------------------------------------+
//| output                                                           |
//+------------------------------------------------------------------+
//   colleague 1 sending message 1
//   colleague 2 notified about message 1
//   colleague 2 sending message 2
//   colleague 1 notified about message 2
//+------------------------------------------------------------------+
//| consequences                                                     |
//+------------------------------------------------------------------+
//   it limits subclassing
//   it simplifies object protocols
//   it abstracts how objects cooperate
//   it centralizes control
//+------------------------------------------------------------------+
//| implementation                                                   |
//+------------------------------------------------------------------+
//   omitting the abstract mediator class
//   colleague-mediator communication
//+------------------------------------------------------------------+
//| related patterns                                                 |
//+------------------------------------------------------------------+
//   facade
//   observer
//+------------------------------------------------------------------+
    Identify the potential best TIME To Trade (Improve your Strategy) - MT5 Identify the potential best TIME To Trade (Improve your Strategy) - MT5

    For day traders, this is one of the important thing to consider in order to improve our strategy by calculating on average how much an asset moves, in which it will allow us to identify the best TIME during the day to trade when the market moves the most as well

    Iterator - behavioral design pattern Iterator - behavioral design pattern

    Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation

    The best TIMES & DAYS our Strategy Works the best (Improve your Strategy) - MT5 The best TIMES & DAYS our Strategy Works the best (Improve your Strategy) - MT5

    For day traders. 2 highly important indicators to turn strategies into extreme winning ones. The Win/Loss ratio and the Reward/Risk ratio will allow us to identify the best times and days our strategy works the best

    Minimum / maximum support resistance zones Minimum / maximum support resistance zones

    Minimum / maximum support resistance zones