Multi-Symbol Tick-event framework. - page 2

 
nicholishen:

The issue is the behind the scenes processing that the terminal does whenever OnTick is called which holds the thread until it is completed. So lets say a chart event comes in while OnTick is being called, what happens is OnTick called -> OnChartEvent wait for OnTick finish -> OnTick returns -> terminal does stuff -> now OnChartEvent is called.  

Please read my latest post (edit). I get 150 microseconds. You may download TimerTool and set the timer as you wish, or open a browser with a video site and the time will go down as well
 
Demos Stogios:
Please read my latest post (edit). I get 150microseconds. You may download TimerTool and set the timer as you wish, or open a browser with a video site and the time will go down as well

I don't think you are understanding the challenge. We are not discussing anything about system timers. We are discussing the latency introduced into the EA thread from the behind-the-scenes terminal processing of the OnTick function. This EA demonstrates exactly what we are talking about. 

#property strict
ulong g_timer;
int OnInit()
{
   return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
   EventKillTimer();
}
void OnTick()
{
   g_timer = GetMicrosecondCount();
   EventSetMillisecondTimer(1);
}
void OnTimer()
{
   printf("The time from OnTick to OnTimer took %d milliseconds.",(GetMicrosecondCount()-g_timer)/1000);
   EventKillTimer();
}
 
I suppose the most efficient way to manage a multi-currency EA is to run the receiver entirely from the OnChartEvent function on an off-line chart? 
 
nicholishen:
I suppose the most efficient way to manage a multi-currency EA is to run the receiver entirely from the OnChartEvent function on an off-line chart? 
Actually what is the initial reason the use Custom events ? What is the problem to run 1 EA trading multiple currencies ("perpetual loops") ?
 
Alain Verleyen:
Actually what is the initial reason the use Custom events ? What is the problem to run 1 EA trading multiple currencies ("perpetual loops") ?

MQL5 is easy, you just use OnBookEvent, but with MQL4 these perpetual loops are killing my processor (think AWS instance). So the solution (currently) is to drop the EA on a non-updating offline chart running in receive/calculate mode, and then the EA then opens up the live charts of subscribed symbols with clones running in send mode. 

 
Alain Verleyen:
Actually what is the initial reason the use Custom events ? What is the problem to run 1 EA trading multiple currencies ("perpetual loops") ?

You know... you got me thinking... Perhaps it would be more efficient to run an OnTimer perpetual loop on an offline chart instead of having multiple charts doing OnTick. Also, the asynchronous orders could be managed in the OnChartEvent handler in other offline charts so OnTick will never interfere with operation, correct? Do you know where I can find code to programmatically open offline charts?

 
nicholishen:

You know... you got me thinking... Perhaps it would be more efficient to run an OnTimer perpetual loop on an offline chart instead of having multiple charts doing OnTick. Also, the asynchronous orders could be managed in the OnChartEvent handler in other offline charts so OnTick will never interfere with operation, correct? Do you know where I can find code to programmatically open offline charts?

my 2 cents,

If you  want to use MT4, you can use a  single offline chart, and poll from there with OnTimer(), with a value of, say, 50ms. I can not remember MQL4, I guess one can use MarketInfo() or similar to get values of pairs from Market Watch. But, IIRC, MT4 does not have async orders

 
nicholishen:

MQL5 is easy, you just use OnBookEvent, but with MQL4 these perpetual loops are killing my processor (think AWS instance). So the solution (currently) is to drop the EA on a non-updating offline chart running in receive/calculate mode, and then the EA then opens up the live charts of subscribed symbols with clones running in send mode. 

Sorry but I still have no idea what you mean exactly by perpetual loops. I always use a timer and scan the different symbols, not a big deal. (Of course a tick event for each symbol would be nice).

 
Demos Stogios:

If you  want to use MT4, you can use a  single offline chart, and poll from there with OnTimer(), with a value of, say, 50ms. I can not remember MQL4, I guess one can use MarketInfo() or similar to get values of pairs from Market Watch. But, AFAIK, MT4 does not have async orders

It does asyncronous orders as long as those orders are sent from separate EAs. For example... 

   for(int i=0;i<active_charts.Total() && i<orders.Total();i++)
   {
      if(!EventChartCustom(active_charts[i],ASYNC_BUY,0,orders[i].lots,order[i].symbol))
         DebugBreak();
   }
   ...
 
nicholishen:

You know... you got me thinking... Perhaps it would be more efficient to run an OnTimer perpetual loop on an offline chart instead of having multiple charts doing OnTick. Also, the asynchronous orders could be managed in the OnChartEvent handler in other offline charts so OnTick will never interfere with operation, correct? Do you know where I can find code to programmatically open offline charts?

Why an offline chart ? Just don't use OnTick()...ah maybe you are thinking there is an overheid on a normal chart even without using OnTick() ?

Asynchronous "like" orders can be done if you really need it, but in MT4 is it really worth it ? Well, depends of the strategy I suppose.

Reason: