NinjaScript > Educational Resources > Developing Strategies > Strategy Position vs. Account Position |
![]() ![]() ![]() ![]() |
An important concept to understand prior to using NinjaScript strategies in a real-time trading environment (live brokerage account, for example) is the difference between a Strategy Position and an Account Position.
Strategy Position A Strategy Position is a virtual position that is created by the entry and exit executions generated by a strategy and is independent from any other running strategy’s position or an Account Position.
Account Position An Account Position is the position you actually hold in a real-time trading account, whether it is a NinjaTrader internal simulation account (Sim101) or your live real-money brokerage account.
In most cases, a trader would want their Strategy Position’s size and market direction to be equal (in sync) to their Account Position, but there are situations when this may not be the case. For example:
An extremely common scenario… An extremely common scenario is starting a NinjaScript strategy in the middle of a trading session, such as one hour after the session has begun. The NinjaScript strategy is run on each historical bar for the 1st hour of the session (it will actually run on all historical data loaded in a chart) to determine the current position state it would be in if it had been running live since the start of the session. This position state then becomes the Strategy Position for your strategy. Let us assume that during the historical hour your strategy would have entered a LONG 1 position and the position is still open. This would mean the Strategy Position is LONG 1 and since this trade was not actually executed on an account, your Account Position is FLAT.
What can you do in this case? If you want your Account Position to match your Strategy Position, you will need to place a manual order into the account the strategy is running on. Continuing from the above example, you would need to place a 1-lot market order for the market being traded into the account the strategy is running on. Alternatively, new to NinjaTrader 7 is the ability to have your account automatically synced to your strategy position on strategy startup. To use this feature, please set "Sync account position" to true in the Strategy dialogue window. For more information on this feature please see the article here about syncing Account Positions to Strategy Positions. |