Hi I am an experienced developer but this is my first attempt at an MQL4 expert advisor.
I am looking open two pending orders on the Germany 30 indicies as soon as it opens (7:00 BST). As my broker is alpari and from what I have read their servers work on GMT+3 this means I should try and get the orders to open at 9:00am
If I take this code out the ea tries to place an order whenever start is called (the send order is unsuccessful returning a Error code 130, but that's a different issue, one thing at a time Rich :-) )
Any help telling me what's wrong with the code would be very much apprcieated.
Hard to say, not enough information . . . what is tod ? timeofday I assume, why not use that as a variable name ? but how is it calculated/stated ? for it to work it would have to be something like TimeCurrent() - Midnight where midnight is something like this: Midnight
Many thanks for your help RaptorUK, I have been having difficulty getting my head around MQL4, but Im sure the Eureka moment will happen soon ;)
tod was originally calculated as:
datetime now = Time[0] int tod = now % 86400;
Given I had read elsewhere that the time was given in seconds I declared this as an int, although from your post it seems that was wrong :-(. I also take your point on the variable name
I have now changed this to the following.
datetime Midnight = TimeCurrent() - (TimeCurrent()%(PERIOD_M1 * 60)); datetime TimeOfDay = TimeCurrent() - Midnight;
The code now runs as originally posted with the 'tod' variable changed to 'TimeOfDay'
It looks like I will have to wait until Monday to test as I'm not sure the strategy tester is working accurately. The journal is showing print statements at very strange times, usually between 22:00 and 23:00 for the dates I have chosen to test. I'm not yet sure if it's a code problem, a strategy tester problem, or a Historical data problem... Arrrrrrrrrrrr lol Would you trust the strategy tester, if so does it still sound like there's a problem with the code?
Should
datetime Midnight = TimeCurrent() - (TimeCurrent()%(PERIOD_M1 * 60));
be
datetime Midnight = TimeCurrent() - (TimeCurrent()%(PERIOD_D1 * 60));
??
Should
be
??

- 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 am an experienced developer but this is my first attempt at an MQL4 expert advisor.
I am looking open two pending orders on the Germany 30 indicies as soon as it opens (7:00 BST). As my broker is alpari and from what I have read their servers work on GMT+3 this means I should try and get the orders to open at 9:00am
If I take this code out the ea tries to place an order whenever start is called (the send order is unsuccessful returning a Error code 130, but that's a different issue, one thing at a time Rich :-) )
Any help telling me what's wrong with the code would be very much apprcieated.