Hello there,
I'm trying to save some values to file for analysis.
First, I get the open and close times for each week, and then I use them as the range to find the day of the week with the highest and lowest price.
That works fine but for a few iterations. For this sample, I was collecting 52 weeks' worth of data. I only get 26 weeks of data right and then after that I get the 1970.01.01 dates. What could be the issue?
Here is my simple code:
And this is the sample output:
it would of helped if you had showed your loop code....
also check you have the data downloaded in the terminal, easily done by opening the chart with the relevant timeframe(s)
datetime openTime = iTime(_Symbol,PERIOD_W1,i);
-
Why did you post your coding question in the MT5 General section (a miscellaneous catch-all category) instead of the MT5 EA section (non-indicator coding)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. I have moved this thread. - You don't verify that all W1 bars have been created before accessing the data.
On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019) - You don't show your loop. We can't read your mind nor see your machine; only what you give us on this forum.
How To Ask Questions The Smart Way. (2004)
When asking about code
Be precise and informative about your problem.
it would of helped if you had showed your loop code....
also check you have the data downloaded in the terminal, easily done by opening the chart with the relevant timeframe(s)
Thank you. I tried opening the terminal chart window.
Indeed, the data doesn't go further past May 2024 in all the timeframes I checked.
Monthly, weekly, and daily timeframes. I will switch my broker and see if the data changes.
-
Why did you post your coding question in the MT5 General section (a miscellaneous catch-all category) instead of the MT5 EA section (non-indicator coding)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. I have moved this thread. - You don't verify that all W1 bars have been created before accessing the data.
On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019) - You don't show your loop. We can't read your mind nor see your machine; only what you give us on this forum.
How To Ask Questions The Smart Way. (2004)
When asking about code
Be precise and informative about your problem.
WeeklyData weeks[]; ArraySetAsSeries(weeks, true); for(int i = 1; i < WeekCount + 1; i++) { WeeklyData thisWeek; datetime openTime = iTime(_Symbol,PERIOD_W1,i); datetime closeTime = openTime + PeriodSeconds(PERIOD_W1); int strt= iBarShift(_Symbol,PERIOD_D1,openTime,false); int end= iBarShift(_Symbol,PERIOD_D1,closeTime,false); string highestDay = DayOfWeek(iTime(_Symbol,PERIOD_D1,iHighest(_Symbol,PERIOD_D1,MODE_HIGH,strt-end+1,end))); string lowestDay = DayOfWeek(iTime(_Symbol,PERIOD_D1,iLowest(_Symbol,PERIOD_D1,MODE_LOW,strt-end+1,end))); //Fill our current week struct thisWeek.open_date = TimeToString(openTime, TIME_DATE); thisWeek.close_date = TimeToString(closeTime, TIME_DATE); thisWeek.high_of_week = highestDay; thisWeek.low_of_week = lowestDay; //Add the current week struct to array ArrayResize(weeks,(ArraySize(weeks)+1)); weeks[ArraySize(weeks)-1]=thisWeek; }Here is the full loop. And thanks for the pointers. I should make sure the bars are created, and the terminal is synchronized to the server for the other periods.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello there,
I'm trying to save some values to file for analysis.
First, I get the open and close times for each week, and then I use them as the range to find the day of the week with the highest and lowest price.
That works fine but for a few iterations. For this sample, I was collecting 52 weeks' worth of data. I only get 26 weeks of data right and then after that I get the 1970.01.01 dates. What could be the issue?
Here is my simple code:
And this is the sample output: