- Share Data between Terminals
- Open extern files with metatrader
- Inconsistent data downloading when using MQL
- 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. :
- 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.
- 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.
- 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.mqhinclude.mqhMainfileMainfile
- 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.
- 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.
Play videoPlease edit your post.
For large amounts of code, attach it.
- 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 }
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.- 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.
Play videoPlease edit your post.
For large amounts of code, attach it.
- You do realize that the ACR array is backwards in the DLL?
- 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.
- 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.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use