Would like to create a proper time based filter that can be backtested, any ways to code this logically and simply?
For a long time I've been using:
But it's not perfectly correct...For filtering by hour only it's fine like this:
But when adding minute it gets a bit more complicated. I looked at this kind of code below but it does not allow for variables to test H and M, and forces me to manually input each time. I want to be able to back test the best H:MM to start and end.
I would like to be able to test combined H and M for both start and stop times on a daily basis, not just testing by H only.
What is the best and simplest way to implement this?
For a long time I've been using:
Inserted Code
if (UseBeforeAfterHM_Filter == true) {
if((Hour()<=TH1) && (Minute()<=TM1)) return(0);
if((Hour()>=TH2) && (Minute()>=TM2)) return(0); But it's not perfectly correct...For filtering by hour only it's fine like this:
Inserted Code
if (UseBeforeAfterHM_Filter == true) {
if(Hour()<=TH1) return(0);
if(Hour()>=TH2) return(0); But when adding minute it gets a bit more complicated. I looked at this kind of code below but it does not allow for variables to test H and M, and forces me to manually input each time. I want to be able to back test the best H:MM to start and end.
Inserted Code
extern string TradeStartTime = "8:30"; extern string TradeStopTime = "23:30"; if(TimeCurrent()<StrToTime(TradeStartTime) && TimeCurrent()>StrToTime(TradeStopTime)) return(0);
I would like to be able to test combined H and M for both start and stop times on a daily basis, not just testing by H only.
What is the best and simplest way to implement this?