Download MetaTrader 5
To add comments, please log in or register
Have you installed MetaTrader 5? Find out more about it!
honest_knave
959
honest_knave 2016.06.20 13:52 

When an object is CREATED by an indicator, it doesn't trigger OnChartEvent().

But when an object in DELETED by an indicator, it does.

#property strict
#property indicator_chart_window

int OnInit()
  {
   ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
   ChartSetInteger(0,CHART_EVENT_OBJECT_DELETE,true);
   EventSetTimer(5);
   return(INIT_SUCCEEDED);
  }

void OnTimer()
  {
   static bool flag=false;
   if(!flag) ObjectCreate(0,"test",OBJ_ARROW,0,Time[0],High[0]);
   else      ObjectDelete(0,"test");
   flag=!flag;
  }

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   Print(EnumToString((ENUM_CHART_EVENT)id));
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   return(rates_total);
  }

 

Does anybody know if this is a foible of Build 971, or has it always been like this?

Alain Verleyen
Moderator
28551
Alain Verleyen 2016.06.20 14:34  
honest_knave:

When an object is CREATED by an indicator, it doesn't trigger OnChartEvent().

But when an object in DELETED by an indicator, it does.

 

Does anybody know if this is a foible of Build 971, or has it always been like this?

 

 

I confirm. Doesn't work either in build 950 and 962. It works with MT5.
honest_knave
959
honest_knave 2016.06.20 15:23  
Thanks angevoyageur - looks like a bug then!
/
To add comments, please log in or register