VPS deleting my EA after some minutes

 

Hello, 

I'm facing an issue with my EA. It's working for months, but since today the VPS Brazil Metaquotes server is deleting and showing this message:


Array 


The following is my code:


void OnTick()
  {
  

   int ATR_V_=iATR(Symbol(),ATR_TIMEFRAME,period_var);
   atr_v_=ATR(ATR_V_,shift_);


   }



//+------------------------------------------------------------------+
double ATR(int handle,int shift)
  {
   double _atr[];
   CopyBuffer(handle,0,shift,1,_atr);
   return _atr[0];
  }
//+------------------------------------------------------------------+
 
Guilherme Mendonca :

Hello, 

I'm facing an issue with my EA. It's working for months, but since today the VPS Brazil Metaquotes server is deleting and showing this message:


 


The following is my code:




Perhaps there is a problem on the server - but you yourself are grossly breaking the rules: THE INDICATOR HANDLE in MQL5 MUST BE CREATED ONCE! THIS SHOULD BE DONE IN OnInit ()!

 
Vladimir Karputov:

Perhaps there is a problem on the server - but you yourself are grossly breaking the rules: THE INDICATOR HANDLE in MQL5 MUST BE CREATED ONCE! THIS SHOULD BE DONE IN OnInit ()!

Usually I use in OnInit().

But, this particular indicator should have a variable PERIOD according of other rules.

Is it possible to make it in diferent way instead of created in OnTick() ?

 
Guilherme Mendonca :

Usually I use in OnInit().

But, this particular indicator should have a variable PERIOD according of other rules.

Is it possible to make it in diferent way instead of created in OnTick() ?

You just create all the handles in OnInit () in advance and put them into an array.

Example: 

Example MultiTimeFrame iRSI get value

How to start with MQL5
How to start with MQL5
  • 2020.07.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 
Vladimir Karputov:

You just create all the handles in OnInit () in advance and put them into an array.

Example: 

Example MultiTimeFrame iRSI get value

Ok. I will read about it.

Thank you!

 
Vladimir Karputov:

You just create all the handles in OnInit () in advance and put them into an array.

Example: 

Example MultiTimeFrame iRSI get value


Ok. I fixed it, but still deleting my EA with the same error: “array out of range”.

 
Guilherme Mendonca :

Ok. I fixed it, but still deleting my EA with the same error: “array out of range”.

You did not show your code - You did not show your code and the lines in which the error occurs.

 
Vladimir Karputov:

You did not show your code - You did not show your code and the lines in which the error occurs.

It does't make sense. This code is working for months.

But the following is the part that having some problem.

I insert a comment in the line with problem in VPS.


int ATR_SL,ATR_V_;
double atr_sl;
double atr_v_;

int shift_=0;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   Trade.SetTypeFilling(OrderFillingType);
   
   
   ATR_SL=iATR(Symbol(),PERIOD_D1,SL_TimeFrame_Period);
   
   
   ATR_V_=iATR(Symbol(),ATR_TIMEFRAME,21);


  }
void OnTick()
  {
  

   atr_v_=ATR(ATR_V_,shift_);      

   atr_sl = ATR(ATR_SL,0);

  }
//+------------------------------------------------------------------+
double ATR(int handle,int shift)
  {
   double _atr[];
   CopyBuffer(handle,0,shift,1,_atr);   //Line with problem in VPS
   return _atr[0];
  }
//+------------------------------------------------------------------+
 
Guilherme Mendonca :

It does't make sense. This code is working for months.

But the following is the part that having some problem.

I insert a comment in the line with problem in VPS.



Please show me the minimal code - code that I can compile and test.

 
Vladimir Karputov:

Please show me the minimal code - code that I can compile and test.


It's clearly a VPS issue, because I updated my MT5 (2571), compiled again with the new version and it's working at my PC.

But when I send to VPS (BRAZIL), it stop work after some minutes.

I can allow you access my PC using TeamViewer.

 
They've updated MT5 MQL5 VP servers to version 2752, so it must have been resolved.
Reason: