I am trying to backtest a simple buy-and-sell strategy. Whenever I run a backtest on the following strategy(given below), the system does not generate any output.
StartTime = ParamTime("Start Time", "09:20");
EndTime = ParamTime("End Time", "15:00");
sqOffTime = ParamTime("Square Off Time", "15:10");
Pd = Optimize("Period", 4, 1, 20, 1);
Buy= PDI(Pd) - MDI(Pd) >= 20 AND TimeNum() > StartTime AND TimeNum() < EndTime;
Sell= PDI(Pd) - MDI(Pd) < 10 OR TimeNum() >= sqOffTime;
Short= MDI(Pd) - PDI(Pd) >= 20 AND TimeNum() > StartTime AND TimeNum() < EndTime;
Cover=MDI(Pd) - PDI(Pd) <10 OR TimeNum() >= sqOffTime;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
However, when I simply comment out the line after 'AND' in BUY or SHORT statements as given below, the backtest runs perfectly.
StartTime = ParamTime("Start Time", "09:20");
EndTime = ParamTime("End Time", "15:00");
sqOffTime = ParamTime("Square Off Time", "15:10");
Pd = Optimize("Period", 4, 1, 20, 1);
Buy= PDI(Pd) - MDI(Pd) >= 20; //AND TimeNum() > StartTime AND TimeNum() < EndTime; //AND ADX(Pd) >= 35
Sell= PDI(Pd) - MDI(Pd) < 10 OR TimeNum() >= sqOffTime;
Short= MDI(Pd) - PDI(Pd) >= 20 AND TimeNum() > StartTime AND TimeNum() < EndTime; //AND ADX(Pd) >= 35
Cover=MDI(Pd) - PDI(Pd) <10 OR TimeNum() >= sqOffTime;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
I am unable to understand why the backtester does not accept the 'start time' and 'End Time' together with the Buy or Sell Signal.
Appreciate any help in figuring out the logic behind the backtest not producing any result with the above-mentioned conditions.