| / | Forum |
|
ForexGeek
2007.10.25 18:29
Hi,
New to MQL4 and I have two questions: 1. I want to perform an operation after a bar has closed, regardless of period. How do I test that a bar has closed so that I can perform my operation. I saw one example on the site that didn't work very well. 2. I travel quite a bit and I want to be able to trade different pairs in different markets. How can I determine when the Asian, UK or US market is open if I'm in New York, Los Angeles or Maui? Thanks, FG |
|
Interview with Rich (Roman Zamozhniy) We had an interview with the Winner of the Automated Trading Championship 2006 – Mr. Roman Zamozhniy, known under the nickname Rich. Regardless his winning in the last-year Championship, Roman completely redesigned his trading strategy. Roman is not afraid of the competition. He feels he fights against the market, and not against other Participants. |
|
phy
2007.10.25 19:36
1: int oldBarTime; init(){ oldBarTime = Time[0]; } start(){ ... ... if(oldBarTime != Time[0]){ oldBarTime = Time[0]; ... a new bar has just started... 2. Chart time won't change when you travel. ww.marketclocks.com is useful |
|
ForexGeek
2007.10.25 21:10
All I did was have an alert fire whenever a bar closed and the results were not
consistent. Any ideas why?
When I say inconsistent I mean I was getting an alert at 3 to 5 seconds after the minute, then some times 50 or 51 seconds after the minute. Thanks, FG |
|
phy
2007.10.25 21:41
New bar occurs with the first tick of the new bar, not according to clock time. No tick, no bar. New tick may come at any time, or never. MT4 Charts can even have a hole where no tick was received during the clock period
of that |
|
ForexGeek
2007.10.25 21:56
Thanks, you are very knowledgeable. So when I hover over bars in a chart and they
all show perfect timing 18:30, 18:45, 19:00 that's not accurate?
What other method is there to have a block of code execute every n minutes? Again, much thanks in advance, FG |
|
phy
2007.10.25 22:17
The bars represent time periods, so the times are "correct" But, a new bar will not appear on a chart until there is a tick in that time period If no tick comes, there will be no bar for that period. how many bars do you have for last Saturday? --- indicators and EA's depend on a new tick to cause the code to be run A script does not wait for ticks, it starts when you attach it to a chart. Create a loop in the script, and it will continue to execute indefinately. You can use LocalTime() for timekeeping to the second. If you do create a loop, put a Sleep() in it or you may find yourself trapped in the loop at 100% CPU script: int start(){ Comment("Waiting"); while(!IsStopped()){ if(MathMod(TimeLocal(), 15) == 0){ string time = TimeToStr(LocalTime(), TIME_DATE|TIME_SECONDS); Comment("Time was ", time); } Sleep(100); } return(0); } |
|
ForexGeek
2007.10.25 23:02
Thanks a ton Phy.
FG |
|
ForexGeek
2007.10.26 18:29
I tried it last night and it worked great. I also got a chance to see what you meant
by "a new bar will not appear on a chart until there is a tick in that time
period". This brings up another question. Does the switch of Bar[0] to Bar[1]
and the creation of the new Bar[0] also wait on a tick in the new time period?
Thanks, FG |
|
phy
2007.10.26 19:29
bar0 is always the rightmost bar on the chart. Doesn't matter what time it is. There is nothing in MT4 that says "weekend start" and "weekend End".
The ticks (and therefore |
|
ForexGeek
2007.10.26 19:37
Again, thanks a lot.
FG |