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

Pending orders from SubmitOrderUnmanaged() are not always shown in SuperDOM

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

    Pending orders from SubmitOrderUnmanaged() are not always shown in SuperDOM

    Hi, Support,

    I built a small program to test SubmitOrderUnmanaged(). If my account is flat, call SubmitOrderUnmanaged(...,OrderAction.Buy,..) to buy 100 shares of IBM stocks, if my account has positions as 100 share of IBM stocks, it calls SubmitOrderUnmanaged(...,OrderAction.Sell,..) to sell them.

    When I send a limited buy order, the order can be shown in SupreDOM as my bid price is lower than market price for sometime.
    But when I send a limit sell order, it doesn't shown in SuperDOM. Can you tell the reason?

    My sell order price is 0.1 higher than market price, so it should be pending for some time before it is executed.


    protected override void OnBarUpdate()
    {
    Print ("need_flat =" + need_flat);
    if (need_flat)
    {
    Print ("Current Price = " + GetCurrentAsk());
    myExit = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, 100, GetCurrentAsk() + 0.1, 0, "", "Buying 100");
    Print (" myExit ======= " + myExit);
    // this print shows outputs.
    need_flat = false;
    first_time = false;
    }

    Print ("first_time =" + first_time);
    if (first_time)
    {
    myEntry = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, 100, GetCurrentBid() - 0.1, 0, "", "Buying 100");
    first_time = false;
    Print (" GetCurrentBid() = " + GetCurrentBid() + "myOrder = " + myEntry);
    need_flat = false;
    }
    }



    Current Price = 123.06
    myExit ======= orderId='NT-00000-338' account='Sim101' name='Buying 100' orderState=Working instrument='IBM' orderAction=Sell orderType='Limit' limitPrice=123.16 stopPrice=0 quantity=100 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2020-09-23 15:56:10' gtd='2099-12-01' statementDate='2020-09-23'


    I also added onOrderUpdate(), it shows the sell order looks normal: orderState is changing from
    Submitted -> Accepted -> Working



    Last edited by localappleseed; 09-23-2020, 02:30 PM.

    #2
    Hello localappleseed,

    Thanks for your post.

    I am not seeing this behavior testing on my end. Please see the demonstration video below and attached script.



    Please let me know if you see the same symptoms testing the attached strategy on your end in the same way.

    You may also want to consider checking if the Sell Limit order is listed in the Orders tab of the Control Center, and if it is not (and your prints confirm the order submission method was reached) to retest with TraceOrders enabled for a hint on why the order would be ignored.

    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm

    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you very much Jim for your detailed answer with your proven testing. Your testing shows both buy/sell at the same time, which I can do as well. But my problem still exists.

      It looks like this is related to the procedures I am using.
      To make the same code even simpler, I manually bought 100 shares of IBM, so position/Strategy shows I have 100 shares. I run SubmitOrderUnmanaged to sell only (no longer using code to buy).

      Procedure 1 (working)
      manually bought 100 shares fromSuperDOM
      verified Positions that I have 100 shares
      Click "Strategies/NTMenu" -> right click to get "New Strategy" -> select "My Test" -> OK -> click "Enabled"
      SuperDOM shows my order

      Procedure 2 (not working)
      manually bought 100 shares from SuperDOM
      verified Positions that I have 100 shares
      Click "New" from NT8 Menu -> chart -> select IBM and use default 24x7 for Trading hours -. Click OK
      from Chart(IBM) I can see previous bought IBM 100 shares -> right click and select "Strategies" ->
      select "My Test" -> select "Enabled" -> Click OK

      SuperDOM doesn't show my order.

      For both procedures, onOrderUpdate() show no difference, both show OrderState is changing from Submitted->Accepted -> Working.

      So loading my Strategy through chart is not working, why?




      Last edited by localappleseed; 09-24-2020, 08:56 AM.

      Comment


        #4
        Hello localappleseed,

        I have not been able to reproduce these symptoms.

        Do you have "Display Selected ATM strategy only" in the SuperDOM Properties and do you have an ATM strategy selected in the ATM strategy Selector when you witness this behavior?

        If this is not the case, can you modify my strategy or attach an export of a barebones script and some steps I can take to quickly reproduce these symptoms? I could not reproduce with my script following your steps and I do not have your test script to reproduce. I would need an export of a reduced script and steps to investigate further.

        I look forward to assisting.


        JimNinjaTrader Customer Service

        Comment


          #5
          Do you mind running my code which is extremely short? I attached whole code and test steps which show both successful and failed results.

          In both failed and successful cases, I selected "Adopt Account Position" in their Starting Behavior of the Strategy.
          Attached Files
          Last edited by localappleseed; 09-24-2020, 02:43 PM.

          Comment


            #6
            Thanks localappleseed,

            I'm heading out the door for the day, but I will reply back tomorrow after testing.

            Have a good rest of your day!
            JimNinjaTrader Customer Service

            Comment


              #7
              No problem and thank you.

              Comment


                #8
                Hello localappleseed,

                I have tested to reproduce following the steps that "Should work" and I have not been able to see issues where the order is not seen when it otherwise should be, because the order is not submitted. I have an AdoptAccountAware example strategy that is working in these cases, however.

                Demo - https://drive.google.com/file/d/1Na3...w?usp=drivesdk

                I have attached my example strategy here so you may compare on your end. Everything is working as I would expect with my example. If there is something that I am missing with the steps I took, could you clarify?

                I look forward to assisting.
                Attached Files
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Kaledus, Today, 01:29 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by frankthearm, Yesterday, 09:08 AM
                13 responses
                45 views
                0 likes
                Last Post frankthearm  
                Started by PaulMohn, Today, 12:36 PM
                2 responses
                16 views
                0 likes
                Last Post PaulMohn  
                Started by Conceptzx, 10-11-2022, 06:38 AM
                2 responses
                55 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                Started by yertle, Yesterday, 08:38 AM
                8 responses
                37 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Working...
                X