How do I make an EA to trade exactly the same on "open bars" and "Every real tick" settings on history?

Cristian Eriksson
4225

How do I make an EA to trade exactly the same on "open bars" and "Every real tick" settings on history?


I did create a function that only allows the EA to trade on the first tick

if (iVolume(Symbol(),PERIOD_M15,0 )!= 1)return;


But I get a diffrent equity graph than when setting the settings to "Every tick based on real ticks" than "Open prices only".


Can someone explain what is going on here. I thought the history of open bars was the first tick of each bar recorded?

Real ticks history

Open bars history

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
William Roeder
25838
William Roeder  
Cristian Eriksson: iVolume(Symbol(),PERIOD_M15)==1
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.

I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
          New candle - MQL4 programming forum #3 2014.04.04

Cristian Eriksson
4225

Thank you! They look much more similar now. Still not exactly, but that might come down to price history errors?

Open prices

Every tick based of real ticks

void OnTick()
  {
  if(TradeFrequenzy==WilliamCandle && !NewWilliamCandle(TF))
    return;
  }

bool NewWilliamCandle(ENUM_TIMEFRAMES TimeFr)
  {
  static datetime timeCur; 
  datetime timePre = timeCur; 
  timeCur=iTime(Symbol(),TimeFr,0);
  bool isNewBar = timeCur != timePre;
  return(isNewBar);
  }