Errors, bugs, questions - page 1857

 

And how to overload the [] and = operators, so that you can write like this:

class A
{
private:
   int arr[5];
};

A *obj = new A();

for(int i = 0; i < 5; ++i)    obj[i] = i;

 
Konstantin:

And how to overload the [] and = operators, so that you can write like this:

class A
{
   int arr[5];
   
   int CurrentPos;
   
public:
  A* operator []( const int Pos )
  {
    this.CurrentPos = Pos;
    
    return(&this);
  }

  void operator =( const int Value )  
  {
    this.arr[this.CurrentPos] = Value;
  }
};
 
fxsaber:


Thank you, but how do I overload the [] operator again so that I can write in addition to what I've written above?

class A
{
   int arr[5];
   
   int CurrentPos;
   
public:
  A* operator []( const int Pos )
  {
    this.CurrentPos = Pos;
    
    return(&this);
  }

  void operator =( const int Value )  
  {
    this.arr[this.CurrentPos] = Value;
  }
};

for(int i = 0; i < 5; ++i)

   int _value = obj[i];

 
Konstantin:

Thank you, but how do I overload the [] operator again so that I can write in addition to what I've written above?

class A
{
   int arr[5];
   
   int CurrentPos;
   
public:
  A* operator []( const int Pos )
  {
    this.CurrentPos = Pos;
    
    return(&this);
  }

  void operator =( const int Value )  
  {
    this.arr[this.CurrentPos] = Value;
  }

  int operator []( const uint Pos ) const
  {
    return(this.arr[Pos]);
  }
};

void OnStart()
{
  A obj;

  for (int i = 0; i < 5; ++i)  
    obj[i] = i;
    
  for (uint i = 0; i < 5; ++i)  
    int _value = obj[i];
}
 
fxsaber:

Thanks again, I didn't know what to do with these overloads, doing them separately works, but not together ))
 

typo in the documentation?

https://www.mql5.com/ru/docs/series/copyticksrange

int  CopyTicks(
   const string     symbol_name,           // имя символа
   MqlTick&         ticks_array[],         // массив для приёма тиков
   uint             flags=COPY_TICKS_ALL,  // флаг, определяющий тип получаемых тиков
   ulong            from_msc=0,            // дата, начиная с которой запрашиваются тики
   ulong            to_msc=0               // дата, по которую запрашиваются тики
   );
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyTicksRange
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyTicksRange
  • www.mql5.com
Доступ к таймсериям и индикаторам / CopyTicksRange - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

The tester goes into a terrible brake mode after 25K transactions.

Running 1585, on ticks, RTS-6.17, Metaquotes-Demo

#include <MT4Orders.mqh>

void OnTick()
{  
  static bool Error = false;  
  static int Type = OP_BUY;
  
  if (Error)
    return;
  
  MqlTick Tick;    

  if (OrderSelect(0, SELECT_BY_POS) && (OrderType() <= OP_SELL))
    OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0);    
  else if ((OrdersTotal() == 0) && SymbolInfoTick(_Symbol, Tick) && (Tick.bid != 0) && (Tick.ask != 0))
  {
    Error = (OrderSend(_Symbol, Type + OP_BUYLIMIT, 1, (Type == OP_BUY) ? Tick.ask : Tick.bid, 0, 0, 0, "", 0, 0, INT_MAX) == -1);        
    
    if (!Error)
    {
      OrderSend(_Symbol, Type + OP_BUYLIMIT, 1, (Type == OP_BUY) ? Tick.ask : Tick.bid, 0, 0, 0);
      
      Type = OP_SELL - Type;
    }    
  }
}

I don't see any reason for the lags. It feels like ArrayResize(Orders, ArraySize(Orders) + 1) was written. I.e. Reserve_Size is not used.

 
There is no time in the tester log when the Expired recording is in progress
2017.04.19 10:46:15.165 2017.04.06 23:09:37   sell limit 1.00 RTS-6.17 at 114300 (114290 / 114300 / 114300)
2017.04.19 10:46:15.168 order expired [#284  sell limit 1.00 RTS-6.17 at 114300]
2017.04.19 10:46:15.168 2017.04.07 09:45:04   buy limit 1.00 RTS-6.17 at 114170 (114140 / 114180)
 
Please add milliseconds to the tester log in addition to the historical time.
 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2017.04.19 08:58

Tester goes into creepy brake mode after 25K transactions.

Running 1585, on ticks, RTS-6.17, Metaquotes-Demo

#include <MT4Orders.mqh>

void OnTick()
{  
  static bool Error = false;  
  static int Type = OP_BUY;
  
  if (Error)
    return;
  
  MqlTick Tick;    

  if (OrderSelect(0, SELECT_BY_POS) && (OrderType() <= OP_SELL))
    OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0);    
  else if ((OrdersTotal() == 0) && SymbolInfoTick(_Symbol, Tick) && (Tick.bid != 0) && (Tick.ask != 0))
  {
    Error = (OrderSend(_Symbol, Type + OP_BUYLIMIT, 1, (Type == OP_BUY) ? Tick.ask : Tick.bid, 0, 0, 0, "", 0, 0, INT_MAX) == -1);        
    
    if (!Error)
    {
      OrderSend(_Symbol, Type + OP_BUYLIMIT, 1, (Type == OP_BUY) ? Tick.ask : Tick.bid, 0, 0, 0);
      
      Type = OP_SELL - Type;
    }    
  }
}

Is it working? Tester settings are as follows

Result

Tester  RTS-6.17,M1: 254907 ticks, 785 bars generated. Test passed in 0:15:54.180 (including ticks preprocessing 0:00:00.047).

I.e. 250K ticks run in 16 minutes.


How is it possible to measure performance degradation in the tester? I tried GetTickCount and global variables, it fails.

Reason: