ArrayCopyRates ,arrays in the includes, and History center

 
Currently I use FileWriteArray to move between the MQH files and MQ4's. I am not aware of any other methods to adjust an array in one location Change it and send it back.

My Current issue is two Fold. I want to use file Write Array to a USB drive to take the Data some place else.

Next. How can I limit the number of bars  ArrayCopyRates. It does not seem possible. In Metrader Four..... Some times I want the DLL to take the whole array and Some time I wanr it to do less than 1000 bars. So far my only solution is to take one Instance of Metatrader with LOTS of data. and move the FileWriteArray to that location with the ,limited data. This is a pain. Any Ideas? " Note I have the data in SQL. server ... the I net this week showed me why that is a bad Idea 

 Summary 

File adjustments between Includes , Not possible MT4

so FileWriteArray  to a location like a USB drive .. 

Last Limit ArrayCopyRates, I have tried to copy that array and send to to the DLL. I can not figure out why it does not work except that ArrayCopyRates is not a real array. 

 

Oh any one know oh any way to AUTO call history center. I guess I have four questions 
 
  1. An included file is the same as if you put the source into the mq4 file at that point. It is all one compilation. No need to send it back.
    include.mqh
    double arr[];
    void function(){ arr[1] = 1; ... }
    include.mqh
    #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
    double arr[][ACR_COUNT];
    void function(){ arr[1][ACR_VOLUME] = 1; ... }
    Mainfile
    #include "include.mqh"
    int start(){
      ArrayResize(arr, Bars);
      function(); // Send it back.
      :
    Mainfile
    #include "include.mqh"
    int start(){
      ArrayResize(arr, Bars);
      function(); // Send it back.
      :

  2. How can I limit the number of bars  ArrayCopyRates. It does not seem possible.
    It's not. You get all Bars from the chart. Just process what you want. No need to limit it.
  3. I have tried to copy that array and send to to the DLL. I can not figure out why it does not work except that ArrayCopyRates is not a real array.
    No mind reader here - you need to post your code. ACR is a real array, as it is redirected to the chart's internal arrays.
 
WHRoeder:
  1. An included file is the same as if you put the source into the mq4 file at that point. It is all one compilation. No need to send it back.
    include.mqh
    include.mqh
    Mainfile
    Mainfile

  2. How can I limit the number of bars  ArrayCopyRates. It does not seem possible.
    It's not. You get all Bars from the chart. Just process what you want. No need to limit it.
  3. I have tried to copy that array and send to to the DLL. I can not figure out why it does not work except that ArrayCopyRates is not a real array.
    No mind reader here - you need to post your code. ACR is a real array, as it is redirected to the chart's internal arrays.


 

Sweet!!

Just so I am clear. The Double Array[][]; Done in mainfile  . is not in scope for The  include.mqh but if I follow your example  Double Array [][]; is in scope in main file if defined in includes.

I use the  include for multiple eas. Doing it this way will block out memory for eas I am not using . I guess I can set the array size when I need them and then That would not be a issue. It Can also get tricky if one EA wants to change the array in a different way. This was one of the reasons for the mainFile Double Array [][]; Currently I use This basic structure . I hope this is not too long.


// --- Define Vars main File above int 

int TimeFrames[];

string Syms[];

 

 

// --- Int EA take user input off Input. DLL Or eternal Program 

// --- load input file or Call input DLL and quiz user for inputs

 

init

(

  // --- Total Time Frames are Changes includes according to user inputs in a Function not displayed in this example 

  // --- Total Syms are Changes includes according to user inputs in a Function not displayed in this example 

  // --- Ea String is name of EA or Function Calling includes

  // --- szSymbol = Symbol sent in

  // --- iTypeTrade -- example pattern

  // ---  TimeFrames is the array

  // ---   dInfo1 --- information InitializeTFArray may need

  // ---   dInfo2 --- Information InitializeTFArray may need

  // ---  HardLocation no line number in Metatrader 4 ... This is for debugging and is the location I came from. a string Marker

  // ---- Example we are in " section 1 process 3" 

 

 totaltimeframes = InitializeTFArray( szEAString, szSymbol ,  iTypeTrade, TimeFrames, dInfo1 ,  dInfo2,  HardLocation );

 

   // --- Bring back adjustment to an Array for this EA.

   int handle;

   handle=FileOpen("TimeFramesArray.dat", FILE_BIN|FILE_READ);

      if(handle>0)

   {

   FileReadArray(handle, TimeFrames, 0, WHOLE_ARRAY);

   FileClose(handle);

   }

   // ----  Syms is the array

   // ---  szSymbol is the symbol on the Last scan

   totalsym= InitializeArray( szEAString, szSymbol ,  iTypeTrade,iTimeFrame , Syms ,  dInfo2,  HardLocation );

   // --- Data from the inculdes to here

   handle=FileOpen("SymbolArray.dat", FILE_BIN|FILE_READ);

      if(handle>0)

   {

   FileReadArray(handle, Syms, 0, WHOLE_ARRAY);

   FileClose(handle);

   } 

 

// ---  totaltimeframes and 

int start( 

  for ( int j = 0; j < totaltimeframes; j++ )

   { 

            for ( int g = 0; g < Syms; g++ )

      {  

// --- Do Some thing

}

   } 

 

 

2. The DLL I am using is kind of complex. It has two main Goals One is define Support and resistance

     and the next is to display a Dispersion Zone off that Data. Some time I want the DLL to process more or to process less.

      

 PivotArray[iMaximumRecords][13]  and DispersionZoneArray1[iMaximumRecords][13]

 


3. This s what I have tried.

        What I meant by  "ACR is not a real array". Is only that it is not treated the same you can not use. ArrayResize(Rates,1000);

  The Goal of the code below. is to  control The size of ArrayCopyRates that that DLL process. With out chang the DLL. It is hardened code and changing hardened code does not seem like the 1st choice 

int iMaximumRecords = ArrayCopyRates(TempRates, szSymbol, iTimeFrame);  

ArrayCopy( Rates,TempRates,0,0,Whole_Array);

      ArrayResize(Rates,1000);

        iMaximumRecords=1000;

//--- Set size of Arrays come back from DLL

//--- to match Rates 

  ArrayResize(Array1,1000);

ArrayResize(array2); 

MyDlL(Ratesl, Array1, array2);

//------Receive  Array1 and array2  

 

When I send RATES to the DLL it goes insane. Sending back trash. When I print array to file and look at it it is perfect. 

 
JeffCrystal: When I send RATES to the DLL it goes insane. Sending back trash. When I print array to file and look at it it is perfect.

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You do realize that the ACR array is backwards in the DLL?
    //////// in mq4
    double acr[][]; // series array in mq4
    double acr12 = getAcrDLL(acr, Bars, 1, 2);
    //////// in DLL
    double getAcrDLL(arr[][], int nBars, int iBar, int eACR){ // no such thing as
      return( arr[nBars - ibar][eACR] );          // series array in DLL
    }

  3. int iMaximumRecords = ArrayCopyRates(TempRates, szSymbol, iTimeFrame);  
    
    ArrayCopy( Rates,TempRates,0,0,Whole_Array);
    
    ArrayResize(Rates,1000);
    You can't copy tempRates to Rates unless you give it a size first. It will not resize Rates, and do the copy. I have no idea whether ArrayCopy will handle the series to non-series (Use a loop instead.) Copying is unnecessary, just pass the array.
  4. Did you read the warning in my code around ArrayCopyRates?
       //{https://forum.mql4.com/36470/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.
    
    It's only necessary to call ACR once, but in start() you must verify its size ArrayRange(buffer,0) != 0 in case it's downloading history from the server.
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You do realize that the ACR array is backwards in the DLL?
  3. You can't copy tempRates to Rates unless you give it a size first. It will not resize Rates, and do the copy. I have no idea whether ArrayCopy will handle the series to non-series (Use a loop instead.) Copying is unnecessary, just pass the array.
  4. Did you read the warning in my code around ArrayCopyRates?It's only necessary to call ACR once, but in start() you must verify its size ArrayRange(buffer,0) != 0 in case it's downloading history from the server.

-----------------------------------------------------------------------------------------

2.You do realize that the ACR array is backwards in the DLL? Yes. The DLL. I co designed and hired out parts of the programming.  Yes I do understand that. 

 --------------------------------------------------------------------------------------------------------------

3.  (Use a loop instead.) I am doing currently 

--------------------------------------------------------------------------------

4. No I did not see that but I am exited about that. I still wish I could control the Size. really big sizes take 3 too 5 seconds in the DLL.  

 
JeffCrystal: really big sizes take 3 too 5 seconds in the DLL.  
No it doesn't - the array is passed by reference - ZERO TIME. Fix your DLL to process only what it needs, not the entire array.
Reason: