one to one coaching

How to Add A newsfilter

Here is another guide for the time filter,

In the extern parameters, add :



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;

After the extern parameters, add :

int istart,iend;


Before the ordersend functions, add :

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);
}



********************************************************************


A new time filter :

Extern parameters :


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 start :



int nstarthour,nendhour,nfridayhour;
string istarthour,istartminutes,iendhour,iendminutes,ifridayhour,ifridayminutes;
datetime tstart,tend,tfriday;


Before the ordersend functions :

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);
 
one to one coaching
Top