77 lines
4.4 KiB
MQL5
77 lines
4.4 KiB
MQL5
|
//+------------------------------------------------------------------+
|
||
|
//| BigDeals_api.mqh |
|
||
|
//+------------------------------------------------------------------+
|
||
|
#property copyright "Copyright 2019, Yurich."
|
||
|
#property link "https://www.mql5.com/ru/users/yurich"
|
||
|
#property version "1.00"
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| Event numbers for BigDeals |
|
||
|
//+------------------------------------------------------------------+
|
||
|
#define BIGDEALS_TRADE_ASK 7702 // event number for single trade Ask
|
||
|
#define BIGDEALS_TRADE_BID 7703 // event number for single trade Bid
|
||
|
#define BIGDEALS_CHAIN_ASK 7704 // event number for chain of trades Ask
|
||
|
#define BIGDEALS_CHAIN_BID 7705 // event number for chain of trades Bid
|
||
|
#define BIGDEALS_LEVEL_ASK 7706 // event number for level of trades Ask
|
||
|
#define BIGDEALS_LEVEL_BID 7707 // event number for level of trades Bid
|
||
|
#define BIGDEALS_LEVEL_TOTAL 7708 // event number for level of trades Ask+Bid
|
||
|
#define BIGDEALS_LEVEL_DELTA 7709 // event number for level of trades Ask-Bid
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| custom event handling function |
|
||
|
//+------------------------------------------------------------------+
|
||
|
typedef void(*CustomHandler)(long _volume,double _price);
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| Class CBigDeals |
|
||
|
//| Purpose: Class of BigDeals indicator. |
|
||
|
//| |
|
||
|
//| The class allows you to receive events from BigDeals indicator |
|
||
|
//| and set new filter values. |
|
||
|
//| Event processing occurs in user-defined functions of the form: |
|
||
|
//| |
|
||
|
//| void NameFunction(long volume, double price). |
|
||
|
//| |
|
||
|
//| Each event requires its own handler. |
|
||
|
//+------------------------------------------------------------------+
|
||
|
class CBigDeals
|
||
|
{
|
||
|
CustomHandler m_handles[8];
|
||
|
public:
|
||
|
CBigDeals();
|
||
|
// receiving events of indicator
|
||
|
bool CheckEvents(const int event,const long &lparam,const double &dparam,const string &sparam);
|
||
|
// add user handler for event
|
||
|
bool AddHandler(const uint _event,CustomHandler _func);
|
||
|
// setting filter value for single trades
|
||
|
void SetFilterSingleTrades(const long _volume) { EventChartCustom(0,BIGDEALS_TRADE_ASK, _volume,0,NULL);}
|
||
|
// setting filter value for chain of trades
|
||
|
void SetFilterChainTrades(const long _volume) { EventChartCustom(0,BIGDEALS_CHAIN_ASK, _volume,0,NULL);}
|
||
|
// setting filter value for level Ask,Bid
|
||
|
void SetFilterLevelAskBid(const long _volume) { EventChartCustom(0,BIGDEALS_LEVEL_ASK, _volume,0,NULL);}
|
||
|
// setting filter value for level Ask+Bid
|
||
|
void SetFilterLevelTotal(const long _volume) { EventChartCustom(0,BIGDEALS_LEVEL_TOTAL,_volume,0,NULL);}
|
||
|
// setting filter value for level delta
|
||
|
void SetFilterLevelDelta(const long _volume) { EventChartCustom(0,BIGDEALS_LEVEL_DELTA,_volume,0,NULL);}
|
||
|
};
|
||
|
//+------------------------------------------------------------------+
|
||
|
CBigDeals::CBigDeals()
|
||
|
{
|
||
|
for(int i=0; i<8; i++) m_handles[i]=NULL;
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|
||
|
bool CBigDeals::AddHandler(const uint _event,CustomHandler _func)
|
||
|
{
|
||
|
if(_event<BIGDEALS_TRADE_ASK || _event>BIGDEALS_LEVEL_DELTA) return(false);
|
||
|
m_handles[_event-BIGDEALS_TRADE_ASK]=_func;
|
||
|
return(true);
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|
||
|
bool CBigDeals::CheckEvents(const int event,const long &lparam,const double &dparam,const string &sparam)
|
||
|
{
|
||
|
int x=event-CHARTEVENT_CUSTOM-BIGDEALS_TRADE_ASK;
|
||
|
if(x<0 || x>7 || dparam==0) return(false);
|
||
|
if(m_handles[x]==NULL) return(false);
|
||
|
CustomHandler f=m_handles[x];
|
||
|
f(lparam,dparam);
|
||
|
return(true);
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|