MT4 v4.00 Build 950 NewTick Event on Offline Charts

 

I know this topic has been bashed around a lot on various forums,  but I have tried everything that I can find and nothing works,  including the ever popular

  if(hwnd == 0) {

    hwnd = WindowHandle(_Symbol, RTimeFrame);

    if(hwnd == 0) {

      return;

    } else {

      Print ("Offline Chart Window for ",_Symbol," detected.");

    }

  }

  if(MT4InternalMsg == 0) {

    MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message");

    if(MT4InternalMsg == 0) 

      return;

  }        

  if(PostMessageA(hwnd, WM_COMMAND, MT4_WMCMD_UPDATE_DATA, 0) == 0) {

    hwnd = 0;

  } else {

    PostMessageA(hwnd, MT4InternalMsg, 2, 1);

  } 

 

I have reworked this code in everyway imaginable and I cannot generate a NewTick Event on an Offline Chart window,  now as you might imagine I can get by with timer events on some less important management tasks,  but there are some things that simply must work on every tick.  It seems very odd to me that I cant raise an event in a given window, what is up with that??

 Can You please tell me how to send a NewTick Event to a Offline chart window??

 I am well aware that this code worked in previous builds of the MT4 Terminal,  but it will not work in the aforementioned build, no way, no how.

 Thanks in advance. 

 

Use PostMessageW not PostMessageA and you should get on fine

(strings are now unicode)

 
honest_knave:

Use PostMessageW not PostMessageA and you should get on fine

 

 

Still No Joy,  I am talking about the NewTick Event with the new Compiler,  build 600+  here is the routine that I am using at present.

 void UpdateChartWindow() {

  static int MT4InternalMsg = 0;

  static CChart MyOffLineChart;

  long chart_id = ChartNext(0);

 

  if(MT4InternalMsg == 0) {

    MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message");

    if(MT4InternalMsg == 0) 

      return;

  }

  while(chart_id != -1 ) {

    if(StringCompare(ChartSymbol(chart_id),_Symbol) == 0 && ChartGetInteger(chart_id,CHART_IS_OFFLINE)) {

      MyOffLineChart.Attach(chart_id);

      PostMessageW(MyOffLineChart.WindowHandle(), WM_COMMAND, MT4_WMCMD_UPDATE_DATA, 0);

      PostMessageW(MyOffLineChart.WindowHandle(), MT4InternalMsg, 2, 1);

      break;

    } else {

      chart_id = ChartNext(chart_id);  

    }

  }

  if(chart_id == -1) {

    MyOffLineChart.Attach(MyOffLineChart.Open(_Symbol,PERIOD_M2));

    MyOffLineChart.ApplyTemplate(TemplateFile);

  }

  return;

}

Now this statement is working

      PostMessageW(MyOffLineChart.WindowHandle(), WM_COMMAND, MT4_WMCMD_UPDATE_DATA, 0);

My chart is drawing as I pump data to the .hst file,  but the OnTick() handler is not firing.  Any ideas?? 

 
All strings are unicode - RegisterWindowMessageW too
 

Nevermind, I just discovered the EventChartCustom func,  just call OnTick from the OnChartEvent handler in the receiving chart and viola.

here is the code

class MyRenkoChart : public CChart {

public:

  void SendMyTick(void) {

    EventChartCustom(m_chart_id,69,0.0,0.0,"");

  }

};

void UpdateChartWindow() {

  static MyRenkoChart MyOffLineChart;


  if(MyOffLineChart.ChartId() != INVALID_HANDLE) {

    PostMessageW(MyOffLineChart.WindowHandle(), WM_COMMAND, MT4_WMCMD_UPDATE_DATA, 0);

    MyOffLineChart.SendMyTick();

  } else {

    MyOffLineChart.FirstChart();

    

    while(MyOffLineChart.ChartId() != INVALID_HANDLE ) {

      if(StringCompare(MyOffLineChart.Symbol(),_Symbol) == 0 && MyOffLineChart.GetInteger(CHART_IS_OFFLINE)) {

        PostMessageW(MyOffLineChart.WindowHandle(), WM_COMMAND, MT4_WMCMD_UPDATE_DATA, 0);

        MyOffLineChart.SendMyTick();

        break;

      } else {

        MyOffLineChart.NextChart();  

      }

    }

    if(MyOffLineChart.ChartId() == INVALID_HANDLE) {

      MyOffLineChart.Attach(MyOffLineChart.Open(_Symbol,2));

      MyOffLineChart.ApplyTemplate(TemplateFile);

    }

  }  

  return;

}

Reason: