i am putting in the times in this format: HHMM (like 2100 to 0600). Its not working in back test. Am i doing something wrong?
i am putting in the times in this format: HHMM (like 2100 to 0600). Its not working in back test. Am i doing something wrong?
No overnight periods, must be endTime > startTime
I've updated attachment in previous post - try new one
ok..so its not possible to trade asian session? sorry for being so dumb...
awesome! thank you very much!
Here is another guide for the time filter,
In the extern parameters, add :
After the extern parameters, add :Code:extern int gmtshift=2; extern bool filter=false; extern int start=7; extern int end=21; extern bool tradesunday=true; extern bool fridayfilter=false; extern int fridayend=24;
Before the ordersend functions, add :Code:int istart,iend;
Code:istart=start+(gmtshift);if(istart>23)istart=istart-24; iend=end+(gmtshift);if(iend>23)iend=iend-24; if((tradesunday==false&&DayOfWeek()==0) ||(filter&&DayOfWeek()>0&& ( (istart<iend && !(Hour()>=(istart)&&Hour()<=(iend)))|| (istart>iend && !((Hour()>=(istart)&&Hour()<=23)||(Hour()>=0&&Hour()<=(iend)))))) ||(fridayfilter&&DayOfWeek()==5&&!(Hour()<(fridayend+(gmtshift))))){ return(0); }
Trading forex risk disclaimer. Exclusive EAs in the Elite section.
A new time filter :
Extern parameters :
Before start :Code:extern string timefilter="Time Filter"; extern int gmtshift=1; // gmt offset of the broker extern bool generalfilter=false; // enable time filter extern int starthour=7; // start hour to trade after this hour extern int startminutes=0; // minutes of the start hour extern int endhour=21; // stop to trade after this hour extern int endminutes=0; // minutes of the start hour extern bool tradesunday=true; // trade on sunday extern bool fridayfilter=false; // enable special time filter on friday extern int fridayhour=21; // stop to trade after this hour extern int fridayminutes=0; // minutes of the friday hour
Before the ordersend functions :Code:int nstarthour,nendhour,nfridayhour; string istarthour,istartminutes,iendhour,iendminutes,ifridayhour,ifridayminutes; datetime tstart,tend,tfriday;
Code:if(generalfilter){ nstarthour=starthour+(gmtshift);if(nstarthour>23)nstarthour=nstarthour-24; if(nstarthour<10)istarthour="0"+nstarthour; if(nstarthour>9)istarthour=nstarthour; if(startminutes<10)istartminutes="0"+startminutes; if(startminutes>9)istartminutes=startminutes; tstart=StrToTime(istarthour+":"+istartminutes); nendhour=endhour+(gmtshift);if(nendhour>23)nendhour=nendhour-24; if(endhour<10)iendhour="0"+nendhour; if(endhour>9)iendhour=nendhour; if(endminutes<10)iendminutes="0"+endminutes; if(endminutes>9)iendminutes=endminutes; tend=StrToTime(iendhour+":"+iendminutes); } if(fridayfilter){ nfridayhour=fridayhour+(gmtshift);if(nfridayhour>23)nfridayhour=nfridayhour-24; if(nfridayhour<10)ifridayhour="0"+nfridayhour; if(nfridayhour>9)ifridayhour=nfridayhour; if(fridayminutes<10)ifridayminutes="0"+fridayminutes; if(fridayminutes>9)ifridayminutes=fridayminutes; tfriday=StrToTime(ifridayhour+":"+ifridayminutes); } if((generalfilter && (nstarthour<nendhour && TimeCurrent()<tstart || TimeCurrent()>tend) || (nstarthour>nendhour && TimeCurrent()<tstart && TimeCurrent()>tend)) || (tradesunday==false && DayOfWeek()==0) || (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))return(0);
Trading forex risk disclaimer. Exclusive EAs in the Elite section.
Hy
can help me please somebody
i need to put in my ea the code to start trading at monday 15 gmt and end trading at friday at 15gmt
thank you
You do this by including some code towards the top of the start() function which will get your EA to return without doing anything. Something like this:
In addition to that you will need to do something about your broker's server time offset, as not every broker will be aligned to GMT. The easy way is to include an external parameter for this in global scope and add it to the 15.PHP Code:int start() {
if(DayOfWeek() == 0) return;//this is Sunday
if(DayOfWeek() == 1 && Hour() <15 ) return;//this is Monday
if(DayOfWeek() == 5 && Hour() >= 15) return;//this is Friday
if(DayOfWeek() > 5) return;//this is Saturday
//the rest of your code goes here
}
You will also need to think carefully about where you position this block of code within the start() function, as you may want to manage the SL of any open orders outside of these times.
PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!
How can i add different gmt settings for summer and wintertime?