Server side close of position before the close of Market

From what I have understood so far it is near impossible to keep positions open overnight on NinjitTrader, the margins are 20 times higher. So for me I would never have a situation in this lifetime when I would want my position open overnight in NinjitTrader brokerage.
But I am yet to find a setting I can put on the server side to close all positions 1 hour before the close of the market.
Which means even if my strategy stops putting trades 2 or 3 hours before the close of market there is a slight chance that the position might not close before the end of the day.
I can configure many tools to close those positions on my VPS but my concern is if NinjitTrader crashes or my VPS crashes while the trade is open and then in 2 or 3 hours if the position does not close it will end up staying open overnight and wipe out my account.

Considering how critical it is for all positions to close before the close of the day, is there really no way to configure the server side to implement that rule of closing the positions before the end of day.

Thanks in advance.

1 Like

Is auto close position not working for you?

1 Like

Will this setting also not stop my strategy.
What i noticed is that my strategy that was doing nothing other then printing in a log file got shut down when i looked at it the next morning and i assumed this setting closes all strategies, that is why i disabled this and started looking for another solution.

I’m not exactly sure since I don’t use it, but I would assume so. I would think it’s similar as clicking the close button, which closes all positions and strategies. If you are coding your own strategies you can just look at only allowing strategies within a specific time range. You can try something like this. order-flow-bot/NinjaTrader/Custom/AddOns/OrderFlowBot/OrderFlowBot.cs at 2358a21722ccb7585b77a924eacbfb37ad287b0f · WaleeTheRobot/order-flow-bot · GitHub

3 Likes

Yes the Auto close position is the “catch all” and will disable any strategies at the time you have set.

1 Like

Is there no way to schedule the start of the strategy that was shutdown before the close of market (by the ninjatrader setting) to start a few hours after the market opens.

I don’t think so because you have to enable the strategy. What you really want is to enable the strategy, but only allow it to enter trades within a certain time range.

1 Like

its already configured to place trades only during active market sessions, but looks like a human being is required every morning to turn the strategy back on. I would have wanted my strategy to run non stop for weeks on the VPS without the need for a human intervention every morning to turn it on..

If it only takes trades I’m assuming during regular trading hours then what’s wrong with just leaving it on? It also doesn’t take much time to just go toggle it on or off every morning too…

Yes thats exactly what i want, i want to go offline into the forest while my strategy is minting money on its own, the documentation says strategies will only be closed of they have placed trades or orders, but what I have noticed is that even strategy that never places any trades gets shutdown by the ninjatrader setting.

Looks like even auto-close is a feature on the platform and not the server side, so if the VPS or ninjatrader was to crash even this auto-close would not get triggered.

So back the the same issue, when no one is placing overnight trades on ninjatrader, how come ninjatrader is not offering an auto-close option that can execute at the server side.

They do offer it… if they have to close it at the broker for you then they charge you a fee. Considering your 1 tick stop loss… I wouldn’t be too concerned about some crash wiping your account.

If you are that concerned about it.. code something to only open trades within a certain time range. Then code something to close all your positions within that time range. For the warm and cozy feeling… just code something to send you an email or a message on Discord towards the end of the time range. If it fails, your backup is to manually go close it.

My stop loss is sometimes 50 ticks, 1 tick stop loss is a different thread.