Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

All actions from one strategy, yet becomes out of sync?

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

    All actions from one strategy, yet becomes out of sync?

    All signals/actions come from the one and only strategy running, account is flat to begin with, yet strategy position and account position become out of sync?

    This is driving me nuts. I know all about the start behaviors of the strategies and the difference between account position and strategy position, but I cannot identify what is causing this behavior.

    I have a strategy that initiates, at most, 5 entries in a direction and only operates in one direction at a time. All of the entries have unique names because I include a 5-digit random number with every signal I send the strategy. This strategy develops no signals of its own and instead simply operates as a landing platform for the signals sent from a Python script that is running on the same PC locally. So a message is sent to it, it figures out what the message wants it to do, and then it places the order with the information in the message.

    Here's the thing... when I look at the Orders tab in NinjaTrader, and there's a column that shows which strategy each action is "from" - sometimes the actions coming from the strategy do not have the name of the strategy in that column, sometimes it's blank. I have no clue why.

    Also, there is no pattern that I can identify from this behavior. There's not an entry that this happens with or doesn't happen with all the time. The strategy always starts out in-sync with account, and has the value of "True" for that.

    Below are my starting settings - I have changed Entry Handling, but both settings have the same effect. Can anyone point me in the right direction to make sure things stay in-sync? I can also provide more information if-needed.
    Last edited by Trueglory; 09-13-2024, 10:40 AM.

    #2
    I still need help with this. Not only the problem stated in the original post but also, it seems that my entries apply to the strategy position inconsistently. Sometimes an entry generated within the strategy only applies to the account position and not the strategy position, and other times it applies to both. I have an idea that this is due to latency and how I have these entries coded, but I still could use someone pointing me in the right direction.

    Comment


      #3
      Hello Trueglory,

      Thank you for your post.

      This behavior is expected if you are using both Enter/Exit methods and also placing orders directly to the account using Account.Submit(). The strategy position is separate from the account position, so it only sees the orders placed using Enter/Exit methods and not orders placed directly to an account using Submit().

      If you want the strategy and account position to match you should use only Enter/Exit methods within your logic.

      Comment


        #4
        Originally posted by NinjaTrader_Gaby View Post
        Hello Trueglory,

        Thank you for your post.

        This behavior is expected if you are using both Enter/Exit methods and also placing orders directly to the account using Account.Submit(). The strategy position is separate from the account position, so it only sees the orders placed using Enter/Exit methods and not orders placed directly to an account using Submit().

        If you want the strategy and account position to match you should use only Enter/Exit methods within your logic.
        Yes, I understand this and have changed the methods used to reflect what you are saying, but still, when using EnterLong() and EnterShort(), I enter 1 quantity at a time and when initiated it inconsistently applies to both account position and strategy position. Sometimes it does and sometimes it does not. What would cause this behavior? btw, thank you for your reply.

        Comment


          #5
          Rithmic and Interactive Brokers Users: When using a NinjaScript strategy it is best practice to only work with passed by value data from OnExecution. Instances of multiple fills at the same time for the same instrument might result in an incorrect OnPositionUpdate, as sequence of events are not guaranteed due to provider API design.
          I found this on the OnExecutionUpdate() page. Could all these problems be caused by me using Rithmic? And in this case, how can I maintain accurate position updates?

          Comment


            #6
            Hello Trueglory,

            Are you running any other strategies on the same account and instrument?

            Or, are you placing any manual orders at the same time the strategy is running?

            With Rithmic you will still get position updates, however the disclaimer is stating there is no guaranteed order in which OnOrderUpdate, OnPositionUpdate, and OnExecutionUpdate will fire when using Rithmic. It is best for your strategy not to rely on position updates for its logic. However, I don't believe this would affect the strategy position vs account position.

            Comment


              #7
              Originally posted by NinjaTrader_Gaby View Post
              there is no guaranteed order in which OnOrderUpdate, OnPositionUpdate, and OnExecutionUpdate will fire when using Rithmic.
              If this is true, how do I know when the prior action/execution is completed before starting another action? Which is essentially what I need. Because I think there are timing issues happening. For example, because I am limited to 5 contracts, and will get an error if I exceed 5. If I enter 5 contract long position, with a limit order for the profit target and a stop market for the stop loss, Trying to close this position with a 5 quantity market sell order will give me an error because I have the 5 contract limit sell order for the profit target in place, it thinks I'm at my 5 contract limit with long direction. Therefore, I need to cancel the limit order, make sure its finished executing, and then sell.

              Comment


                #8
                Hello,

                I recommend taking a look at our Rithmic/IB Friendly example scripts to help navigate submitting orders if Rithmic is your data provider:

                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