I am coding a strategy to enter long when it is 9AM and exit at 11AM.
What is the right way to do this?
I tried this code below, but in strategy backtest, it did not generate trades on 5 min bar.
Thanks
if ((ToTime(Time[0]) > 90000)
&& (ToTime(Time[0]) < 110000)
&& Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(DefaultQuantity, "Long");
}
if (ToTime(Time[0]) >= 110000
&& ToTime(Time[0]) <= 90000
&& Position.MarketPosition == MarketPosition.Long)
{
ExitLong("ExitLong", "Long");
}
Comment