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

Calculation in OnExecutionUpdate wrong due ignored SubmitOrderManaged()

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

    Calculation in OnExecutionUpdate wrong due ignored SubmitOrderManaged()

    Hello,

    I'm doing some position quantity calculation in OnExecutionUpdate.

    Now I'm trying to identify, why in some scenarios masterStrategy.Position.Quantity is different from my calculation that is basically doing the following:

    CurrentPositionSize= volume + CurrentPositionSize;
    or
    CurrentPositionSize= volume - CurrentPositionSize;


    I found some : Ignored SubmitOrderManaged() .
    Think OnExecutionUpdate is entered before Ignored SubmitOrderManaged() is raised?
    Can I catch these Ignored SubmitOrderManaged() on any way?

    (Of course I'll try to identify also, why these Ignored SubmitOrderManaged() are raised but here I only want to prevent, that my calculation is getting wrong.

    Thanks in advance.

    #2
    Hello Airwave,

    Thanks for your post.

    The Position object is updated based on Execution events and updated as early as OnExecutionUpdate. What is the context of using "masterStrategy.Position.Quantity?" This does not sound like a typical use of a NinjaScript strategy.

    Managed Approach orders would be ignored if we break an internal rule of the Managed Approach, or try to Exit a quantity that is greater than the strategy's Position (which is calculated from execution's.)

    Internal Rules - https://ninjatrader.com/support/help...d_approach.htm

    It is also unclear on your use of "volume" and "CurrentPositionSize"

    Could you further describe what you are trying to accomplish and show what you are attempting? It helps us best if you can provide an example that shows what you are doing in simple terms.

    Exporting as source code - https://ninjatrader.com/support/help...tml?export.htm

    We look forward to assisting.

    JimNinjaTrader Customer Service

    Comment


      #3
      Hello,

      I found the issue and it was totally different from what I thought before.



      When I create some Limit orders that are pending and waiting for execution and then execute in between such a lot market orders (all orders limit and market in same direction e.g. Short) that the Position.Quantity reaches Int32.MaxValue then the Position.MarketPosition turns (e.g from Short to Long) when the limit orders get executed.

      Think this is a bug in an edge case szenario.

      Cheers

      Comment


        #4
        Hello Airwave,

        This sounds like a very particular situation to set up.

        If you can illustrate ill behavior in a small example, we could use that to review and see if we are looking at a bug.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Karado58, 11-26-2012, 02:57 PM
        8 responses
        14,828 views
        0 likes
        Last Post Option Whisperer  
        Started by Option Whisperer, Today, 09:05 AM
        0 responses
        1 view
        0 likes
        Last Post Option Whisperer  
        Started by cre8able, Yesterday, 01:16 PM
        3 responses
        11 views
        0 likes
        Last Post cre8able  
        Started by Harry, 05-02-2018, 01:54 PM
        10 responses
        3,204 views
        0 likes
        Last Post tharton3  
        Started by ChartTourist, Today, 08:22 AM
        0 responses
        6 views
        0 likes
        Last Post ChartTourist  
        Working...
        X