Tick Simulation - Start() runs every X milliseconds without loop

To add comments, please log in or register
Lime
649
Lime  

Hi Coders!

I have a DLL file (download) consists two functions for simulating new tick arriving. The functions are: IceLock_StartTicker() and IceLock_StopTicker().

Usage:

#import "IceFX.TraderAgent.dll"
   void IceLock_StartTicker(int a0, int a1);
   void IceLock_StopTicker(int a0);
#import

int init(){

   window_handle = WindowHandle(Symbol(),Period());

   IceLock_StartTicker(window_handle,200);

   return(0);  
}

int deinit(){

   IceLock_StopTicker(window_handle);
   
   return(0);
}


int start(){



   return(0);
}

You can set the delay in millisecond between the ticks in the IceLock_StartTicket() function. In the example, the Start() function will run every 200 milliseconds.

This DLL file isn't mine. I don't have the source code of it. But I would like to prepare my own. This is why I ask your help.

Can you help me, how to operate this StopTicker solution? How can we simulate new tick arrive? Is there any public solution for it?

Thank you in advance.

Relative

Ex Ovo Omnia
3356
Ex Ovo Omnia  

well, if I only needed to simulate ticks on a single chart, I would probably use a script like that. I have no trust in a third party DLL for such a simple task.

#property show_inputs
#include <WinUser32.mqh>
#import "user32.dll"
   int RegisterWindowMessageA(string lpString);
#import

extern int INTERVAL_MILLIS = 1000;

int start() {
        while(!IsStopped()) {
                int hwnd = WindowHandle(Symbol(), Period());
                int MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message");
                if(hwnd != 0 && MT4InternalMsg != 0) {
                        PostMessageA(hwnd, MT4InternalMsg, 2, 1);
                }
                Sleep(INTERVAL_MILLIS);
        }
        return(0);
}
whroeder1
17945
whroeder1  
The above wont work. Infinite loop posting messages, never stopping, never processing the messages.
Post a message and return
int start(){
   : // do something
   if(!IsStopped()) {
      int hwnd = WindowHandle(Symbol(), Period());
      int MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message");
      if(hwnd != 0 && MT4InternalMsg != 0) {
         PostMessageA(hwnd, MT4InternalMsg, 2, 1);
      }
      Sleep(INTERVAL_MILLIS);
   }
   return(0);
}
Just loop
int start(){
   while( !(IsTesting() || IsStopped()) ) {
      : // do something
      Sleep(INTERVAL_MILLIS);
      RefreshRates();
   }
   return(0);
}
Lime
649
Lime  

Thank you for your codes.

I can not call the Properties window (F7) under run. This is my problem with these solutions.

Ex Ovo Omnia
3356
Ex Ovo Omnia  
Relative:

Thank you for your codes.

I can not call the Properties window (F7) under run. This is my problem with these solutions.


I am not sure if I understand properly. You can run EA while the script sends the ticks. Or, with a slight modification you may send ticks from another chart window.
Lime
649
Lime  
Ovo:

I am not sure if I understand properly. You can run EA while the script sends the ticks. Or, with a slight modification you may send ticks from another chart window.

I would like to run the start() every X milliseconds. And when I press the F7, I would like to be able to modify the input parameters of the EA.

I can achieve this with the DLL file I mentioned. And I would like to rewrite that DLL in Delphi or in Pascal, because I need the source code too.

Ex Ovo Omnia
3356
Ex Ovo Omnia  
Ok, then the easiest way is, if you take the source for the MQL script I posted and port the 4 lines into Pascal. Then add the start(handle) and stop() controls.
Lime
649
Lime  
Ovo:
Ok, then the easiest way is, if you take the source for the MQL script I posted and port the 4 lines into Pascal. Then add the start(handle) and stop() controls.

Hm, I don't know how you think that. Can you show me, please? :)
Ex Ovo Omnia
3356
Ex Ovo Omnia  
Relative:

Hm, I don't know how you think that. Can you show me, please? :)


No, I cannot. I do not know Pascal.

For some reason you need DLL assembled from Pascal - I respect it, whatever the reason is. So take the loop from the MQL script, and port it to Pascal, and add the start-stop logic. I.e. transfer part of the script to your Pascal-based DLL and call it from MQL the same way your first post does.

Lime
649
Lime  
Ovo:


No, I cannot. I do not know Pascal.

For some reason you need DLL assembled from Pascal - I respect it, whatever the reason is. So take the loop from the MQL script, and port it to Pascal, and add the start-stop logic. I.e. transfer part of the script to your Pascal-based DLL and call it from MQL the same way your first post does.


Ok. Thank you for your help.
To add comments, please log in or register