Specific Hours to Trade

Hi,

I am using hourly bars and am trying have my first trade start late in the afternoon and close that trade early the next morning. However, if I set the below to US hours, it will not take any trades. If I set it to 24 hours it will take all trades. I think the problem is that my FirstTradeTime is after the SquareOffTime sequentially in the day. I need to have the SquareOffTime reference tomorrow's Date, not the same day as the FirstTradeTime.

Any help will be appreciated.

Thanks,

Mike

Trading_Hours = ParamList("Trading Hours","US_Hours|24_Hours",1); //
switch (Trading_Hours)
{
case Trading_Hours = "US_Hours"://20%
    FirstTradeTime= 18000;//utc
    SquareOffTime = 08000;//utc
    break;
    
case Trading_Hours = "24_Hours"://40%
    FirstTradeTime=  0 ;
    SquareOffTime = 240000;
	break;
	
default:
    FirstTradeTime= 009000;
    SquareOffTime = 160000;
	break;
}


Buy=Val>1 AND TimeNum()> FirstTradeTime AND TimeNum()<SquareOffTime  AND  ntDays == 0 AND  C>EMA( C, 100*24 ); 
Sell=Val<1;

Short=Val<-1 AND TimeNum()> FirstTradeTime AND TimeNum()<SquareOffTime  AND  ntDays == 0 AND  C< EMA( C, 100*24 ); 
Cover=Val>-1;

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.