Errors, bugs, questions - page 1935

 
Aleksey Vyazmikin:

So I'm not sure it's about trading functions...

The branch there is an example of constructive statements that anyone can reproduce.
 
fxsaber:
The branch there is an example of a constructive statement that anyone can reproduce.

I understand - I'd post the code, but it uses a class for trading functions that I haven't paid for yet...

When rendering, I observe a gradual slowdown - almost a couple of seconds per bar at max speed - any idea what it could be?

No antivirus checks, SSD drive, space on it...

 
Aleksey Vyazmikin:

Rewrote an EA from MT4 to MT5

The story is the same, testing by control points on minutes.

MT5

2017.07.20 20:01:38.059 Core 1 Si-9.17,M1: 107509 ticks, 35385 bars generated. Environment synchronized at 0:00:00.078. Test passed in 0:03:52.707 (including ticks preprocessing 0:00:00.031).

MT4

2017.07.20 20:02:32.696 RUBRUR,M1: 225314 tick events (35701 bars, 231783 bar states) processed in 0:00:04.259 (total time 0:00:11.310)

And where is the praised speed of MT5?
Show me both Expert Advisors' code. You've got the lazy MQL4 emulator instead of the native MQL5, right?
 
Renat Fatkhullin:
You show the code of both EAs. You have the lazy MQL4 emulator instead of native MQL5, right?

Not ready to show code yet due to

Forum on trading, automated trading systems and strategy testing

Bugs, bugs, questions

Aleksey Vyazmikin, 2017.07.20 23:28


I understand - I'd post the code, but it uses a class for trading functions that I haven't paid for yet...

But ready to show profiling results from MT5 - as I understand trading functions are out of the question.



For OHLC environment I use the following functions

//-------------------------------------------------------------------
//==MQL4toMQL5
//+------------------------------------------------------------------+ 
//| Получим Open для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Open(int index)
  {
   double open=0;
   ArraySetAsSeries(Open,true);
   int copied=CopyOpen(Symbol(),0,0,Bars(Symbol(),0),Open);
   if(copied>0 && index<copied) open=Open[index];
   return(open);
  }
//+------------------------------------------------------------------+ 
//| Получим Low для заданного номера бара                            | 
//+------------------------------------------------------------------+ 
double Low(int index)
  {
   double low=0;
   ArraySetAsSeries(Low,true);
   int copied=CopyLow(Symbol(),0,0,Bars(Symbol(),0),Low);
   if(copied>0 && index<copied) low=Low[index];
   return(low);
  }
//+------------------------------------------------------------------+ 
//| Получим High для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double High(int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(Symbol(),0,0,Bars(Symbol(),0),High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }
//+------------------------------------------------------------------+ 
//| Получим Close для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Close(int index)
  {
   double close=0;
   ArraySetAsSeries(Close,true);
   int copied=CopyHigh(Symbol(),0,0,Bars(Symbol(),0),Close);
   if(copied>0 && index<copied) close=Close[index];
   return(close);
  }
Maybe I'm doing something wrong?
 
Aleksey Vyazmikin:

Not ready to show the code yet due to

But I am ready to show the profiling results from MT5 - as I understand trading functions are out of the question.

For OHLC environment I use the following functions

