I am trying to backtest a strategy in which I generate an entry signal on a daily bar series. I want to enter a stock position 1 minute after opening, and exit 1 minute before close. I got it to enter correctly, but I can't seem to nail the exit condition:
if (BarsInProgress == 0)
{
if (TestPredictor(BarsArray[0]).Plot[0] > Threshold)
{
enter = true;
}
}
else if (BarsInProgress == 1)
{
if (enter == true)
{
EnterLong(1, DefaultQuantity, "test_entry");
enter = false;
}
if (BarsSinceEntry(1, "test_entry", 0) == 389)
{
ExitLong(1, DefaultQuantity, "test_exit", "test_entry");
}
}
My barsInProgress index is 0 for daily, and 1 for minute based data.
Thanks

Comment