거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Memento - behavioral design pattern - MetaTrader 5용 라이브러리

조회수:
2593
평가:
(9)
게시됨:
2020.11.04 10:31
\MQL5\Include\Mqh\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
//+------------------------------------------------------------------+
//|                                                201104_114239.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
//+------------------------------------------------------------------+
//| memento - behavioral design pattern                              |
//+------------------------------------------------------------------+
//   without violating encapsulation, capture and externalize an object's
//internal state so that the object can be restored to this state later
//+------------------------------------------------------------------+
//| applicability                                                    |
//+------------------------------------------------------------------+
//   a snapshot of (some portion of) an object's state must be saved so
//that it can be restored to that state later, and
//   a direct interface to obtaining the state would expose implementation
//details and break the object's encapsulation
//+------------------------------------------------------------------+
//| structure                                                        |
//+------------------------------------------------------------------+
//                                                memento
// |        Originator        |- - ->| Memento  |<-------o|Caretaker|
// |--------------------------|      |----------|
// |SetMemento(Memento m)     |      |GetState()|
// | state=m.GetState()       |      |SetState()|
// |CreateMemento()           |      |----------|
// | return new Memento(state)|      |state     |
// |--------------------------|
// |state                     |
//
//+------------------------------------------------------------------+
//| participants                                                     |
//+------------------------------------------------------------------+
//   memento
//      stores internal state of the originator object. the memento may
//store as much or as little of the originator's internal state as necessary
//at its originator's discretion
//      protects against access by objects other than the originator.
//mementos have effectively two interfaces. caretaker sees a narrow interface
//to the memento — it can only pass the memento to other objects. originator,
//in contrast, sees a wide interface, one that lets it access all the data
//necessary to restore itself to its previous state. ideally, only the
//originator that produced the memento would be permitted to access the
//memento's internal state
//   originator
//      creates a memento containing a snapshot of its current internal state
//      uses the memento to restore its internal state
//   caretaker
//      is responsible for the memento's safekeeping
//      never operates on or examines the contents of a memento
//+------------------------------------------------------------------+
//| collaborations                                                   |
//+------------------------------------------------------------------+
#include <Mqh\201104_114823.mqh> //memento
#include <Mqh\201104_115143.mqh> //originator
#include <Mqh\201104_115621.mqh> //caretaker
//   a caretaker requests a memento from an originator, holds it for a
//time, and passes it back to the originator:
//
//   aCaretaker              anOriginator              aMemento
//       |                        |                        |
//      | |CreateMemento()        |
//      | |--------------------->| |new Memento            |
//      | |                      | |- - - - - - - - - - ->| |
//      | |                      | |SetState()             |
//      | |                      | |--------------------->| |
//       |                        |                        |
//       /                        /                        /
//       /                        /                        /
//       |                        |                        |
//      | |SetMemento()           |                        |
//      | |--------------------->| |GetState()             |
//      | |                      | |--------------------->| |
//       |                        |                        |
//
//   sometimes the caretaker won't pass the memento back to the originator,
//because the originator might never need to revert to an earlier state
//   mementos are passive. only the originator that created a memento will
//assign or retrieve its state
//---
void OnStart()
  {
   Originator originator;
   Caretaker caretaker;
//---
   originator.State("on");
   caretaker.memento=originator.CreateMemento();
   originator.State("off");
   originator.SetMemento(caretaker.memento);
  }
//+------------------------------------------------------------------+
//| output                                                           |
//+------------------------------------------------------------------+
//   changing originator state to on
//   creating memento with current state on
//   changing originator state to off
//   restoring originator state from memento to on
//+------------------------------------------------------------------+
//| consequences                                                     |
//+------------------------------------------------------------------+
//   preserving encapsulation boundaries
//   it simplifies originator
//   using mementos might be expensive
//   defining narrow and wide interfaces
//   hidden costs in caring for mementos
//+------------------------------------------------------------------+
//| implementation                                                   |
//+------------------------------------------------------------------+
//   language support
//   storing incremental changes
//+------------------------------------------------------------------+
//| related patterns                                                 |
//+------------------------------------------------------------------+
//   command: commands can use mementos to maintain state for undoable operations
//   iterator: mementos can be used for iteration as described earlier
//+------------------------------------------------------------------+
    McGinley dynamic (official) McGinley dynamic (official)

    McGinley dynamic (official version - as described by John R. McGinley)

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

    Minimum / maximum support resistance zones

    SSL Channel Chart SSL Channel Chart

    Trend indicator

    Strategy - Set And Forget (with Alerting system) - MT5 Strategy - Set And Forget (with Alerting system) - MT5

    This strategy is the well known set & forget with the ALERTING system. It is very useful on different trading scenarios. I urge you guys to always use trading tools that will make your live easier. So instead of watching the charts and the time and all day long, you can use this indicator that will watch the charts for you.