MT5 chart autorefresh

 

Hi, I want to convert a chart autorefresh MT4 indicator I've found to MT5.

The indicador uses a postMessages WM_COMMAND,33324 and RegisterWindowMessageW("MetaTrader4_Internal_Message"),2,1 but seems they doesnt work on MT5.

Please, anyone could help me to find the correct messages?

Greetings.


#property copyright 

#property link    
//---
#property indicator_chart_window
#property strict
//---
extern int PeriodMiliSeconds=250;  // Period in miliseconds
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnInit()
  {
   EventSetMillisecondTimer((int)MathMax(PeriodMiliSeconds,16));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int Des)
  {
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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(0);
  }
//+------------------------------------------------------------------+
#import "user32.dll"
int RegisterWindowMessageW(string lpString);
int PostMessageW(int hWnd,int Msg,int wParam,int lParam);
#import
#define WM_COMMAND 0x0111
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
   static bool inUpdate=false;
   if(inUpdate) return;
   inUpdate=true;
   static int handle=0;
   if(handle == 0) handle = RegisterWindowMessageW("MetaTrader4_Internal_Message");
   if(handle!=0)
     {
      int whandle=WindowHandle(Symbol(),Period());
      PostMessageW(whandle,WM_COMMAND,33324,0);
      PostMessageW(whandle,handle,2,1);
     }
   inUpdate=false;
  }
//+------------------------------------------------------------------+

 

No need to do that.

Use this statement to refresh the current chart :

ChartSetSymbolPeriod(0,NULL,0);
 
Alain Verleyen:

No need to do that.

Use this statement to refresh the current chart :

Thank you but it doesn't work as expected. It does refresh the chart but doesn't generate a "virtual tick". I need to refresh my EA based on miliseconds instead of "onTick" . On MT4 it does that with the attached code.

 
[Deleted]:

Thank you but it doesn't work as expected. It does refresh the chart but doesn't generate a "virtual tick". I need to refresh my EA based on miliseconds instead of "onTick" . On MT4 it does that with the attached code.

Maybe someone could help further, there are two errors there that are difficult for me to edit.

Files:
 
Oluwaseyi Olakojo #:

Maybe someone could help further, there are two errors there that are difficult for me to edit.

here you go


#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
//---
extern int PeriodMiliSeconds=250;  // Period in miliseconds
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnInit()
  {
   EventSetMillisecondTimer((int)MathMax(PeriodMiliSeconds,16));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int Des)
  {
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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(0);
  }
//+------------------------------------------------------------------+
#import "user32.dll"
int RegisterWindowMessageW(string lpString);
int PostMessageW(int hWnd,int Msg,int wParam,int lParam);
#import
#define WM_COMMAND 0x0111
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
   static bool inUpdate=false;
   if(inUpdate) return;
   inUpdate=true;
   static int handle=0;
   int Whandle = 0,whandle = 0;
   if(handle == 0) handle = RegisterWindowMessageW("MetaTrader4_Internal_Message");
   if(handle!=0)
     {
      ChartSetSymbolPeriod(0,NULL,0);
      PostMessageW(Whandle,WM_COMMAND,33324,0);
      PostMessageW(whandle,handle,2,1);
     }
   inUpdate=false;
  }
//+------------------------------------------------------------------+
 

Have a code to refresh SERVER Connection?

 
Adolfo Damaceno #:

Have a code to refresh SERVER Connection?

Doesnt it already auto refresh?