Maybe I am doing something wrong?
double iOpen(string symbol,ENUM_TIMEFRAMES tf,int index) {
  if(index < 0) return(-1);
   double Arr[];
   if(CopyOpen(symbol,tf, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
 }

double iClose(string symbol,ENUM_TIMEFRAMES tf,int index) {
  if(index < 0) return(-1);
   double Arr[];
   if(CopyClose(symbol,tf, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
 }

double iHigh(string symbol,ENUM_TIMEFRAMES tf,int index) {
  if(index < 0) return(-1);
   double Arr[];
   if(CopyHigh(symbol,tf, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
 }

double iLow(string symbol,ENUM_TIMEFRAMES tf,int index) {
  if(index < 0) return(-1);
   double Arr[];
   if(CopyLow(symbol,tf, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
 }
 

You copy all available bars from the story, but you really only need the oneindex you are looking for

CopyOpen(Symbol(),0,index,Bars(Symbol(),0)1,Open);
 
Vitaly Muzichenko:

You copy all available bars from the story, but you really only need the oneindex you are looking for

Changed it using your recipe and EA stopped opening orders... Maybe I messed up again?


//-------------------------------------------------------------------
//==MQL4toMQL5
//+------------------------------------------------------------------+ 
//| Получим Open для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Open(int index)
  {
   double open=0;
   ArraySetAsSeries(Open,true);
   int copied=CopyOpen(Symbol(),0,index,1,Open);
   if(copied>0 && index<copied) open=Open[index];
   return(open);
  }
//+------------------------------------------------------------------+ 
//| Получим Low для заданного номера бара                            | 
//+------------------------------------------------------------------+ 
double Low(int index)
  {
   double low=0;
   ArraySetAsSeries(Low,true);
   int copied=CopyLow(Symbol(),0,index,1,Low);
   if(copied>0 && index<copied) low=Low[index];
   return(low);
  }
//+------------------------------------------------------------------+ 
//| Получим High для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double High(int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(Symbol(),0,index,1,High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }
//+------------------------------------------------------------------+ 
//| Получим Close для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Close(int index)
  {
   double close=0;
   ArraySetAsSeries(Close,true);
   int copied=CopyHigh(Symbol(),0,index,1,Close);
   if(copied>0 && index<copied) close=Close[index];
   return(close);
  }


  
//+------------------------------------------------------------------+ 
//| Получим IOpen для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iOpen(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double open=0;
   ArraySetAsSeries(OpenI,true);
   int copied=CopyOpen(symbol,timeframe,index,1,OpenI);
   if(copied>0 && index<copied) open=OpenI[index];
   return(open);
  }
//+------------------------------------------------------------------+ 
//| Получим iLow для заданного номера бара                            | 
//+------------------------------------------------------------------+ 
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double low=0;
   ArraySetAsSeries(LowI,true);
   int copied=CopyLow(symbol,timeframe,index,1,LowI);
   if(copied>0 && index<copied) low=LowI[index];
   return(low);
  }
//+------------------------------------------------------------------+ 
//| Получим iHigh для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   ArraySetAsSeries(HighI,true);
   int copied=CopyHigh(symbol,timeframe,index,1,HighI);
   if(copied>0 && index<copied) high=HighI[index];
   return(high);
  }
//+------------------------------------------------------------------+ 
//| Получим iClose для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iClose(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double close=0;
   ArraySetAsSeries(CloseI,true);
   int copied=CopyHigh(symbol,timeframe,index,1,CloseI);
   if(copied>0 && index<copied) close=CloseI[index];
   return(close);
  }
 
Aleksey Vyazmikin:

Changed your recipe and the EA stopped opening orders... Maybe I messed up again?


double Close(int index)
  {
   double close=0;
   ArraySetAsSeries(Close,true);
   int copied=CopyHigh(Symbol(),0,index,1,Close);
   if(copied>0 && index<copied) close=Close[index];
   return(close);
  }

Close != High


PS. Please write here, it is not the topic

I ask the moderators to move the posts to the right topic, not to trash this one

Вопросы от начинающих MQL5 MT5 MetaTrader 5
Вопросы от начинающих MQL5 MT5 MetaTrader 5
  • 2012.03.12
  • www.mql5.com
Подскажите пожалуйста, такой показатель тестера в жизни реален? И хороший это или плохой результат за год с депо 3000...
 
Vitaly Muzichenko:

Close != High

PS. Post here, this is not the right topic.

I ask the moderators to move the posts to the right topic, not to litter this one

Thanks - corrected.

The code is as follows.

//-------------------------------------------------------------------
//==MQL4toMQL5
//+------------------------------------------------------------------+ 
//| Получим Open для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Open(int index)
  {
   double open=0;
   int copied=CopyOpen(Symbol(),0,index,1,Open);
   if(copied>0) open=Open[0];
   return(open);
  }
//+------------------------------------------------------------------+ 
//| Получим Low для заданного номера бара                            | 
//+------------------------------------------------------------------+ 
double Low(int index)
  {
   double low=0;
   int copied=CopyLow(Symbol(),0,index,1,Low);
   if(copied>0) low=Low[0];
   return(low);
  }
//+------------------------------------------------------------------+ 
//| Получим High для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double High(int index)
  {
   double high=0;
   int copied=CopyHigh(Symbol(),0,index,1,High);
   if(copied>0) high=High[0];
   return(high);
  }
//+------------------------------------------------------------------+ 
//| Получим Close для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double Close(int index)
  {
   double close=0;
   int copied=CopyClose(Symbol(),0,index,1,Close);
   if(copied>0) close=Close[0];
   return(close);
  }


  
//+------------------------------------------------------------------+ 
//| Получим IOpen для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iOpen(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double open=0;
   int copied=CopyOpen(symbol,timeframe,index,1,OpenI);
   if(copied>0) open=OpenI[0];
   return(open);
  }
//+------------------------------------------------------------------+ 
//| Получим iLow для заданного номера бара                            | 
//+------------------------------------------------------------------+ 
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double low=0;
   int copied=CopyLow(symbol,timeframe,index,1,LowI);
   if(copied>0) low=LowI[0];
   return(low);
  }
//+------------------------------------------------------------------+ 
//| Получим iHigh для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   int copied=CopyHigh(symbol,timeframe,index,1,HighI);
   if(copied>0) high=HighI[0];
   return(high);
  }
//+------------------------------------------------------------------+ 
//| Получим iClose для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iClose(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double close=0;
   int copied=CopyClose(symbol,timeframe,index,1,CloseI);
   if(copied>0) close=CloseI[0];
   return(close);
  }

Time in tester has grown - tired of waiting :)

 

I'm counting lots traded in the history for the current month.

   double lots=0;
   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
         if(TimeMonth(OrderCloseTime())==TimeMonth(TimeCurrent()))
            if(OrderType()<2)
               lots+=OrderLots();

It turns out that if I show orders for a specified period of time in the terminal history, for example, for the last three days, thenOrdersHistoryTotal() only sees the last three days.

I think that this is not correct.OrdersHistoryTotal() should see all orders for the entire history, but filtering by dates and periods should be performed by a developer.

Otherwise, incorrect hiding of the history by the user can lead to problems ....