dingmaotu / mql4-lib

MQL4/5 Foundation Library For Professional Developers
Apache License 2.0
544 stars 251 forks source link

trade: add pool constructor options #33

Closed yerden closed 6 years ago

yerden commented 6 years ago

Changes:

These changes don't violate current API and allow to reduce boilerplate code in case of defining TradingPool and HistoryPool since matching criteria for both are often identical. It can also be useful when defining pools as RAII objects. For example:

class MagicAndBuyMatcher: public OrderMatcher
  {
private:
   int               m_magic;
public:
                     MagicAndBuyMatcher(int m):m_magic(m){}
   virtual bool      matches() const {return Order::MagicNumber()==m_magic && Order::Type()==OP_BUY;}
  };
...
// elsewhere
   MagicAndBuyMatcher myMatcher(1337);
   TradingPool tp(&myMatcher);
   HistoryPool hp(&myMatcher);
   foreachorder(tp) {
   ...
   }