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
As there is not a bar present for midnight, you may adapt your code with
I use : if ((Hour() == 0) && (Minute() == 0) && (Seconds() == 0) ...
or if (Day() != PreviousDay) ...
Try my EA used for XAUEUR H1 default params is best.
You 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, 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.
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.
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?