Download MetaTrader 5
To add comments, please log in or register
Publish your article and win recognition from thousands of traders!
gsudariojr
20
gsudariojr 2015.09.23 04:28 

how to calculate the total number of arrows on the chart and put an alert when emerging a new arrow

Vladimir Karputov
Moderator
37830
Vladimir Karputov 2015.09.23 17:37  
gsudariojr:

how to calculate the total number of arrows on the chart and put an alert when emerging a new arrow

Returns the number of objects ObjectsTotal, and ENUM_OBJECT = OBJ_ARROWED_LINE or another type.

gsudariojr
20
gsudariojr 2015.09.23 21:49  
Karputov Vladimir:
Returns the number of objects ObjectsTotal, and ENUM_OBJECT = OBJ_ARROWED_LINE or another type.

Show me an example please :/
Vladimir Karputov
Moderator
37830
Vladimir Karputov 2015.09.24 08:46  

Please.

Advisor counts the number of objects in a given sub-window:


//+------------------------------------------------------------------+
//|                                                 ObjectsTotal.mq5 |
//|                              Copyright © 2015, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property description "Returns the number of objects of the specified type."
//--- input
input ENUM_OBJECT inpObject=OBJ_ARROW_THUMB_UP; // object type
input int inpSub_Window=-1;                         // window index
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   int intCount=ObjectsTotal(0,inpSub_Window,inpObject);
   string count_windows="";
   if(inpSub_Window==-1)
      count_windows="all subwindows";
   else
      count_windows="subwindow № "+IntegerToString(inpSub_Window);
   string text="On the chart in "+count_windows+" is "+IntegerToString(intCount)+" "+EnumToString(inpObject);
   Alert(text);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
/
To add comments, please log in or register