Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
Thank you.
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum double copyLowArray(string symbol,ENUM_TIMEFRAMES timeframe,int index){ double LowValues[]; : int copied=CopyLow(symbol,timeframe,startDate,endDate,lowV); : return(LowValues);
Only post code that compiles. How can you return an array? What is startDate, endDate, lowV? Etc.- If you're going to write OOP, then write it, don't mix your struct and procedural code.
struct symbol_data { string symbol; int barsNo; double LowValues[]; void fill(ENUM_TIMEFRAMES timeframe){ barsNo = CopyLow(symbol,timeframe,0, Bars(symbol,timeframe), LowValues); } } symbol_data symbolsArr[]; ... for(int i=0; i<ArraySize(symbolsArr); i++) symbolsArr[i].fill(InpLoadedPeriod);
-
On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
whroeder1:
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum - Only post code that compiles. How can you return an array? What is startDate, endDate, lowV? Etc.
- If you're going to write OOP, then write it, don't mix your struct and procedural code.
-
On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Sorry... new to the forum as well.
I did not mix all, just didn't write all the procedures. Here is the whole code. wrote the errors I got inline:
input ENUM_TIMEFRAMES InpLoadedPeriod=PERIOD_H1; // Period to be loaded datetime startDate, endDate; string symbols[] = {"GBPUSD", "EURUSD", "USDJPY", "USDCHF", "NZDUSD", "USDCAD", "AUDUSD"}; struct symbol_data { string symbol; int barsNo; long VolumeValues[]; double LowValues[]; double CloseValues[]; double HighValues[]; double OpenValues[]; datetime DateValues[]; }; symbol_data symbolsArr[]; //array of symbols with data for bars //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { endDate = TimeCurrent(); startDate=endDate-(1000*InpLoadedPeriod*60); // Start date- 1000 bars before current date //---Init symbolsArr for(int i=0; i<ArraySize(symbols); i++) { //ArraySetAsSeries(symbolsArr[i].LowValues,true); int bars=Bars(symbols[i],InpLoadedPeriod, startDate, endDate); symbolsArr[i].symbol = symbols[i]; symbolsArr[i].barsNo = bars; ArrayCopy(symbolsArr[i].LowValues, copyLowArray(symbols[i],InpLoadedPeriod,bars) ,0,0,WHOLE_ARRAY); //try 2 - got error: copyLowArray variable expected symbolsArr[i].LowValues= copyLowArray(symbols[i],InpLoadedPeriod,bars); //this was try 1 - got error: LowValues- invalid array access } //--- return(INIT_SUCCEEDED); } double copyLowArray(string symbol,ENUM_TIMEFRAMES timeframe,int index) { double LowValues[]; ArraySetAsSeries(LowValues,true); printf("---Run CopyLow for " + symbol); int copied=CopyLow(symbol,timeframe,startDate,endDate,lowV); if(copied>0 && index<=copied) printf("---Copied Low=%d", copied); //else return 0; return(LowValues); }
The way I overcame it was to define a global array, fill it in the function and then copy it to relevant place... But it doesn't sound logic to do so for every param in the structure (there will be more)... does it?
Thanks!
Sergey Golubev:
Sorry... new to the forum as well.
done

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
Here is the whole code. wrote the errors I got inline:I'm trying to fill a struct that has a double array.
I'm trying to copy this array from a function returning it.
It is just a start, so code is very clean (no error handling, etc. yet).
I keep getting an error of 'copyLowArray Variable Expected':
The way I overcame it was to define a global array, fill it in the function and then copy it to relevant place... But it doesn't sound logic to do so for every param in the structure (there will be more)... does it?
Thanks!