Multi-Symbol Tick-event framework. - page 3

 
Alain Verleyen:

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 orders can be done if you really need it, but in MT4 is it really worth it ? Well, depends of the strategy I suppose.

Let's just say I have a strategy... Here's my reasoning for offline (inactive) charts

  • OnTick will introduce an additional  ~2-60ms of latency every time it is called. If you are running an OnTimer loop, ticks will interrupt the loop and bring about unwanted latency.
  • The alternative is to run the loop inside of OnTick and use sleep for more calibrated intervals, however, with this approach you lose the ability to use the timer or chart event handler. 
  • Running an OnTimer loop on an inactive chart will guarantee that OnTick will not interrupt the intervals and you can still make use of the chart events, which is important for fast two-way communication between the workers and manager. 

 
nicholishen:

Let's just say I have a strategy... Here's my reasoning for offline (inactive) charts

  • OnTick will introduce an additional  ~2-60ms of latency every time it is called. If you are running an OnTimer loop, ticks will interrupt the loop and bring about unwanted latency.
  • ...

On what evidence is this based ?

There is not any latency if OnTick() is not used. If it's use why a 2-60ms latency ? That doesn't exist unless I misunderstood what you mean.

An OnTimer loop interrupted by ticks ? no such things unless I misunderstood what you mean.

I think you are overcomplicating things and searching solution to non-existent problems. But if I am wrong please explain and show it.

 
nicholishen:

Let's just say I have a strategy... Here's my reasoning for offline (inactive) charts

  • OnTick will introduce an additional  ~2-60ms of latency every time it is called. If you are running an OnTimer loop, ticks will interrupt the loop and bring about unwanted latency.
  • The alternative is to run the loop inside of OnTick and use sleep for more calibrated intervals, however, with this approach you lose the ability to use the timer or chart event handler. 
  • Running an OnTimer loop on an inactive chart will guarantee that OnTick will not interrupt the intervals and you can still make use of the chart events, which is important for fast two-way communication between the workers and manager. 

a) I would use OnTimer() in a offline chart to poll for prices. That means that I should be careful to poll for new prices; even then, polling at 50 ms can be much better than having a dozen of charts open with OnTick() on every single one

b) Have a second chart to handle orders signaled from the chart above. There should be no point for async orders in MT4, simulated or not. After, I should make sure consecutive orders of a single symbol are not messed up

regards

 
Alain Verleyen:

On what evidence is this based ?

There is not any latency if OnTick() is not used. If it's use why a 2-60ms latency ? That doesn't exist unless I misunderstood what you mean.

An OnTimer loop interrupted by ticks ? no such things unless I misunderstood what you mean.

I think you are overcomplicating things and searching solution to non-existent problems. But if I am wrong please explain and show it.

Oh boy... here we go again......

I posted the evidence earlier in the thread, and you even tested it out yourself and posted the results. Since you likely skimmed the posts in between, it was discovered that the latency in the ping was due to the behind the scenes post-processing of the OnTick event. The latency can vary depending on how many symbols in market watch and for no reason at all, and it is most certainly due to the OnTick event. If you want more obvious proof then run this EA on a live chart for a bit then look at the logs... then do the same on an offline chart. The delays from tick events are obvious, on my end at least.

#property strict

int OnInit()
{
   EventSetMillisecondTimer(1);
   return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
   EventKillTimer();
}
void OnTick()
{
   EventChartCustom(ChartID(),1,GetMicrosecondCount(),1.,_Symbol);
}

void OnTimer()
{
   EventChartCustom(ChartID(),1,GetMicrosecondCount(),1.,_Symbol);
   EventKillTimer();
}

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   printf("Interval time = %d",(GetMicrosecondCount()-lparam)/1000);
   EventChartCustom(ChartID(),1,GetMicrosecondCount(),1.,_Symbol);
}
//+------------------------------------------------------------------+
 
Demos Stogios:

a) I would use OnTimer() in a offline chart to poll for prices. That means that I should be careful to poll for new prices; even then, polling at 50 ms can be much better than having a dozen of charts open with OnTick() on every single one

b) Have a second chart to handle orders signaled from the chart above. There should be no point for async orders in MT4, simulated or not. After, I should make sure consecutive orders of a single symbol are not messed up

regards

I appreciate the thoughts, but... 

  1. That's what I was getting at, that way I could still use chart-events. There would be benefits to using separate charts, however, for example you could implement psuedo-multi-threading eg. tick comes in and each unique EA is doing it's own calculations for that particular symbol and feeding back basic data through the custom event. This would be easier to implement than OpenCL.
  2. I wholeheartedly and respectfully disagree with these remarks. I've found it beneficial to place multiple small orders at tight intervals in order to avoid slippage and get better fills. Being able to put groups of orders on and take them off all at once is critical. Additionally, if I wanted to enter a basket of trades in a fast market it would be beneficial to place all orders simultaneously. Most importantly it is crucial for risk management because if you cannot pull multiple orders simultaneously then you risk getting filled when you didn't want or your losses multiply as you wait.....and wait....and waittt for each order to close one by sluggish-one.  .  .   
 
nicholishen:

Oh boy... here we go again......

I just expressed my opinion, if you can't manage contradictions or misunderstandings you should not post on a public forum.  Please stop that attitude.

I posted the evidence earlier in the thread, and you even tested it out yourself and posted the results. Since you likely skimmed the posts in between, it was discovered that the latency in the ping was due to the behind the scenes post-processing of the OnTick event. The latency can vary depending on how many symbols in market watch and for no reason at all, and it is most certainly due to the OnTick event. If you want more obvious proof then run this EA on a live chart for a bit then look at the logs... then do the same on an offline chart. The delays from tick events are obvious, on my end at least.

Checking...

 
Alain Verleyen:
I just expressed my opinion, if you can't manage contradictions or misunderstandings you should not post on a public forum.  Please stop that attitude.

Checking...

You attack my position on 100% of the threads that I start... This is the cycle between you and I... 

  • I post something
  • You make an opinion
  • I post evidence
  • You ignore evidence
  • I post more scripts 
  • You assert your "knowledge"
  • I assert evidence
  • You make personal attacks
  • Someone else gets involved
  • You throw a fit
  • Some time goes by and you finally accept evidence
  • Cycle repeats

 
nicholishen:

You attack my position on 100% of the threads that I start... This is the cycle between you and I... 

  • I post something
  • You make an opinion
  • I post evidence
  • You ignore evidence
  • I post more scripts 
  • You assert your "knowledge"
  • I assert evidence
  • You make personal attacks
  • Someone else gets involved
  • You throw a fit
  • Some time goes by and you finally accept evidence
  • Cycle repeats

I was just trying to understand what you mean. I asked you to explain your view and you got mad once again.

Banned 1 week for repeated trolling, coming to non-existent personal issues each time someone "contradict" or ask question. Enough is enough.

 

After my own test : 


OnTimer Min loop : 16ms even if you ask 1ms (As it's said in the doc)

So a While loop with Sleep(1) would be more efficient. 


For the OnTick() Function lantency don't know I'll code something to test that and keep you posted.