Goodday i Created An expect that Finds Newly Created Objects on a custom Indicator And Reports that a new object has being created on Chart

 

i Created An expect that Finds Newly Created Objects on a custom Indicator And Reports that a new object has being created on Chart


Code:

//+------------------------------------------------------------------+

//|                                        Object expert advisor.mq5 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

string  NamePart;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
string NamePart = "ePASimple_0";
ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
ChartSetInteger(0,CHART_EVENT_OBJECT_DELETE,true);


   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
 
   
  }
//+------------------------------------------------------------------+
//| Trade function                                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Tester function                                                  |
//+------------------------------------------------------------------+
double OnTester()
  {
//---
   double ret=0.0;
//---
   return(ret);
  }
//+------------------------------------------------------------------+
//| TesterInit function                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| TesterPass function                                              |
//+------------------------------------------------------------------+
void OnTesterPass()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(id==CHARTEVENT_OBJECT_CREATE){
   
   NewObject(sparam);
  
   
   
   return;
   
   
   
  }
  }
//+------------------------------------------------------------------+
void NewObject(string name){


if (StringSubstr(name ,StringLen(NamePart))!=NamePart)return;
int sub_window = ObjectFind(0,name);
if(sub_window !=0) return;
long type = ObjectGetInteger(0,name ,OBJPROP_TYPE);
if(type!=OBJ_ARROW_BUY && type!=OBJ_ARROW_SELL)return;

//Found do something else 
//ReportObject
string objet_type = ObjectGetString(0,name,OBJPROP_TEXT);
PrintFormat("OBJ TEXT IS"+objet_type);
ReportObject("New",name);
}
void ReportObject(string event , string name){

datetime object_time   = (datetime) ObjectGetInteger(0,name , OBJPROP_TIME);
ENUM_OBJECT object_type = (ENUM_OBJECT)ObjectGetInteger(0,name ,OBJPROP_TYPE);
int object_bar        = iBarShift(Symbol(),Period(), object_time);
double object_Price   =ObjectGetDouble(0,name,OBJPROP_PRICE);
double bsr_high       =iHigh(Symbol(),Period(),object_bar);
double bar_low        =iLow(Symbol(), Period(),object_bar);
string objet_type1 = ObjectGetString(0,name,OBJPROP_TEXT);

PrintFormat("This is where you trade your strategy using information ftom thw objeçt");
PrintFormat("Event =%s",event);
PrintFormat(""+name+""+"Description"+objet_type1);
PrintFormat("Object type =%s", EnumToString(object_type));
PrintFormat("time=%s,bar=%i,price=%f, high=%f , low=%f", TimeToString(object_time),object_bar);
}
 
Are you facing any issue with this code ?