Important Update for MetaTrader 4 build 1080 - page 3

 
fxsaber:
#property strict
Thank you for the hint, but it seems there are more problems with inherited classes.
 
fxsaber:
Write the body of the function you want.

Ok, so this is useless. In fact, it gave no more compilation errors, but the code is not working indeed.

The problem is that code that was running fine prior to the update, now is not working anymore. How am i supposed to rewrite a native function like ArrayCopy, that always worked and has always been used.


I'll open a ticket and pray...

 
Savoiardo:

Ok, so this is useless. In fact, it gave no more compilation errors, but the code is not working indeed.

The problem is that code that was running fine prior to the update, now is not working anymore. How am i supposed to rewrite a native function like ArrayCopy, that always worked and has always been used.


I'll open a ticket and pray...

Ask someone.
 
Savoiardo: . How am i supposed to rewrite a native function like ArrayCopy, t
No need. For structs (with internal objects) and classes to be used in an array,  write a default constructor and a assignment operator and your done.
struct S{ 
   string s;
   void S(void) : s(""){}
   void operator=(const& that){ this.s = that.s; }
};
 
whroeder1:
No need. For structs (with internal objects) and classes to be used in an array,  write a default constructor and a assignment operator and your done.
Does not work
class CLASS
{
public:
  CLASS( void ) {}  
  void operator =( const CLASS* ) {}
};

void OnStart()
{
  CLASS* Array1[];
  CLASS* Array2[];
  
  ArrayCopy(Array1, Array2);    
}
 
fxsaber:
Does not work
I always passed an array of objects from a class to ArrayCopy, and it has always worked, without creating constructor and operators. I sent a ticket to support, I'll let you know if this is just a new version bug or whatever.
 

What happened with Slippage?

Until now working on 20 pips, and currently only 2 pips are allowed...

0    17:34:07.722    Safe Orders Management EURUSD,M1: Partial Close order  Sell  - 705000693. Awaiting response...
3    17:34:07.722    Safe Orders Management EURUSD,M1: invalid slippage for OrderClose function
0    17:34:07.722    Safe Orders Management EURUSD,M1: Alert: Error occurred: invalid function parameter value

The maximum value in the МТ4 is 5 pips.

Max Deviation

 
fxsaber: Does not work
class CLASS{
public:
  CLASS( void ) {}  
  void operator =( const CLASS* ) {}
};
void OnStart(){
  CLASS* Array1[];
  CLASS* Array2[];
  ArrayCopy(Array1, Array2);    
}

  1. That's not a assignment operator. Requires a const reference to the class.
  2. What doesn't work? You have zero length arrays of pointers. Constructor/assignment is irrelevant.
 
whroeder1:

  1. That's not a assignment operator. Requires a const reference to the class.
  2. What doesn't work? You have zero length arrays of pointers. Constructor/assignment is irrelevant.
class MyClass
  {
public:
                     MyClass(){};
   void operator=(const MyClass*) {}                             //<---------------- Added this
                     MyClass(const MyClass&);
                     MyClass(..., ..., ..., ..., ..., ..., ...);
                    ~MyClass(void){};

}


But it doesn't change anything. There is a problem with the ArrayCopy function parameters. Try doing this:

   MyClass *testArr1[];
   MyClass *testArr2[];
   ArrayCopy(testArr1,testArr2);

wherever you want, with any class you want, and you'll get the same result:

'testArr2' - structures containing objects are not allowed    xxxxxxxxx.mq4    92    23

And this didn't happen before the 1080 update

 

Well in case anybody need it, i modified the function to avoid the use of ArrayCopy, and made it generic.

So this can be used to remove an element from an array of objects / array of pointers at a specified index.

template<typename T>
void DeleteElementInArray(T *&Arr[],int index)
  {
   T *TempArray[];
   delete Arr[index];
   int size=ArraySize(Arr);
   if(size==0)
     {
      ArrayFree(Arr);
      ArrayResize(Arr,0);
     }
   else if(index==0)
     {
      ArrayResize(TempArray,size-1);
      for(int i=1;i<size;i++)
        {
         TempArray[i-1]=Arr[i];
        }
      ArrayFree(Arr);
      for(int i=0;i<size-1;i++)
        {
         Arr[i]=TempArray[i];
        }
     }
   else
     {
      ArrayResize(TempArray,size-1);
      for(int i=0;i<index;i++)
        {
         TempArray[i]=Arr[i];
        }
      for(int i=index+1;i<size;i++)
        {
         TempArray[i-1]=Arr[i];
        }
      ArrayFree(Arr);
      for(int i=0;i<size-1;i++)
        {
         Arr[i]=TempArray[i];
        }
     }
  }

Take care.

Reason: