Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Orders in OrderState.CancelPending Should be Deletable

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

    Orders in OrderState.CancelPending Should be Deletable

    Scenario: A careful developer, trying to fully understand the platform and what the code produces may validly create Orders within an AddOn using, for example, Account.CreateOrder() for testing purposes with no intention of submitting the Orders because they are part of familiarisation and/or testing.

    If such Orders are created, when the AddOn is terminated, the Orders go into OrderState.CancelPending. This would be acceptable if one could easily remove such Orders, preferably by being able to Cancel them (although since they are already supposedly cancelled, this makes no sense) or actually deleting them. However, that appears to not be possible. It would be of little consequence if these Orders caused no discernible consequences other than appearing in logs or historical records.

    Unfortunately, such Orders do cause issues. First, they always appear in the Orders Grid. Since they were never intended to be submitted, this is at best a distraction, at worst, has the potential for erroneous actions because of a confusing display of multiple Orders that are no longer "genuine" mixed with genuine Orders that may be in the same OrderState but that have real issues.

    More particularly of concern, trying to disconnect a Connection to which the Account (in this case, a Simulation Account) for which the Orders were created, causes a popup Warning notification of the form "You have X active orders(s). Do you really want to disconnect?". This message is generated every time an attempt is made to disconnect from the Connection of the relevant Account. Shutting down and restarting NinjaTrader does not stop this from happening.

    I have read in other Forum posts that issues of this nature occur because all Orders that are created, even those not submitted, are entered into the NinjaTrader database and never deleted. This being so, the only way to remove such Orders is to clean re-install NinjaTrader or Reset the database. Both of these are not acceptable as "standard" ways to achieve this, since the consequences are far beyond the scope of just those Orders.

    It is entirely valid, I believe, to create such Orders in full expectation that they should be and can be easily deleted in a fully supported manner.

    Please advise on this matter.

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    From the description I could say that a possible solution is to use the addon state terminated to cancel the orders to prevent that from happening. If that is what you are already doing or If that is not a solution I would likely need to see a simple script that produces this result so that I can explore that further on my end.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, Jesse. I'll bear that in mind. If need be, I'll provide something you can test, but it really is as simple as a single invocation of Account.CreateOrder with any set of parameters that makes sense, then terminate the AddOn, in effect leaving the created Order for garbage collection.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello Jesse,

        I have the same issue. What function should be used to cancel the orders on the Terminated?

        Regards
        ulisesguerrero
        NinjaTrader Ecosystem Vendor - Thrifty Coders

        Comment


          #5
          These "stubborn" Orders are kept in the NinjaTrader db file (db\NinjaTrader.sdf).

          My solution is to replace the affected db file with one that does not have the problem. The file I use as the replacement is a copy of one created in a fresh install with all my configuration changes from the defaults, but with no trading activity. I save that "template" db file and replace the "live" file with a copy of it when I need to, based on testing and other activities that affect the live file to a point where I want to "clean" the live db file.

          Note that this approach removes all traces of activity in the db file other than what was done to generate the replacement db file used.

          This "solution" may or may not be suitable for your circumstances.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by junkone, Today, 11:37 AM
          2 responses
          14 views
          0 likes
          Last Post junkone
          by junkone
           
          Started by frankthearm, Yesterday, 09:08 AM
          12 responses
          43 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by quantismo, 04-17-2024, 05:13 PM
          5 responses
          35 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by proptrade13, Today, 11:06 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by love2code2trade, 04-17-2024, 01:45 PM
          4 responses
          35 views
          0 likes
          Last Post love2code2trade  
          Working...
          X