1minute OHLC vs every tick - opposite results

michelino  

I'm getting complete opposite result when testing on every tick or 1min OHLC. the EA and input parameters are exactly the same but in the case of 1min ohlc I get 50000 profit while in every tick I get -7000 losses.

this happens on many pairs testing on a period of 2 years 0811-0813

someone have had the same problem? I don't understand what is the problem here and what shall I do when trading real money. 

 both graph below

1minute OHLC

1minute ohlc

every tick

every tick

 

 

 

Uwe Goetzke  

Without any information how your EA decides to buy/sell this is difficult to answer.

We see in the market a lot of situations where one bar has a very big size (for example on important news).

So the tester generates up to 11 ticks for such a bar. Depending on your logic it acts very different (in testing alone).

If you would use your EA with real money I am quite shure it will be much worse because such big bars may have up to 200 ticks in one minute.

I assume that your logic acts on the current bar, you should try your logic with the values of the previous bar.

Best wishes

Uwe

Jordi Bassaganas  
ugo58:

Without any information how your EA decides to buy/sell this is difficult to answer.

We see in the market a lot of situations where one bar has a very big size (for example on important news).

So the tester generates up to 11 ticks for such a bar. Depending on your logic it acts very different (in testing alone).

If you would use your EA with real money I am quite shure it will be much worse because such big bars may have up to 200 ticks in one minute.

I assume that your logic acts on the current bar, you should try your logic with the values of the previous bar.

Best wishes

Uwe

I send now a trick for only "ticking" in one bar. You just have tu put this logic at the beginning of the tick. If the bar is not new then exits...

In which situations do you think that this trick may work well?

   //--- Let's first check if a new bar has come!         
   if(CopyTime(_Symbol, _Period, 0, 1, m_currentBarTime) > 0) 
     {
      if(m_previousBarTime != m_currentBarTime[0])
        {
         m_isNewBar = true;
         m_previousBarTime = m_currentBarTime[0];
        }
     }
   else
     {
      Alert("Error copying historical data, error: ", GetLastError());
      return;
     }
     
   if(!m_isNewBar) return;

What would you also recommend to solve those extra ticks? Is there an article or so explaining this? Thank you.

Alain Verleyen  
laplacianlab:

I send now a trick for only "ticking" in one bar. You just have tu put this logic at the beginning of the tick. If the bar is not new then exits...

In which situations do you think that this trick may work well?

What would you also recommend to solve those extra ticks? Is there an article or so explaining this? Thank you.

What do you mean by "to solve those extra ticks" ?
michelino  
ugo58:

Without any information how your EA decides to buy/sell this is difficult to answer.

We see in the market a lot of situations where one bar has a very big size (for example on important news).

So the tester generates up to 11 ticks for such a bar. Depending on your logic it acts very different (in testing alone).

If you would use your EA with real money I am quite shure it will be much worse because such big bars may have up to 200 ticks in one minute.

I assume that your logic acts on the current bar, you should try your logic with the values of the previous bar.

Best wishes

Uwe

hi,

what do you mean using the values of previous bar? use maVal[1] (where maVal contains moving average values and the array is set as series) instead of maVal[0]? 

or check whether the condition have been verified during the last bar and so enter on the opening of this bar? 

below part of the code of my very simple EA 

 triggerLong=maVal[1]-diff;
 triggerShort=maVal[1]+diff; 

......
.......

Buy_Condition_1=(now_ask<triggerLong);
Sell_Condition_1=(now_bid>triggerShort);

Exit_long_Condition=(closeAtCross? now_ask>=maVal[1]:false) || Sell_Condition_1;
Exit_short_Condition=(closeAtCross? now_bid<=maVal[1]:false) || Buy_Condition_1;

 whether I use maVal[1] or maVal[0] the situation doesn't change thath much, the ohcl is still profitable while every tick is not.

thanks  

Alain Verleyen  
ugo58:

Without any information how your EA decides to buy/sell this is difficult to answer.

We see in the market a lot of situations where one bar has a very big size (for example on important news).

So the tester generates up to 11 ticks for such a bar. Depending on your logic it acts very different (in testing alone).

If you would use your EA with real money I am quite shure it will be much worse because such big bars may have up to 200 ticks in one minute.

I assume that your logic acts on the current bar, you should try your logic with the values of the previous bar.

Best wishes

Uwe

This isn't true, tester can generates a lot more than 11 ticks. See this post.
Jordi Bassaganas  
angevoyageur:
What do you mean by "to solve those extra ticks" ?

I absolutely agree with ugo58. Big bars can trigger the event OnTick many times, while small bars will trigger it much fewer.

This can have an impact on your automated trading strategy, so we developers have to look for solutions that mitigate the fact that your event OnTick may be executed many many times per bar.

I think that what I sent before is just one solution. ugo50 proposed another solution: running your OnTick logic in the most recent past bar. Anyway, if you want to run your OnTick logic on the current bar maybe you can use something similar to what I sent before.

We are trying to implement something like a OnBar event.

What do you think about this?

Alain Verleyen  
michelino:

hi,

what do you mean using the values of previous bar? use maVal[1] (where maVal contains moving average values and the array is set as series) instead of maVal[0]? 

or check whether the condition have been verified during the last bar and so enter on the opening of this bar? 

below part of the code of my very simple EA 

 whether I use maVal[1] or maVal[0] the situation doesn't change thath much, the ohcl is still profitable while every tick is not.

thanks  

There is obviously a big difference if your code use maVal[1] or maVal[0], or in general if you are working on Closed bar only or on Open bar or inside a bar.

In the last case you need to use Every tick mode, all others mode aren't appropriate.

Uwe Goetzke  
angevoyageur:
This isn't true, tester can generates a lot more than 11 ticks. See this post.

Thx. Oh, well. One of things I just had to relearn. ;)


As I said it depends on your logic.

Their are a lot of ways to solve those issues, maVal[1]is one of the easier solutions as moving averages may not change so fast on each bar (depending on period length and smoothing method).

That could be different if for example you depend on a high and low of a range of bars.

Jordi Bassaganas  
Maybe this link is also useful, https://www.mql5.com/en/articles/159
"New Bar" Event Handler
"New Bar" Event Handler
  • 2010.10.11
  • Konstantin Gruzdev
  • www.mql5.com
MQL5 programming language is capable of solving problems on a brand new level. Even those tasks, that already have such solutions, thanks to object oriented programming can rise to a higher level. In this article we take a specially simple example of checking new bar on a chart, that was transformed into rather powerful and versatile tool. What tool? Find out in this article.