• Sign up >>

MT5 chart autorefresh

To add comments, please log in or register
kepter
294
kepter  

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;
  }
//+------------------------------------------------------------------+

Alain Verleyen
39007
Alain Verleyen  

No need to do that.

Use this statement to refresh the current chart :

ChartSetSymbolPeriod(0,NULL,0);
kepter
294
kepter  
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.

To add comments, please log in or register