81 lines
2.3 KiB
MQL5
81 lines
2.3 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| OnBookEvent.mq5 |
|
|
//| Copyright 2020, MetaQuotes Software Corp. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2020, MetaQuotes Software Corp."
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
//+------------------------------------------------------------------+
|
|
//| Expert initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
//---
|
|
MarketBookAdd(_Symbol);
|
|
|
|
//---
|
|
return(INIT_SUCCEEDED);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert deinitialization function |
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//---
|
|
MarketBookRelease(_Symbol);
|
|
|
|
//---
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert tick function |
|
|
//+------------------------------------------------------------------+
|
|
void OnTick()
|
|
{
|
|
//---
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| BookEvent function |
|
|
//+------------------------------------------------------------------+
|
|
void OnBookEvent(const string &symbol)
|
|
{
|
|
//---
|
|
MqlBookInfo DomArr[];
|
|
|
|
//---
|
|
MarketBookGet(_Symbol,DomArr);
|
|
|
|
//---
|
|
string comment="";
|
|
|
|
//---
|
|
for(int i=0; i<ArraySize(DomArr); i++)
|
|
{
|
|
//---
|
|
string BidOrAsk="";
|
|
|
|
//---
|
|
if(DomArr[i].type==1)
|
|
{
|
|
BidOrAsk="Ask";
|
|
}
|
|
else
|
|
{
|
|
BidOrAsk="Bid";
|
|
}
|
|
|
|
//---
|
|
if(DomArr[i].volume>150)
|
|
{
|
|
Print("A volume of 150 or more has been found @",DomArr[i].price);
|
|
}
|
|
|
|
//---
|
|
comment+="Price: @"+DoubleToString(DomArr[i].price,_Digits)+" Vol: "+IntegerToString(DomArr[i].volume)+" Type: "+BidOrAsk+"\n";
|
|
}
|
|
|
|
//---
|
|
Comment(comment);
|
|
}
|
|
//+------------------------------------------------------------------+
|