You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
EA during Specific time frame
Hi there
Could anyone advise how to run an EA during a specific time frame, e.g between 1pm - 4pm on GBP/USD.
Thanks
Time on a EA.
Hello,
I want to learn how to put the time to start trading an ea, and the time to stop trading.
Is this very difficult ?
I have opened the metaeditor only once, please, the one that want to respond me, say me step by step.
Thanks!
It's relatively easy, canaleuropeo.
First, add as many variables as you need in the header. By instance:
//
extern bool TradeOnFriday = true;
extern bool TradeOnSunday = true;
extern bool TradeOnMonday = true;
extern int LastDayOnMonth = 32;
extern int TradeHourWindowInit = 0;
extern int TradeHourWindowEnd = 24;
//
This way you can change these variables when you want. Next, add a new function as follow:
//
bool IsTimeToTrade() {
if(TradeOnFriday == false && DayOfWeek() == 5) return(false);
if(TradeOnSunday == false && DayOfWeek() == 0) return(false);
if(TradeOnMonday == false && DayOfWeek() == 1) return(false);
if(Day() > LastDayOnMonth) return(false);
if(TradeHourWindowInit < TradeHourWindowEnd) {
if(TimeHour(TimeCurrent()) TradeHourWindowEnd) return(false);
}
else {
if(TimeHour(TimeCurrent()) TradeHourWindowEnd) return(false);
}
return(true);
}
//
At last, you should add the following sentence just before the OrderSend function:
if(IsTimeToTrade() == false) { return(0);}
This way, if it is not time to trade, the system doesn't Open a new trade.
Please help
Hi,
Please help me to add specific time period to open trade in my EA. Set input as
Trade open time1:-
Start:
End
Trade open time2:-
Start:
End
Trade open time3:-
Start:
End
Great Code
It's relatively easy, canaleuropeo.
First, add as many variables as you need in the header. By instance:
//
extern bool TradeOnFriday = true;
extern bool TradeOnSunday = true;
extern bool TradeOnMonday = true;
extern int LastDayOnMonth = 32;
extern int TradeHourWindowInit = 0;
extern int TradeHourWindowEnd = 24;
//
This way you can change these variables when you want. Next, add a new function as follow:
//
bool IsTimeToTrade() {
if(TradeOnFriday == false && DayOfWeek() == 5) return(false);
if(TradeOnSunday == false && DayOfWeek() == 0) return(false);
if(TradeOnMonday == false && DayOfWeek() == 1) return(false);
if(Day() > LastDayOnMonth) return(false);
if(TradeHourWindowInit < TradeHourWindowEnd) {
if(TimeHour(TimeCurrent()) TradeHourWindowEnd) return(false);
}
else {
if(TimeHour(TimeCurrent()) TradeHourWindowEnd) return(false);
}
return(true);
}
//
At last, you should add the following sentence just before the OrderSend function:
if(IsTimeToTrade() == false) { return(0);}
This way, if it is not time to trade, the system doesn't Open a new trade.Hi Xere,
I just came across your post and it's just what I'm looking for...thanks !
One question though as I haven't been able to test your code yet:
If one of my EAs is Martingale does it turn it off immediately or after cycle completes?
ie. If End time is set at 3.00pm and EA is in the middle of a martingale series at 3.00pm can it carry on and finish that sequence?
(ie. It prevents a new sequence starting after End time is reached?)
If not......do you know how to add more code to your one above to make it do that?
If so, that would be fantastic, as I've been look for this for ages .
Many thanks in advance......
Hi guys,
I have problem integrating 2 time filter codes
The first time filter allows for trading times to cross midnight to the next morning while the latter has the ability to let user select 3 different trading times.
I am able to get the time filter to work only if the 3 trading times are selected. However, if i disable any of the trading time filter, it would no longer work. Can anyone take a look and help me? Thanks a million.
time_filter_integration.mq4