Description: I want to write inside csv file each days Symbol strengths each in separate row so it would be asc or desc by date time . Everything works fine but it just writes the first row with necessary data. I understand that there is problem with loop. I tried to put in different places the code that should write in csv file each cycle strengths, but without success. If you could just point me in right direction, It would be fantastic.
Also question: How can I insert that data inside multidimensional array ? Is there some way to do that. The code would be inside the place off that file writing in csv file, so at the end of each cycle Symbol strengths are added to array and moved on?
Thanks
Open the file, write everything you want to the file, then close the file . . .
Also . . . move your code from init() to start() . . .
You may find useful "StringArrayLoad" function here: https://www.mql5.com/en/code/8701
This reads csv file into an array.
You may find useful "StringArrayLoad" function here: https://www.mql5.com/en/code/8701
This reads csv file into an array.
Why would I find that useful ?
Edgar, for the second question. To read the data from csv into an array.
Edgar, for the second question. To read the data from csv into an array.
Ah, your comment was aimed at edgars, you didn't quote him at all so it looked like you were replying to me.
sorry for the misunderstanding
sorry for the misunderstanding

Description: I want to write inside csv file each days Symbol strengths each in separate row so it would be asc or desc by date time . Everything works fine but it just writes the first row with necessary data. I understand that there is problem with loop. I tried to put in different places the code that should write in csv file each cycle strengths, but without success. If you could just point me in right direction, It would be fantastic.
Here is a working version of the code you posted:
int init() { FWTest1(); return(0); } void FWTest1 () { double GBPUSD_array[][6], USDCHF_array[][6], EURGBP_array[][6], EURCHF_array[][6], EURUSD_array[][6]; int GBP_strenght = 0, USD_strenght = 0, EUR_strenght = 0; string filename = "pair_strenght.csv"; FileDelete(filename); GetLastError(); if (IsHistoryCurrent("GBPUSD", PERIOD_D1, false)) if (ArrayCopyRates(GBPUSD_array, "GBPUSD", PERIOD_D1) < 0) { Print ("Error occurred while copying rates for GBPUSD"); return; } if (IsHistoryCurrent("USDCHF", PERIOD_D1, false)) if (ArrayCopyRates(USDCHF_array, "USDCHF", PERIOD_D1) < 0) { Print ("Error occurred while copying rates for USDCHF"); return; } if (IsHistoryCurrent("EURUSD", PERIOD_D1, false)) if (ArrayCopyRates(EURUSD_array, "EURUSD", PERIOD_D1) < 0) { Print ("Error occurred while copying rates for EURUSD"); return; } if (IsHistoryCurrent("EURGBP", PERIOD_D1, false)) if (ArrayCopyRates(EURGBP_array, "EURGBP", PERIOD_D1) < 0) { Print ("Error occurred while copying rates for EURGBP"); return; } if (IsHistoryCurrent("EURCHF", PERIOD_D1, false)) if (ArrayCopyRates(EURCHF_array, "EURCHF", PERIOD_D1) < 0) { Print ("Error occurred while copying rates for EURCHF"); return; } for (int i = 0; i < 50; i++) { if (GBPUSD_array[i][0] == EURGBP_array[i][0] && EURGBP_array[i][0] == EURUSD_array[i][0]) { // if a = b and b = c, then a = c if (GBPUSD_array[i][1] > GBPUSD_array[i][4]) { GBP_strenght--; USD_strenght++; } if (GBPUSD_array[i][1] < GBPUSD_array[i][4]) { GBP_strenght++; USD_strenght--; } if (EURGBP_array[i][1] < EURGBP_array[i][4]) { EUR_strenght++; GBP_strenght--; } if (EURGBP_array[i][1] > EURGBP_array[i][4]) { EUR_strenght--; GBP_strenght++; } if (EURUSD_array[i][1] < EURUSD_array[i][4]) { EUR_strenght++; USD_strenght--; } if (EURUSD_array[i][1] > EURUSD_array[i][4]) { EUR_strenght--; USD_strenght++; } int handle=FileOpen(filename, FILE_CSV|FILE_WRITE|FILE_READ, ';'); if(handle > 0) { FileSeek(handle, 0, SEEK_END); FileWrite(handle, TimeToStr(EURGBP_array[i][0]), EUR_strenght, USD_strenght, GBP_strenght ); FileClose(handle); } else Print ("FileOpen failed. Error # ", GetLastError()); GBP_strenght=0; EUR_strenght=0; USD_strenght=0; } else Alert ("Datatime mismatch. STOPING"); } return; } bool IsHistoryCurrent(string curpair = "EURUSD", int tf = PERIOD_H1, bool verbose = true) { datetime latest_history_time = iTime(curpair, tf, 0); int error = GetLastError(); if (error > 0) { if (verbose) { if (error == 4066) Print (curpair, " history is updating . . . "); else Print ("An error occurred in IsHistoryCurrent(). Error # ", error); } return (false); } if (TimeCurrent() < latest_history_time + (tf * 60)) return (true); else return (false); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Description: I want to write inside csv file each days Symbol strengths each in separate row so it would be asc or desc by date time . Everything works fine but it just writes the first row with necessary data. I understand that there is problem with loop. I tried to put in different places the code that should write in csv file each cycle strengths, but without success. If you could just point me in right direction, It would be fantastic.
Also question: How can I insert that data inside multidimensional array ? Is there some way to do that. The code would be inside the place off that file writing in csv file, so at the end of each cycle Symbol strengths are added to array and moved on?
Thanks