what is the difference between "ArrayGetAsSeries(arrayX)" and "ArrayIsSeries(arrayX)"?

 

1. I get the arrayX by the function--ArrayCopyRates();

   and then execute functions of  "ArrayGetAsSeries(arrayX)" and "ArrayIsSeries(arrayX)" as order.

   but the return of the former is 1 and that of latter is 0. why?

2.  how can get the maximum or minimum open price for the arrayX?

3. how can i know what's the last one of arrayX[][6]? such as arrayX[100] or others and why? 

 

Thank you! 

 
vx0532:

1. I get the arrayX by the function--ArrayCopyRates();

   and then execute functions of  "ArrayGetAsSeries(arrayX)" and "ArrayIsSeries(arrayX)" as order.

   but the return of the former is 1 and that of latter is 0. why?

2.  how can get the maximum or minimum open price for the arrayX?

3. how can i know what's the last one of arrayX[][6]? such as arrayX[100] or others and why? 

1.  I think the distinction is between a timeseries type array and a series organised array.

2.   have you tried ArrayMaximum() and ArrayMinimum() ?

3.  for a 1 ddimensional array you can ue  arrayX[ArraySize(arrayX) - 1] 

 
vx0532:

1. I get the arrayX by the function--ArrayCopyRates();

   and then execute functions of  "ArrayGetAsSeries(arrayX)" and "ArrayIsSeries(arrayX)" as order.

   but the return of the former is 1 and that of latter is 0. why?

2.  how can get the maximum or minimum open price for the arrayX?

