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

OnExecutionUpdate oddity

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

    OnExecutionUpdate oddity

    Hello,

    I noticed this during some testing.

    I added an OnExecutionUpdate handler to an indicator, as I have done before. This works perfectly well when orders are executed for the most part, but I noticed an oddity when testing with the 'Order Ticket' window.

    Assume my OnExecutionUpdate function simply prints e.Execution.ToString(); The indicator does nothing else. If I buy and sell via any chart window using charttrader, this works fine. I see the indie print of the execution lines.

    Now, If I try to sell via the Order Ticket window, assuming I have no existing position, this works fine, too. As expected. But, if I start with a buy and no initial position, OnExecutionUpdate never fires. It does for the closing sell order.

    Click image for larger version  Name:	image.png Views:	0 Size:	25.1 KB ID:	1216889

    In fact, I can click buy from flat multiple times and OnExecutionUpdate does not fire. The moment I hit sell, it does. This ONLY happens from the 'Order Ticket' window. If I hit buy or sell from ChartTrader buttons, works as expected. Given the latter works and my code is just doing the aforementioned dump of the string, I cannot imagine it is code related.I would add that the DOM buy and sell buttons work exactly as expected, also. It only happens with the order Ticket window. NT8 ver is 8.0.26.1 64-bit

    Is this a known 'feature'? Are my expectations incorrect?

    Thanks.​

    #2
    Originally posted by pjsmith View Post
    Assume my OnExecutionUpdate function simply prints e.Execution.ToString(); The indicator does nothing else.
    Any chance this little gem can become attached to this little thread?



    Comment


      #3
      Hello pjsmith,

      Thank you for your reply.

      Are you submitting a market buy order, or a limit buy order in the Order Ticket window? I wouldn't expect to see OnExecutionUpdate run for a limit order until it actually fills.

      Thanks in advance, I look forward to assisting you further.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Hi Kate - Thanks for the reply. Buy Market and Sell Market only during testing with the buttons. No limits.

        Comment


          #5
          Hello pjsmith,

          Thank you for your reply.

          I ask, because your screenshot above shows the order type set to Limit. Here's a quick video of what I see when the attached test indicator is applied to a chart and a market order is submitted using the Order Ticket window to the Sim 101 account:

          https://www.screencast.com/t/pegt4rYa8r4y

          Do you see the same with the test indicator, ensuring that Market is selected in the Order Type dropdown?

          Thanks in advance; I look forward to assisting you further.
          Attached Files
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Kate View Post
            I might suggest moving everything dealing with Account in State.Default to any other State past..
            Then just make sure to null check your account object before event disposal in State.Terminated..

            Some other useful general information you can grab from your account:
            Code:
            realizedPnL    = acc.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
            cashValue    = acc.Get(AccountItem.CashValue, Currency.UsDollar);
            Some other useful Instrument Specific information you can grab from your account:
            Code:
            tradeCount = acc.Executions.Where(x => x.Instrument == Instrument && (x.IsEntry || x.IsEntryStrategy)).Count();
            
            foreach (Position pos in acc.Positions)
            {
                 if (pos.Instrument == Instrument)
                 {
                      isPositionIn = true;
                      isPositionLong = pos.MarketPosition == MarketPosition.Long;
                      posAvgPrice = pos.AveragePrice;
                 }
            }





            -=Edge=-
            NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

            Comment


              #7
              Kate - I owe you an apology for wasting your time! I have just retested and it works. I was getting fills the other day, so I am a bit confused (limit would just sit there, unfilled). I will test further, but it looks like the mistake may be my side

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by LavniaCardos, Today, 02:32 AM
              0 responses
              1 view
              0 likes
              Last Post LavniaCardos  
              Started by pstrusi, 11-13-2022, 05:23 PM
              23 responses
              398 views
              0 likes
              Last Post pstrusi
              by pstrusi
               
              Started by Murphy67, Today, 01:10 AM
              2 responses
              12 views
              0 likes
              Last Post DiverG20  
              Started by DiverG20, Today, 02:01 AM
              0 responses
              4 views
              0 likes
              Last Post DiverG20  
              Started by AlexEro, Today, 12:29 AM
              0 responses
              8 views
              0 likes
              Last Post AlexEro
              by AlexEro
               
              Working...
              X