Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trade: add pool constructor options #33

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions Trade/OrderPool.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,43 @@
//| OrderPoolIter or the macro foreachorder to iterate through an |
//| order pool. |
//+------------------------------------------------------------------+
class OrderPool: public OrderMatcher
interface OrderPool: public OrderMatcher
{
int total() const;
bool select(int i) const;
};
//+------------------------------------------------------------------+
//| The pool of orders with supplied predefined matcher |
//+------------------------------------------------------------------+
class OrderPoolMatcher: public OrderPool
{
private:
const OrderMatcher *m_om;
public:
virtual int total() const=0;
virtual bool select(int i) const=0;
virtual bool matches() const=0;
OrderPoolMatcher(const OrderMatcher *m):m_om(m){}
virtual bool matches() const {return m_om?m_om.matches():true;}
};
//+------------------------------------------------------------------+
//| The pool of orders from the Terminal order history tab |
//+------------------------------------------------------------------+
class HistoryPool: public OrderPool
class HistoryPool: public OrderPoolMatcher
{
public:
HistoryPool():OrderPoolMatcher(NULL){}
HistoryPool(const OrderMatcher *m):OrderPoolMatcher(m){}
int total() const final {return OrdersHistoryTotal();}
bool select(int i) const final {return OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);}
virtual bool matches() const {return true;}
};
//+------------------------------------------------------------------+
//| Currently active orders |
//+------------------------------------------------------------------+
class TradingPool: public OrderPool
class TradingPool: public OrderPoolMatcher
{
public:
TradingPool():OrderPoolMatcher(NULL){}
TradingPool(const OrderMatcher *m):OrderPoolMatcher(m){}
int total() const final {return OrdersTotal();}
bool select(int i) const final {return OrderSelect(i,SELECT_BY_POS,MODE_TRADES);}
virtual bool matches() const {return true;}
};
//+------------------------------------------------------------------+
//| For internal use: iterate through an OrderPool |
Expand Down