I’m not up to speed in running algo’s, so this may be at bit of BS.
I started scratching head when you mentioned, ‘Market closed’ and ‘ tries to take position’.
@GraHal brings up a good point.
If your algo is on daily, and lets say the code only action’s events at the close of a daily bar,
then does that mean that even if the code recognised the market was in the closed area,
it couldn’t action the change till the end of a bar, whereby the halt condition is no longer true.
And therefore, setting an halt at the beginning of the day, and, with a change in the middle of the day, wouldn’t get actioned till the end of the day.
Where it all repeats, possibly with no trades.
This seems to explain while messing around with the time on daily, doesn’t give logical results regarding actions taken.
Regarding , why it tries to take order when market shut, still scratching head.
Unless you can make orders all the time, and get the error, if market shut.
But, what made condition true…