Libraries: SingleTesterCache - page 7

fxsaber #:

I would record the maximum value. The time of creating the next TesterTradeState-record probably depends on the frequency chosen by the developers and some other conditions.

If I had a task to create a very similar tst-file to the original one, I would not achieve identical TesterTradeState[].

Got it

After running the SingleTesterCache_Example.ex5 script, the Test.tst result does not open in the Strategy Tester when I click the ‘Previous Results’ button.

I have attached the file containing the script’s output and the account history on which I ran the script.

I updated the library today.

MT5 build 6230.

Files:
Files.zip  315 kb
Ivan Titov the Strategy Tester when the ‘Previous Results’ button is clicked.

I haven’t used the Save method since the library was created (it’ll soon be seven years). During that time, MQ has most likely made some changes.


You need to take the original TST file, read it and then save it. After that, check what the differences are.

I’m not ready to look into this myself just yet. I don’t use this functionality.

In other words, when it comes to ‘writing tst files’ , it’s best not to usethis library. Only for ‘reading’. Am I right?
Ivan Titov #:
In other words, when it comes to ‘writing TST files’ , it’s best not to usethis library. It’s only suitable for ‘reading’. Am I right?
If you’re writing files to be read by the Tester, some explicit modifications will be required. We’ll need to look into what exactly is needed.
fxsaber #:
If the code is intended to be read by a tester, it clearly needs some refinement. We’ll need to see what sort.
Replace this number
      this.Header.version = ::MathMax(this.Header.version, 502);

with 505.


If you need to discuss backtest results without advertising (for example, an expert advisor from the Market), you can anonymise the tst file and post it on the forum without any issues.

Here’s how to do it.

#include <fxsaber\SingleTesterCache\SingleTesterCache.mqh> // https://www.mql5.com/en/code/27611
#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/en/code/26132

template <typename T>
void ChangeComments( T &Array[], const string NewComment = NULL )
{
  for (uint i = ArraySize(Array); (bool)i--;)
    Array[i].comment = NewComment;
    
  return;
}

void ChangeName( SINGLETESTERCACHE &SingleTesterCache, const string Name = "Deleted", const bool Comments = false )
{
  SingleTesterCache.Header.expert_name = Name;            // expert’s name
  SingleTesterCache.Header.expert_path = Name;            // expert name with path from MQL5

  if (!Comments)
  {  
    ChangeComments(SingleTesterCache.Deals);
    
    ChangeComments(SingleTesterCache.Orders);
  }
  
  return;
}

void OnStart()
{  
  uchar Bytes2[];
  
  if (MTTESTER::GetLastTstCache(Bytes2) != -1) // If the last cache entry for a single run was successfully read
  {
    SINGLETESTERCACHE SingleTesterCache(Bytes2); // Assign it to the relevant object.

    ChangeName(SingleTesterCache);
    
    SingleTesterCache.Save("ForumBacktest.tst");
  }
}


First, carry out the backtest, then run this script in the Terminal. The result will be your backtest file with all identifying details removed. Consequently, all the backtest statistics will be preserved, and you can post them on the forum without any concerns.

Here, in the source code, you can see how to organise operations to run concurrently with any number of single-pass caches.


In particular, this is how transactions are isolated.

struct DEAL_SIGN2 : public DEAL_SIGN
{
  bool operator =( const TradeDeal &Deal )
  {
    const bool Res = (Deal.action <= DEAL_TYPE_SELL);

    if (Res)
    {
      const double ContactSize = Deal.contract_size ? Deal.contract_size * 1000 : 1e8;

      this.Volume = (1.0 - (Deal.action << 1)) * Deal.volume / ContactSize;
      this.Time = Deal.time_create;
    }

    return(Res);
  }
};

int GetDeals( const string FileName, DEAL_SIGN &Deals[] )
{
  const SINGLETESTERCACHE SingleTesterCache(FileName);

  int Amount = 0;
  DEAL_SIGN2 Deal;

  for (int i = 0, const Size = ArrayResize(Deals, ArraySize(SingleTesterCache.Deals)); i < Size; i++)
    if (Deal = SingleTesterCache.Deals[i])
      Deals[Amount++] = Deal;

  return(ArrayResize(Deals, Amount));
}
Коэффициент НЕкорреляции.
Коэффициент НЕкорреляции.
  • www.mql5.com
При составлении портфеля ТС стараются опираться на статистику. Например, пробуют составлять таблицу корреляции на основе вычислений соответствующих коэффициента (КК). Основная причина такого подхода -
fxsaber #:
Replace this number

with 505.

The transactions have been calculated, but there’s something wrong with the totals: