MetaTrader 5 Strategy Tester: bugs, bugs, suggestions for improvement - page 47

 
traveller00:

Build 2280. Exchange, futures market. All history is loaded, but tests are done offline. iBarShift works strangely in indicators. And the same code works fine in the script. Is it a bug or am I missing something?

There is such a code. It essentially runs through all symbols from the market review and yanks theiBarShift. The same code works fine in the script. The indicator produces -1 for all symbols, except for the current one (on the chart of which it is running) with the error that there is no history. At the same time, on the second run, it loads the history and displays it normally.

The availability of data in the indicator is not guaranteed, so you should check the success of data retrieval. If it fails, then retry inOnCalculate. Referring to the data in OnInit is not a good idea.


#property indicator_separate_window

void OnInit()
{
}

int OnCalculate(const int rates_total,const int prev_calculated,const datetime& time[],const double& open[],const double& high[],
  const double& low[],const double& close[],const long& tick_volume[],const long& volume[],const int& spread[])
{
  static bool printed = false;
  
  if( !printed ){
    printed = TryToPrint();
  }
  return 0;
}

bool TryToPrint(){


  datetime Time[];
  ArraySetAsSeries(Time, true);
  Print("try");
  if( CopyTime(_Symbol,_Period,0,1,Time) != 1 )return false;

  int Shift=iBarShift(_Symbol,_Period,Time[0]);
  
  bool fail = false;
  if( Shift < 0 )fail = true; 
  string toprint = "Symbol="+_Symbol+", Shift="+(string)Shift;
  
  

  for(int i=0;i!=SymbolsTotal(true);++i)
  {
    const string SymbName=SymbolName(i,true);
    Shift=iBarShift(SymbName,_Period,Time[0]);
    
    if( Shift < 0 )fail = true;
    toprint = toprint + "\r\n" + "Symbol="+SymbName+", Shift="+(string)Shift;

  }
  if( !fail ) Print( toprint );
  
  return !fail;
}
 

The server name is not always displayed in the cache records.


 
In tst-format, the times of trades/orders are only in seconds (datetime). There are no milliseconds.
 
Is it correct that the tst file is not generated for such an EA?
input int i = 0;

void OnInit() {}


What condition must be met to create a single pass cache?

 
fxsaber:
Is it correct that the tst file is not generated for such an EA?


What condition must be met to create a single pass cache?

Yes, correct.

If there are no trades, the tst file is not saved

 
Slava:

Yes, that's right.

If there are no trades, the tst file is not saved

Thank you.

 
I will repeat my question (apparently it got lost):

Developers, a question for you. Is it possible to customize the parametersof the genetic algorithm? For example to set stop and mutation criteria?

I often encounter situations when a stop occurs before the extremums are reached.

Also a question. Do you intend to implement other methods, e.g. simulated annealing?

 
Hi all, switched from mt4 to mt5 and don't understand how to save set files in the tester. Can you please advise. Could only find how to save ini and opt
 

I run the robot in the tester. I trade on a certain symbol. I enter by OnTimer and take price quote from SymbolInfoTick.

If I use different symbols (when I trade on the same symbol) then for some reason my results are very much different. May be anyone has faced this problem? I'm currently studying this behaviour in more detail.

PS. Every tick is based on a real one and perfect execution with no delays
 

I've figured it out. If you are interested, to save CPU resources, I check TimeCurrent in OnTimer and if it has not changed since the last update, nothing needs to be done. If there are no quotes, the status is the same. If you track trading sessions, it's a very consuming operation.

Everything works fine for multiple symbols. But when there are only two of them - everything depends on quotes, which come and starts shifting the time of opening positions and other things. As a result, the results inthe strategy tester are different.

PS. In general, I will check symbol states individually viaSymbolInfoTick