Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Re-sync with ninjascript

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

    Re-sync with ninjascript

    Hi,

    I run in many situations that can make my ninjascript strategy run out of sync with my account positions. The most problematic one is if I add to my position while the strategy is running, it does not update and I need to restart the strategy for that.

    Is there a way to re-sync the managed positions by ninjascript? If not it would be a great addition to the API.

    Thanks!

    #2
    Hello RT001,

    Thank you for your post.

    When you say "if I add to my position while the strategy is running, it does not update", are you manually sending orders while the strategy is running? If so, this would be expected. Strategies are self contained and are not aware of manual changes to the account position. Should you manually place a trade on the stame instrument and account combination, it would be expected that your account position and strategy position would become unsynchronized.

    I would recommend reviewing our section of the help guide on Account Position vs. Strategy Position:



    What we would recommend is if you're going to be running a strategy but want to also be able to manually add to the strategy's position, that you add logic to the strategy itself to add buttons to the chart or to the ChartTrader panel that submit orders when clicked.

    This post has several examples of modifying the UI to add buttons:

    Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


    Please let us know if we may be of further assistance to you.

    Comment


      #3
      I noticed my NT doesnt have all the Start Behavior options as are in that help guide
      (like Adopt account position
      Synchronize all strategies)

      What kind of start behavior would I want to choose if I want to run the same strategy on different charts(different instruments) but same account? thanks

      This morning I was surprised when I started the strategy and it sold off all my long term stocks and canceled all my orders.
      Pretty aggressive

      Comment


        #4
        Hello ezrollin,

        Thank you for your reply.

        Adopt Account Position is only available for strategies specifically programmed to use it, so that's why you don't see it. Synchronize all Strategies is an option in the right click menu of the Strategies tab.

        Strategies should generally be run on instruments where the account is in a flat position. Wait until Flat and Immediately Submit would assume the account is in the same position the strategy has calculated. However, with Immediately Submit, any active orders on the account previously generated by the strategy that does not match an active strategy order will be cancelled. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued. The matching active orders on the account will then be mapped to the active strategy orders and any remaining active strategy orders that cannot be successfully paired will be submitted live and the strategy will begin managing your Strategy Position assuming your Account Position is in sync with it. Wait until Flat would just start submitting new orders after the next time the strategy calculates it should be in a flat position.

        Now, Wait Until Flat, Synchronize Account and Immediately Submit, Synchronize Account would be different, these would submit orders to bring your account in line with what the strategy expects. So, for example, Wait until Flat, Synchronize account expects your account and the strategy to both begin from a flat position, so it would submit an order to bring your account flat, and then submit orders after the strategy calculates it too would be in a flat state.

        Immediately submit, synchronize account would submit an order to bring your account to the position specified by the strategy that it would be in at that point and continue from there.

        The only option that would not cancel active orders or submit a synchronization order would be Wait Until Flat. However, if your actual position is not flat, the PnL will be off since you could be say, 3 short in your actual account, the strategy assumes the account is flat and submits an order for 3 long - so it thinks it's in a position and reports that PnL, but your actual overall position would be flat and that PnL reporting would not be accurate.

        Please let us know if we may be of further assistance to you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 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