EventChartCustom => indicator is too slow - страница 6

 

Добрый день,

Похоже, что OnChartEvent () большую часть времени ожидает входящую галочку перед выполнением. Не тот случай с MT4.

Кто-нибудь может подтвердить это, пожалуйста. Спасибо.

int handle[9];
uint chartTick;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   string Symbol[]={"AUDUSD","USDCAD","USDCHF","EURUSD","EURJPY","GBPUSD","GBPJPY","USDJPY","NZDUSD"};
   for(int i=0;i<ArraySize(Symbol);i++)
      if(!SymbolSelect(Symbol[i],true) || (handle[i]=iCustom(Symbol[i],PERIOD_M1,"Tick.ex5",ChartID(),i+1))==INVALID_HANDLE)
         return(INIT_FAILED);   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   for(int i=0;i<ArraySize(handle);i++)
      IndicatorRelease(handle[i]);
//---
  } 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
   chartTick=GetTickCount();

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   if(id>CHARTEVENT_CUSTOM && lparam<chartTick)
      printf("ChartEvent : %u Tick : %u Symbol: %s",chartTick,lparam,sparam);
  }
//+------------------------------------------------------------------+
Файлы:
Tick.mq5  2 kb
 
Ernst Van Der Merwe:

Добрый день,

Похоже, что OnChartEvent () большую часть времени ожидает входящую галочку перед выполнением. Не тот случай с MT4.

Кто-нибудь может подтвердить это, пожалуйста. Спасибо.

Can you please rephrase your question? Write in English.

 
Andrey Khatimlianskii :

Can you please rephrase your question? Write in English.

Hi Andrey,

Attached are two pairs of similar indicators for each platform.

ChartEvent opens the necessary charts with templates that send ticks back.

The MT4 version is more responsive with higher values ​​(the time difference between an incoming tick in OnCalculate () and EventChartCustom ().

From these it seems to me that OnChartEvent () in MT5 isn't firing inbetween ticks on its chart.


Файлы:
Tick.mq4  4 kb
Tick.tpl  1 kb
MT4.gif  4556 kb
Tick.mq5  4 kb
Tick.tpl  4 kb
MT5.gif  3303 kb
 
Ernst Van Der Merwe:

Hi Andrey,

Attached are two pairs of similar indicators for each platform.

ChartEvent opens the necessary charts with templates that send ticks back.

The MT4 version is more responsive with higher values ​​(the time difference between an incoming tick in OnCalculate () and EventChartCustom ().

From these it seems to me that OnChartEvent () in MT5 isn't firing inbetween ticks on its chart.

Here is the fix for MT5:

   if(id>CHARTEVENT_CUSTOM && btn!=NULL)
   {
      btn.SetString(OBJPROP_TEXT,StringFormat("%s %d",sparam,lparam-tickCount));
      ChartRedraw(0);
   }