Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninja places order with label "Close position" by itself

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

    Ninja places order with label "Close position" by itself

    Hello,

    I know this could be difficult to explain but I have broken my head over this issue. There are quite a few details but overall how can this be?

    I have a fully scripted automated strategy.
    All my orders have names.
    How come, Ninja places an order with a name that doesn't even appear anywhere in my script "Close position"?
    Obviously at some point this really messes up the whole strategy.

    Has anyone come across a similar issue or can suggest anything? Thank you.

    #2
    Hello tradealgo,

    Welcome to the NinjaTrader forums!

    When calling an entry method in the opposite direction of your position this will cause your position to be reversed. NinjaTrader will automatically submit an order to close your existing position and then enter an order to enter you into the opposite position.

    This order will be named 'Close position'.

    Are you reversing your position in the strategy using the managed approach?



    As a heads up, if you exit and then call an entry method in the same run of OnBarUpdate, the OnPositionUpdate() will not have yet run and NinjaTrader will not have known that your position is closed. This will cause both actions to complete and end up sending 3 orders. The first order is the exit position from your exit method, the second order is to close the position from NinjaTrader automatically reversing your position, the third order is to enter you into the opposite position.

    The result is that either the script will double the quantity when it reverses or it will cause an overfill and stop the script.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      "As a heads up, if you exit and then call an entry method in the same run of OnBarUpdate, the OnPositionUpdate() will not have yet run and NinjaTrader will not have known that your position is closed. This will cause both actions to complete and end up sending 3 orders. The first order is the exit position from your exit method, the second order is to close the position from NinjaTrader automatically reversing your position, the third order is to enter you into the opposite position.

      The result is that either the script will double the quantity when it reverses or it will cause an overfill and stop the script."


      Hi, I need into OnBarUpdate, Exit, evaluate if I want Enter (sometimes it will be true, sometimes It will bew false) and Enter if finaly I want do it. Most of the time, It works fine but sometimes It do just you posted!

      I need a solution for this.

      Also, I don't understand why sometimes it works fine and sometimes it doesn't

      Thanks in advance

      Comment


        #4
        Hello JoseFRS,

        OnBarUpdate() is run from a data thread. As the bar updates OnBarUpdate() is run. In a separate thread orders are processed. As orders are processed this runs order methods such as OnExecution(), OnOrderUpdate(), and OnPositionUpdate().

        The position will not update until OnPositionUpdate runs.

        If you want to reverse a position, do not call an exit and an entry at the same time. Only call the entry and NinjaTrader will automatically reverse the position.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,266 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X