Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Manual Order Close in a Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Manual Order Close in a Strategy

    Hello Experts

    I have a strategy that works perfectly. The only issue I have is if I close the order manually, the strategy does not pick up the next order. Example:

    1. Strategy runs and places a Long order
    2. I manually intervene and close the Long order.
    3. I restart the Strategy(remove and start again). The Strategy does not pick the order....Also, the Chart don't show the order as closed. And see the screen shot below, even though the order is closed it shows position as 1L
    Click image for larger version

Name:	image.png
Views:	60
Size:	9.2 KB
ID:	1298444

    How do I fix it? Appreciate your help!

    #2
    Hello NRITV,

    Thanks for your post.

    This would be the expected behavior when manually placing orders on the same instrument/account that the strategy is running on.

    NinjaScript strategies are intended to run without any manual intervention. NinjaScript strategies cannot see orders that are manually placed and they cannot see orders placed by other strategies.

    Manually placing orders on the instrument/account the strategy is running on will cause the strategy to become out of sync.

    The 1 L position you are referring to is a historically (virtually) calculated position when the strategy is enabled with 'Wait until flat' as the Start Behavior.

    When a strategy is yellow (or orange on some monitors) in the Strategies tab of the Control Center, this means that the strategy entered a historical (theoretical) position in the historical data that has been loaded.

    It also means that you have "Wait until flat" selected for the 'Start behavior' option in the strategy parameters.

    This means that once the strategy has finished processing the historical data and has transitioned to real-time, it will wait until there is a real-time order submission that will cause the strategy to become flat. This also includes changing from a long position to a short position or vice versa as the position would pass through flat.

    This also applies to secondary instruments if there are added series to the script. All positions must be flat before real-time orders will begin.

    You can change the start behavior to "Immediately submit" in the parameters of the strategy. Immediately Submit automatically submits working orders from when the strategy processed historical data, and assumes the strategy position and account position are where you want it when you enable the strategy. This is typically used to have a strategy resume a position after disabling/enabling. If the strategy already had live orders running, the orders will resume with the new enablement of the strategy if they match the historically calculated orders. If the orders calculated from historical data do not match the live working orders, the live working orders will be cancelled and replaced by those calculated from historical data.

    Sync Account Positions is an additional option that has NinjaTrader submit an order to sync the account position to the position calculated by the strategy. (Not the other way around.)

    If you do not want the strategy to calculate a position from processing historical data. Simple add if (State == State.Historical) return; to the top of your strategy logic so historical processing is skipped. The strategy will then always start from a flat position because it has not calculated any orders.

    See the help guide documentation below for more information.

    Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

    Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

    Additional information could be found in this forum thread - https://ninjatrader.com/support/foru...ion#post811541
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    58 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X