answered in this thread before to get the daily highs and lows of a specific day:
Why do you want to zone in on a specific day? what's the problem with returning the daily highs and lows for X number of previous days?
there's also a nice indicator recently published in the codebase
You can see the date and time under the chart of course
metinique:
Hi , i am new to coding with mql5 and i struggle to find a way of returning the monday high and low . I don't even know where to start from to be honest.
Thank you!
dayofweek for Monday is 1:
Documentation on MQL5: Date and Time / TimeToStruct
- www.mql5.com
Converts a value of datetime type (number of seconds since 01.01.1970) into a structure variable MqlDateTime . Parameters dt [in] Date value...
metinique:
Hi , i am new to coding with mql5 and i struggle to find a way of returning the monday high and low . I don't even know where to start from to be honest.
Thank you!
//+------------------------------------------------------------------+ //| Day of the week as integer (0-Sunday, 1-Monday, ... ,6-Saturday) | //+------------------------------------------------------------------+ int TimeDayOfWeek(const datetime t) { MqlDateTime st; TimeToStruct(t,st); return(st.day_of_week); } void OnStart() { datetime now = TimeTradeServer(); int shift = TimeDayOfWeek(now) - MONDAY; if (shift < 0) shift += 7; datetime time = iTime(Symbol(),PERIOD_D1,shift); double open = iOpen(Symbol(),PERIOD_D1,shift); double high = iHigh(Symbol(),PERIOD_D1,shift); double low = iLow(Symbol(),PERIOD_D1,shift); double close = iClose(Symbol(),PERIOD_D1,shift); long volume= iVolume(Symbol(),PERIOD_D1,shift); Comment(Symbol(),", Monday\n", "Time: " ,TimeToString(time,TIME_DATE),"\n", "Open: " ,DoubleToString(open,Digits()),"\n", "High: " ,DoubleToString(high,Digits()),"\n", "Low: " ,DoubleToString(low,Digits()),"\n", "Close: " ,DoubleToString(close,Digits()),"\n", "Volume: ",IntegerToString(volume),"\n" ); }
Conor Mcnamara #:
that logic doesn't make sense just looking at it
that logic doesn't make sense just looking at it
If today was Thursday (4) then Thursday (4) - Monday (1) would give you the highs and lows of 3...which is Wednesday
You need to understand how indexing in time series works https://www.mql5.com/en/docs/series/bufferdirection.
Indexing in time series is done in reverse.
If today was Thursday (4) then Thursday (4) - Monday (1) = 3
shift = 0; means Thursday D1 bar shift = 1; means Wednesday D1 bar shift = 2; means Tuesday D1 bar shift = 3; means Monday D1 bar
Documentation on MQL5: Timeseries and Indicators Access / Indexing Direction in Arrays, Buffers and Timeseries
- www.mql5.com
The default indexing of all arrays and indicator buffers is left to right. The index of the first element is always equal to zero. Thus, the very...
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 , i am new to coding with mql5 and i struggle to find a way of returning the monday high and low . I don't even know where to start from to be honest.
Thank you!