As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
I use : if ((Hour() == 0) && (Minute() == 0) && (Seconds() == 0) ...
or if (Day() != PreviousDay) ...
Try my EA used for XAUEUR H1 default params is best.
Nedd the source? let me knowI use : if ((Hour() == 0) && (Minute() == 0) && (Seconds() == 0) ...
Try my EA used for XAUEUR H1 default params is best.
Nedd the source? let me knowYou need to be careful with this logic.
If you don't get a tick coming in at the exact second of midnight, this logic will not trigger.
If you get 2 or more ticks coming in at the exact second of midnight, it will fire multiple times.
As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
I use : if ((Hour() == 0) && (Minute() == 0) && (Seconds() == 0) ...
Try my EA used for XAUEUR H1 default params is best.
Nedd the source? let me knowAs there is not a bar present for midnight, your if() will never return true.
Your code is only useful for checking against the current time, so no good for drawing objects on earlier bars.
As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
As there is not a bar present for midnight, your if() will never return true.
Your code is only useful for checking against the current time, so no good for drawing objects on earlier bars.
As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
You could further refine this using a 'while' loop rather than an 'if' statement, for cases when it isn't only 1 bar short of midnight.
It shouldn't be necessary to use a loop.
If there is not a bar with the searched for time, iBarShift will return the next earlier bar, so it will be the last bar before midnight.
shift - 1 will be the first bar after midnight.
It shouldn't be necessary to use a loop.
If there is not a bar with the searched for time, iBarShift will return the next earlier bar, so it will be the last bar before midnight.
shift - 1 will be the first bar after midnight.
As there is not a bar present for midnight, you may adapt your code with
OpenTime = iTime(NULL, PERIOD_D1, 0);
int shift=iBarShift(Symbol(),0,OpenTime);
if(Time[shift]!=OpenTime)
OpenTime=Time[shift-1];
Thank you this perfectly worked!! :). Dont know if you can help me with something else @Keith Watford
the red fibonacci is for downtrend and the green one is for uptrend of the day. Sometime it show the worng one,
exemple : red fib for for uptrend. I just change time frame and come back at the initiale one and it come back
to the correct fib, in that case the green one. Do you see something wrong on the code about that?
thank you
Thank you this perfectly worked!! :). Dont know if you can help me with something else @Keith Watford
the red fibonacci is for downtrend and the green one is for uptrend of the day. Sometime it show the worng one,
exemple : red fib for for uptrend. I just change time frame and come back at the initiale one and it come back
to the correct fib, in that case the green one. Do you see something wrong on the code about that?
thank you

- 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,
I've made an indicator that draw a fibonacci from the low of the day to the high of the day or invert depending on the trend.
Everything work great but now with the GOLD. If you go on m5 you will see that the day dont start at 00:00 but at 23:55. How can I add
5min to gold with this...
SwingHigh = iHigh(Symbol(),PERIOD_D1,0);
SwingLow = iLow(Symbol(),PERIOD_D1,0);
I attached the mq4 file
Thank you
Whoseen