I found some piece of code which I am using sometimes.
If I need to do some back/forward test in particular hours, or if I am not trading 24 hours per day I use the following code to be inserted in EA:
In the top of EA (where information about the lots, Take Profit etc are located) insert the following:
Code:
extern bool UseHourTrade = True;
extern int FromHourTrade = 9;
extern int ToHourTrade = 21;
After that look on the code and find the line
After this line there are some pieces of the code where something is checking (Bars, TakeProfit<10 etc).
If you see it you may insert the following code:
Code:
if (UseHourTrade){
if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
Comment("Non-Trading Hours!");
return(0);
}
}
For example:
Code:
int start(){
if(Bars<100){
Print("bars less than 100");
return(0);
}
if (UseHourTrade){
if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
Comment("Non-Trading Hours!");
return(0);
}
}
if(lStopLoss<10){
Print("StopLoss less than 10");
return(0);
}
if(lTakeProfit<10){
Print("TakeProfit less than 10");
return(0);
}
We can not do it with every EA. But in some EA we can. If I change something in the code I will mark it in the comments in the code (working hours was added by newdigital) and will re-name this EA. For example, I changed something in Ichimoku5 and I receive Ichimoku5_1. Why? If you post changed EA to the forum the other members will not be confused with the versions and will know exactly where the original version is and where is yours which you changed for yourself only.
Codersguru will correct me if I did mistake.