3. how can i know what's the last one of arrayX[][6]? such as arrayX[100] or others and why?

  1. GetAsSeries returns true because it is a 2D series array. RTFM: (ArrayIsSeries) Returns TRUE if the array under check is a series array (Time[],Open[],Close[],High[],Low[], or Volume[]), otherwise returns FALSE. is your 2D array one of those?
  2. It is a 2D array. No built in functions for 2D arrays. You must code one. (from my code)
    //+------------------------------------------------------------------+
    //| Find local extrema                                               |
    //+------------------------------------------------------------------+
    #define EXAR_LE         1  // true  // Local extream
    #define EXAR_RNG        0  // false // fixed range
    #define EXAR_LARGEST    +1 // Direction
    #define EXAR_SMALLEST   -1 // Defaults to DIR
    double   ExtreamArray2D(double arr[][], int eSel, int length=WHOLE_ARRAY,
                         int iBeg=0, bool wantLE=EXAR_RNG, double d=EMPTY_VALUE){
       return( arr[iExtreamArray2D(arr, eSel, length, iBeg, wantLE, d)][eSel] );  }
    int      iExtreamArray2D(double arr[][], int eSel, int length=WHOLE_ARRAY,
                            int iBeg=0, bool wantLE=EXAR_RNG, double d=EMPTY_VALUE){
    //double DIR                                 // Import from SetDIR
       #define INF 0x6FFFFFFF // Not quite infinite, Jul 2029, or 1,879,048,191
       if(length == WHOLE_ARRAY)  length = INF;
       if(d == EMPTY_VALUE) d = DIR;
       double   extreama = -d * INF;
       if(length > 0){   // Search iBeg, iBeg+1, ... iBeg+n-1
          int   nBars = ArrayRange(arr,0), iLimit = MathMinI(nBars, iBeg + length);
          for(; iBeg < iLimit; iBeg++){
             double   value = arr[iBeg][eSel];
             if((extreama - value)*d < 0.){
                extreama = value; int   iExtreama   = iBeg;
                if(wantLE)              iLimit      = MathMinI(nBars,iBeg + length);
       }  }  }
       else{             // Search iBeg, iBeg-1, ... 0
                                        iLimit      = MathMaxI( -1, iBeg + length);
          for(; iBeg > iLimit; iBeg--){
             value = arr[iBeg][eSel];
             if((extreama - value)*d < 0.){
                extreama = value;       iExtreama   = iBeg;
                if(wantLE)              iLimit      = MathMaxI( -1, iBeg + length);
       }  }  }
       return(iExtreama);
    }  // iExtreamArray2D
    
    #define ACR_TIME     0  // Array Copy Rates
    #define ACR_OPEN     1
    #define ACR_LOW      2
    #define ACR_HIGH     3
    #define ACR_CLOSE    4
    #define ACR_VOLUME   5
       #define ACR_COUNT    6
    #define iCB 0  // Current Bar
    #define iPB 1  // Previous Bar
    datetime GetTime( int iBar=iCB){          return( GetMkt(ACR_TIME,   iBar) ); }
    //double GetOpen( int iBar=iCB){          return( GetMkt(ACR_OPEN,   iBar) ); }
    //double GetHigh( int iBar=iCB){          return( GetMkt(ACR_HIGH,   iBar) ); }
    //double GetLow(  int iBar=iCB){          return( GetMkt(ACR_LOW,    iBar) ); }
    double   GetClose(int iBar=iCB){          return( GetMkt(ACR_CLOSE,  iBar) ); }
    //double GetVolume(int iBar=iCB){         return( GetMkt(ACR_VOLUME, iBar) ); }
    double   acr.arr[][ACR_COUNT];
    int      GetBars(){                       return( ArrayRange(acr.arr, 0)   ); }
    double   GetMkt(int eACR, int iBar=iCB){  return( acr.arr[iBar][eACR]      ); }
    int      GetMaximalBar(int eSel, int length=WHOLE_ARRAY, int iBeg=iCB,
                            bool wantLE=EXAR_RNG, double d=EMPTY_VALUE){
       return( iExtreamArray2D(acr.arr, eSel, length, iBeg, wantLE, d)         ); }
    :
    int init(){
       //{https://www.mql5.com/en/forum/129734/page2 says ArrayCopyRates is a nonreentrant,
       // non-thread-safe call. Therefor you must put a mutex around the call in
       // case of multiple EAs on multiple charts. Alteratively, since init() is
       // single threaded across all charts, put all ACRs there.
       //}
       ArrayCopyRates(acr.arr, market.pair, period.market);     // I'm in an OnInit.
    }
    int start(){
       int iMaxOpen = GetMaximalBar(ACR_OPEN, WHOLE_ARRAY, iCB, EXAR_RNG, EXAR_LARGEST)
       Print("Max open price @ ",iMaxOpen," is ", PriceToStr( GetMkt(ACR_OPEN, iMaxOpen) );

  3. int      GetBars(){                       return( ArrayRange(acr.arr, 0)   ); }

 
RaptorUK:

1.  I think the distinction is between a timeseries type array and a series organised array.

2.   have you tried ArrayMaximum() and ArrayMinimum() ?

3.  for a 1 ddimensional array you can ue  arrayX[ArraySize(arrayX) - 1] 


Thank you for your reply.

1.  what does "series organised array" means? because I get the arrayX by ArrayCopyRates() function, and arrayX should be organised by "time", why the return of ArrayIsSeries is 0 rather than 1.

2. ArrayMaximun() and ArrayMinimun() never work here, and  I think they can work for 1D array.

3. ArraySize(arrayX); works well here and it can return the count of all element in the arrayX;and we can get the count of bars by "ArraySize(arrayX)/6;".

 

WHRoeder:

 


  1. GetAsSeries returns true because it is a 2D series array. RTFM: (ArrayIsSeries) Returns TRUE if the array under check is a series array (Time[],Open[],Close[],High[],Low[], or Volume[]), otherwise returns FALSE. is your 2D array one of those?
  2. It is a 2D array. No built in functions for 2D arrays. You must code one. (from my code)




Thank you for your reply.

1. yes, arrayX is one of "those". arrayX is initialized by function "ArrayCopeRates(arrayX,"EURUSD",PERIOD_M1)" , so I think arrayX must be a series array--by time series, yes?

 2. Thank you for your detail codes; I need more time to understand, test and use them. you are so nice kindly.

3.  It is perfect. when I executed ArrayRrange(arrageX,0); I can get how many bars's data have been saved in arrayX by ArrayCopyRates(); and I find it is 2165. then another question: why is 2165 or how can I modify it, i mean shall i save 2166 bars's data in arrayX by ArrayCopyRates()? Thank you very much.

 

vx0532:

1. yes, arrayX is one of "those". arrayX is initialized by function "ArrayCopeRates(arrayX,"EURUSD",PERIOD_M1)" , so I think arrayX must be a series array--by time series, yes?

3.  It is perfect. when I executed ArrayRrange(arrageX,0); I can get how many bars's data have been saved in arrayX by ArrayCopyRates(); and I find it is 2165. then another question: why is 2165 or how can I modify it, i mean shall i save 2166 bars's data in arrayX by ArrayCopyRates()? Thank you very much.

  1. No it is not. It is not Time[], it is not open[] it is not close[] it is not high[] it is not low[] it is NOT one of "those" so ArrayIsSeries returns false. It is a series array (organized by decreasing index, increasing time) so GetAsSeries is true.
  2. .
  3. 2165 is the amount of history you have. As long as the chart is open and the EA is running every new bar will increase the number.
 
WHRoeder:
  1. No it is not. It is not Time[], it is not open[] it is not close[] it is not high[] it is not low[] it is NOT one of "those" so ArrayIsSeries returns false. It is a series array (organized by decreasing index, increasing time) so GetAsSeries is true.
  2. .
  3. 2165 is the amount of history you have. As long as the chart is open and the EA is running every new bar will increase the number.

Thanks for all your kindly reply.

1. I am not sure that I have understood your meaning or not  now, but I guess your meaning is that arrayX is never one of "those" because arrayX is 1D array at first and if it is one of "those", it should be 1D array at first, such as open[],time[],close[] and so on then it it is a series array. yes? if not, shall I know how can I modify arrayX as the array which can make ArrayIsSeries[arrayX] return 1.

2. It is a little difficult to get the maximum Open price or Close price i find and it seems that there is something wrong,such as "DIR","market.pair","period.market" and so on never are defined. 

but we can get the maximum price's or minimum price's bar in a series bars by iHighest() or iLowest() function, yes?

3. It is; thank you very much. 

Reason: