
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
First bar of the day should be the first bar after TimeHour() started over with counting.
That will be of course the first bar of anything M1 , M5 , M15 etc they all start new bars.
I will try it soon, also I am working on this issue.
Thanks a lot.
I still read forums and researching, I can find similar forums, but can't find exactly what I want. ( maybe I do not understand their code style or ... )
I made quickly screenshot, I hope this could help you clearly understand me.
Thanks in advance.
open=iOpen(Symbol(),PERIOD_D1,0);
// put in ontick
if(iOpen(Symbol(),PERIOD_D1,0)!=open)
{
if(TimeHour(open)==0)
{
Alert("New Day !!");
}
open=iOpen(Symbol(),PERIOD_D1,0); // assign new value every hour
}
Ive had a few beers so i hope you get the idea im sure its wrong in every possible way.
I think open must be replaced by time.
Or maybe you can even do:
{
Alert("NEw DAy m8");
}
Ive had a few beers so i hope you get the idea im sure its wrong in every possible way.
ps. what happen to the other thread? it was almost 40 pages?Or maybe you can even do:
( I tried to explain my issue in code source section )
// this code gives me Hour 00:00 - but actually D1 time should show Hour 01:00 | this mean my broker shows absolutely wrong Hour for period PERIOD_D1
// But I need to write code to get first H1 bar Time of the day ( e.g: if first H1 bar 00:00 or 01:00 or ... ) instead of PERIOD_D1
// But I really struggle to write code for get today first H1 time
---
P.S
Are you think why I do not open sub topics?
I am still working on it. I can find solutions in forums. Now it's going good also little slowly.
Additionally:
When I started to write Trade Panel EA's I was thought I need to write 4 function scripts Sell, Buy, Close all Order, EXIT ( remove ) EA.
While I work on it I got a lot of idea's... now that EA's have over 3k lines.
Still I should write almost 10 more useful functions if I decided about all of them.
Also maybe when I finish my that Trade Panel EA's I will write little story about how I started to write script for my Trade Panel EA's. ( even I don't finished it - really I belieave who will see it most people will say: Wow awesome! ) hehe :)
---
Thanks Mr. Marco.
Thank you all ( who reply my comments ) a lot and for your helps.
#property show_inputs
#define HOUR 3600
#define DAY 86400
extern int local_offset = 1; // local time offset from broker (hours)
void OnStart()
{
local_offset*=HOUR;
int D1_shift = (TimeCurrent()%DAY > local_offset) ? 0 : 1;
datetime broker_midnight = iTime(_Symbol,PERIOD_D1,D1_shift);
datetime local_midnight = broker_midnight + local_offset;
int M5_shift = iBarShift(_Symbol,PERIOD_M5,local_midnight);
datetime M5_time = iTime(_Symbol,PERIOD_M5,M5_shift);
double M5_open = iOpen(_Symbol,PERIOD_M5,M5_shift);
printf("M5_time: %s M5_open: %f", TimeToString(M5_time),M5_open);
}
Thanks for your great example.
Maybe if I take a time I will try explain with video / image tomorrow.
I research about this issue so hard.
( also I search like this keywords in google seo (not useful comment so far in seo): site:mql4.com | site:mql5.com first bar of the day )
Are you looking for a way to automatically detect the local > broker time offset? e.g. +1 hour
If you are going to have a manual setting (this is better because sometimes you don't want to use local time but another timezone altogether) the steps your follow are like in my script above:
1. Get midnight on broker time (using iTime or through calculation)
2. Convert it to a local midnight using your offset setting
3. Put local midnight through iBarShift to get the correct bar on your chosen timeframe.
Are you looking for a way to automatically detect the local > broker time offset? e.g. +1 hour
If you are going to have a manual setting (this is better because sometimes you don't want to use local time but another timezone altogether) the steps your follow are like in my script above:
1. Get midnight on broker time (using iTime or through calculation)
2. Convert it to a local midnight using your offset setting
3. Put local midnight through iBarShift to get the correct bar on your chosen timeframe.
You absolutely understand me correctly - that I am looking for a way to automatically... - So, why? I have few important indicator ( self made - with different forums helped ) if I choose manual way - I could change their settings... that is long way - I am so lazy. :)
Thanks so much more!
Maybe I found solution ( at this time looks like it's working - I already tried 2 different brokers I get correct time ).
I believe question comes from lack of experience.
Q: How can I keep only Hour 1 in below outcome, please?
( Actually I found how can I keep only " 1 " from below outcome - but I need professional method, please )
( e.g: result: 2017.02.27 01:00:00 - But I need to keep only: 1 )
Thanks a lot for everything.
( I will share how I found solution. - if you did not help I can't found solution - one more thanks a lot. )
I was looking for just below code.
But I still need to test it.
Period_Shift=iBarShift(Symbol(),PERIOD_H4,Period_Look);
Period_Time=iTime(Symbol(),PERIOD_H4,Period_Shift-1);
GMT_Offset=(Period_Time-iTime(Symbol(),PERIOD_W1,0)-PeriodSeconds(PERIOD_D1))/PeriodSeconds(PERIOD_H1); // result: 1
If above code is not right, please let me know.
Thanks a lot @honest_knave and @Marco
Well Max consider this, if you are scanning for a pattern, and it forms, then your trigger will go off regardless of time stamp.
So the trigger can have several time stamps on different brokers, but the exact moment of the trigger would be about the same on all brokers.
Not exactly, but close enough.