defining trading time
8 replies
Scout2408
9 years ago #113517
Hello Traders,
Since I am new to EA programming, especially EA Wizard, I kindly ask for your assistance regarding the following issue.
I want the EA to only trade from 10 a.m. CET to 7 p.m. CET. Now my questions regarding EA Wizard:
– at first step I would like to code an option where I can choose time restrictions true/false
– second, if time restrictions are TRUE, how can I define the trading time range correctly?
– is it possible to code these conditions with EA Wizard or do I have to add it directly to the source code?
Thank you for your answers.
Michael
Mark Fric
9 years ago #129548
yes, it is possible and not that difficult.
how to control the option:
– create a new boolean variable, name it for example TimeRangeActive. You’ll be then able to control it by changing this variable to true or false
– your IF condition could look like this:
IF TimeRangeActive = true
and Hour > 10
and Hour < 19
and … other conditions
THEN
Enter at market
You can use variables for hours too, instead of using fixed numbers.
Keep in mind that the times are always your broker times, not CET. So you have to recompute the time to the broker time if he is not using CET time zone.
in
Mark
StrategyQuant architect
Scout2408
9 years ago #129575
Thanks a lot for your detailed reply, Mark.
Your support is highly appreciated!
Best regards,
Michael
daveM
8 years ago #134911
In Marc’s post he shows
IF TimeRangeActive = true
and Hour > 10
and Hour < 19
Could I use that to optimize for best hours to trade? (assigning variables)
daveM
8 years ago #134912
Update
I did use that and it is working well.
BUT, I did not see the first line ‘If TimeRangeActive = True’, not sure where to find that one.
Maybe that is from older version of the software.
tomas262
8 years ago #134932
Dave, Mark defined this variable TimeRangeActive while setting it to boolean type i.e. True or False
You can optimize trading time window. Instead of using 10 and 19 fixed values just create variables ‘startTime’ and ‘endTime’ and use them in your condition. Now you can optimize it in MetaTrader.
Don’t forget to add a condition into your trading rule which says ‘startTime < endTime'. This way you ensure everything works correctly
Let me know if you need me to create an example
daveM
8 years ago #134939
What I did seems to be working so far, I have optimized quite a few times and results seem fine.
Thanks
Dennisd
8 years ago #135000
tomas262
8 years ago #135008
Hi, no problem. Created one for you. It enters a position in a specified time range. In this case I set 9 o’clock start and 9 o’clock end so it trades only between 9:00 and 9:59
Viewing 8 replies - 1 through 8 (of 8 total)