Hi all, I use the following code in the majors, and it works well.
If I apply the same code on GOLD it doesnt' work.
My broker is GMT+2.
The opening bar for the majors is 0:00, for GOLD the opening is 1:00.
How can I edit the code fot GOLD? Thank you!
Try....
if(Symbol() == XAUUSD) timeDailyOpen = timeDailyOpen + 3600;
...but, what "Time" exactly are you looking for... "Server" Time... "Local" Time....? The time on your computer "Local" Time is not the same as the markets...
In what context are you wanting to use this value?
All you are basically asking for is the "Bar Number" of the first bar of a New Day based on your computers "Local" time... (if I am correct).... I don't see the value for that...
datetime timeDailyOpen=iTime(Symbol(),PERIOD_D1,0); int currentDailyBars=iBarShift(Symbol(),PERIOD_H1,timeDailyOpen,true); if(currentDailyBars==-1) currentDailyBars=iBarShift(Symbol(),PERIOD_H1,timeDailyOpen,false)-1;
This should work for all symbols.
Note that it only calculates closed bars, same as your code.
This should work for all symbols.
Note that it only calculates closed bars, same as your code.
I seem it works well 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 all, I use the following code in the majors, and it works well.
If I apply the same code on GOLD it doesnt' work.
My broker is GMT+2.
The opening bar for the majors is 0:00, for GOLD the opening is 1:00.
How can I edit the code fot GOLD? Thank you!