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
No, because Time[x] returns a datetime . . . but you can do . . .
read up on TimeHour
Hi people
Pesky business took all my time for a while there, but back to coding now
Thanks for all these replies
I was considering just using some such code for this trading time range also I see now there are many different ways to go about this.
if(Hour() >= 2 && Hour()<17)
Thanks again
I see the documents here about it:
https://docs.mql4.com/basis/types/datetime
https://docs.mql4.com/series/iBarShift
I'm trying to select a candle something like this perhaps
if(TimeToStr(Time[1]) == 7:15)
Print(Low[1], " 7:15 low");
I know 7:15 is not the correct datetime method; and yet this is where I'm having trouble comparing daily reoccurring time
IBarsShift indicates the same datetime scheme for the datetime constant but it appears to be only for a partcular datetime and not reoccuring daily time.
I'm assuming I have to use IBarsShift to find out the shift to search for that particular bars time and it returns the shift for that bar then I can use the shift to select that candle and use it's data.
At least thats how I'm seeing it.
I could probably work through what I am trying to do if I could figure out how to select a daily reoccuring time rather then a specific time during 1 particular date.
And one that has the same format at Time[] or TimeToStr(Time[]) or some such method so that I can make the comparison and use the data for that candle
I'm not completely convinced I wan to use IBarsShift because I don't really want to search for a bar by open time either
I want to know when Time[1] or even Close[1] == a_particular_time
Please advise
Thanks
One last question about Datetime constants and the datetime format used for iBarsShift
I see the documents here about it:
https://docs.mql4.com/basis/types/datetime
https://docs.mql4.com/series/iBarShift
I'm trying to select a candle something like this perhaps
if(TimeToStr(Time[1]) == 7:15)
Print(Low[1], " 7:15 low");
I know 7:15 is not the correct datetime method; and yet this is where I'm having trouble comparing daily reoccurring time
Why not just calculate the datetime value for 7:15 ? How ?
Calculate the datetime for midnight . . . add on ( (7 * PERIOD_H1) + 15) * 60
datetime for midnight
Why not just calculate the datetime value for 7:15 ? How ?
Calculate the datetime for midnight . . . add on ( (7 * PERIOD_H1) + 15) * 60
Just like I already posted, previously, on THIS thread
Agent86: If you're not going to bother reading what we've posted and learning, we're waisting our time with you.
Just like I already posted, previously, on THIS thread
Why not just calculate the datetime value for 7:15 ? How ?
Calculate the datetime for midnight . . . add on ( (7 * PERIOD_H1) + 15) * 60
datetime for midnight
So I could code something like:
datetime time_select = ( (7 * PERIOD_H1) + 15) * 60
if(Time[1] == time_select)
Print(Time[1], '' and", Low[1]);
But what is PERIOD_H1 value when not being used as a timeframe enumeration value for an indicator. I don't see anything in the documentation about using this in another way.
But this does sound like what I'm after for selecting a particular time to compare it with the time of a particular candle
Thanks
Just like I already posted, previously, on THIS thread
Agent86: If you're not going to bother reading what we've posted and learning, we're waisting our time with you.
Thanks for the response
I did read your post which was regarding a time range or range / filter and I understood the conclusion but not the equations completely
By your answer I have to assume that I don't understand how to create an expression that would compare something like if(Time[1] == 7:15) in it's proper form because I don't understand the equations you posted.
Please confirm
I do not mean to ask the same questions if this is actually the same answer that I needed, but I did not think it was or I would not have asked it again.
Thanks
Yeah, but that was last year . . . everyone has slept since then ;-)
No doubt.
I really wanted learning mql quickly and spend much more time on it
Unfortunately my business is a complete nuisance which consumed way too much time that past year.
I've made some adjustments so hopefully I can proceed consistently once again.
Thanks everyone for the responses
Thanks
So I could code something like:
datetime time_select = ( (7 * PERIOD_H1) + 15) * 60
if(Time[1] == time_select)
Print(Time[1], '' and", Low[1]);
But what is PERIOD_H1 value when not being used as a timeframe enumeration value for an indicator. I don't see anything in the documentation about using this in another way.
You really need to start learning your way around the documentation . . .
Go to any function that uses a TimeFrame and you will see timeframe enumeration . . . and it links to here: Timeframe enumeration and that will tell you that Period_H1 is a value of 60 . . . in other words 60 minutes . . . 60 mins * 60 = seconds . . . datetimes are in seconds.
What you have coded won't work . . your time_select is NOT a datetime . . . remember, what is a datetime ? from the Documentation . . . "datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970)." if you want a datetime that means 7:15 am it has to be the number of seconds that have elapsed from 1 Jan 1970 to 7:15am today . . .
What you ave calculated is the number of seconds from Midnight to 7:15am this morning, and that is not a datetime.