A question for the MQ developers - how to trigger the tick?

 
Hello MetaQuotes developers,

I've been using the Period Converter Optimized to generate non-standard TF charts as listed on this forum ("Period converter optimized with real-time freshing support and low CPU cost")

My question is - would you mind sharing how to simulate the tick trigger? I see that we can do an UPDATE_DATA to get the window to refresh and a RefreshRates() to insure that things like Bid and Ask are up to date, but it would be a big thing to rewrite all EA's into scripts to auto trade these time frames.

Would it be possible to share what event or message I need to send to the offline window to let it know that a new tick has come in, so that it triggers the EA. This would allow a very desirable feature in MT4 without requiring any additional work on your part.

I very much appreciate your time and consideration...

Best regards,
CS
 
You can use script on the non-standard offline chart. Script with endless loop (like the 2-nd part of period converter script).

Try one trick:
1. Open M1 chart
2. Run period converter
3. Open offline M3 chart
4. Run period converter on the M3
5. Open offline M9 chart

RefreshRates()==true is same as incoming tick
 
Hi Slawa,

Thank you very much for the information. However, I am already aware of that option.

I'm asking for how to actually trigger the EA, not simulate it's purpose with a script.

Given that there are so many existing EA's, I'd prefer to not have to rewrite them into scripts - taking into account EA initialization, etc. So, while I could rewrite my EA's, I'd rather not have to.

In the interest of using an expert adviser AS IS with a M3 chart, I'm hoping that you can provide the specific message or event that is required to be passed to the offline M3 chart with each update that is done by the period converter - similar to the PostMessageA(hwnd,WM_COMMAND,CHART_CMD_UPDATE_DATA,0) that is used by the period converter script in line 313, but rather a message that will make an EA running on the offline M3 chart think that a "real" tick has come in.

I'm assuming that you must use a similar mechanism with the normal online charts - Each time a tick comes in, you must fire an event or message indicating to the EA that the start() function should cycle and run once again.

I'm also assuming that if you share that event with me, I can fire that message at the offline chart in addition to the CHART_CMD_UPDATE_DATA (33324) message. Then, I could have a continuously updated M3 chart, along with being able to use an EA as is.

Can you kindly provide this information? I think it would be of great benefit to your users, and would require no additional work on the part of your development team. MT4 is such a great program, and I would love to be able to auto trade with other time frame charts.

Thank you again for your time and help.

Best regards,
CS
 
I see. We will think of it, but I cannot promise anything at the moment.
 
I see. We will think of it, but I cannot promise anything at the moment.


I thank you kindly for your consideration! I greatly appreciate it and am hopeful for your answer.

Best regards,
CS
 
Hi Slawa,

Just checking to see if by chance there might be an update on my request? I would very much like to use non-standard timeframe charts.

Thank you kindly for your consideration.

Cheers,
CS
 
Try to test following script. Attach some EA to offline chart. Then drop this script. One dropping - one expert launch.

//+------------------------------------------------------------------+
//|                                                 IncomingTick.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <WinUser32.mqh>

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   int MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message");
   int hWnd = WindowHandle(Symbol(),Period());
   PostMessageA(hWnd,MT4InternalMsg,2,1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Hi Slawa,

Thank you very much for the update!

Unfortunately, this doesn't seem to work though.

This is what I did:

1) Made a small EA that simply prints the Bid and Ask
2) Attached it to an offline chart
3) dropped the IncomingTick script onto the offline window

But, nothing happened... Any advice?

Thank you again for your help...

Best regards,
CS
 
Download build 200 dated nov 21 and try once more
 
I just tried that with build 200 and it works.

you also need to add this to the winuser32.mqh file

int RegisterWindowMessageA(string lpString);

I have been want to do this for a while as well, so thanks for that Slawa.
 
I will try it when the market opens! Thank you very much!

Cheers,
CS
Reason: