- Please use the SRC-button if you post code (more than one line)
- Have you checked the error messages?
- What did you get and what did you expect: PREV_YEAR_OPEN_DATE ?
- Maybe you shouldn't use: "2017.01.001 0:00" but try:
Hello,
I do not get any error.
But i need it to be like the previous month (for example).
datetime PREV_MONTH_OPEN_DATE=iTime(Symbol(),PERIOD_MN1,1);
I find how to get the high and low price of the previous year
PREV_YEAR_HIGH = iHigh(NULL, PERIOD_MN1, iHighest(NULL, PERIOD_MN1, MODE_HIGH, 12, Month()));
And i need the open time now.
Thank you very much.
PREV_YEAR_HIGH = iHigh(NULL, PERIOD_MN1, iHighest(NULL, PERIOD_MN1, MODE_HIGH, 12, Month()));And i need the open time now.
- You already know how. You posted the code. Since MT doesn't have yearly charts you have to find the MN1 indexes yourself.
#define INDEX uint #define PRICE double datetime startOfMonth = iTime(Symbol(),PERIOD_MN1,0); INDEX iMnLastYearLast = TimeMonth(startOfMonth); // MN1 last bar of last year. INDEX iMnHighestMonth = iHighest(NULL, PERIOD_MN1, MODE_HIGH, 12, iMnLastYearLast); PRICE HHlastYeat = iHigh(NULL, PERIOD_MN1, iMnHighestMonth)
-
On MT4: Unless the current chart is the specific pair/TF referenced, you must handle
4066/4073 errors.
Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum - "Open time" of what "now?" The year? iMNCurrYearFirst = iMNLastYearLast + 1
- You already know how. You posted the code. Since MT doesn't have yearly charts you have to find the MN1 indexes yourself.
-
On MT4: Unless the current chart is the specific pair/TF referenced, you must handle
4066/4073 errors.
Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum - "Open time" of what "now?" The year? iMNCurrYearFirst = iMNLastYearLast + 1
Thank you for your response.
Yes i need the open time of the previous year.
I tried so many way, but i failed.
If you can give me the answer, it would be very nice for me...
Regards.
Thank you for your response.
Yes i need the open time of the previous year.
I tried so many way, but i failed.
If you can give me the answer, it would be very nice for me...
Regards.
MqlDateTime time; TimeCurrent(time); time.year--; time.mon=1; time.day=1; time.min=0; time.sec=0; time.hour=0; Print("Last year's start time = ",StructToTime(time));
Nothing work to me...as my coding skills are limited.
I will put the date manually.
Anyway, thank to all 3 of you very much for your time.
Regards.
If iMnLastYearLast is December of last year, isn't January iMnLastYearLast+11? When in doubt, think.
As I continue to learn, i finally got it from your code.
Thank you very much.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I tried and tried to get the open date of the previous year.
Can you help me please ?
Now, i do it like this but, it's not "pro"
Regards.