Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange trade handling

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

    Strange trade handling

    NT support,
    I use what you call "Advanced Order Handling".
    I use 3 IOrders: EntryOrder, StopOrder and PTOrder.
    For longs I issue in OnBarUpdate() an EntryOrder=EnterLong(TradeQuantity, Name)
    Then in OnExecution() if Long:
    StopOrder = ExitLongStop(SLPrice, "Stop", Name)
    PTOrder = ExitLongLimit(PTPrice, "PT", Name)
    Those orders are executed and then canceled (see order_bug.txt). Why are they canceled and why the quantity is Zero.
    Second attempt :
    StopOrder = ExitLongStop(TradeQuantity, SLPrice, "Stop", Name)
    PTOrder = ExitLongLimit(TradeQuantity, PTPrice, "PT", Name)
    In this scenario (order_bug2.txt) The quantity is correct, but still cancellation.
    So now I do:
    StopOrder = ExitLongStop(0, true, TradeQuantity, SLPrice, "Stop", Name)
    PTOrder = ExitLongLimit(0, true, TradeQuantity, PTPrice, "PT", Name)

    The question is: Why exit orders are canceled and why do I need the quantity? and do I need the last overload or there is something other wrong?

    Baruch
    Attached Files

    #2
    Hello,

    Thanks for the forum post.

    Just to clarify:

    StopOrder = ExitLongStop(0, true, TradeQuantity, SLPrice, "Stop", Name)
    PTOrder = ExitLongLimit(0, true, TradeQuantity, PTPrice, "PT", Name)

    The last option you tried works without cancellation correct?

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      The last option you tried works without cancellation correct?
      Yes, but I thought that only entries are canceled on a new bar, not exits.

      Comment


        #4
        Hello,

        It also applies to exit orders as well.

        Also, these orders are meant to work in OnBarUpdate(), running outside of this may give you some unexpected cancellation timing.
        Last edited by NinjaTrader_Brett; 09-15-2011, 07:45 AM.
        BrettNinjaTrader Product Management

        Comment


          #5
          Hi Bret,
          Yes it applies to exits too. I had a blackout.
          For entering only OnBarUpdate(), please look at the example below.
          When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until

          Comment


            #6
            Rght however this uses the override that says to not cancel the order based off OnBarUpdate(). Which then works as you have confirmed and you dont run into the OnBarUpdate() cancellation issue.

            Thanks.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            77 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            45 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            27 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            63 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X