Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Placing multiple orders

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

    Placing multiple orders

    I have the following code. My buy order is being placed immediately, and I can see my sell order in the trace log, however the sell order does not show up in the ninja gui. Anyone know why?

    Code:
    [FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (Positions[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].MarketPosition==MarketPosition.Flat && Positions[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]].MarketPosition==MarketPosition.Flat)
    {
    LongEntry=EnterLongLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,myprice[/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"LEntry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
    ShortEntry=EnterShortLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]myprice[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"SEntry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
    } 
    [/SIZE][/FONT]

    #2
    You are likely running into one of these Internal Order Handling Rules: http://www.ninjatrader-support.com/H...verview36.html
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I don't see an answer from the link. I have EntriesPerDirection=1 and EntryHandling=UniqueEntries. My entries are both unique, and they are in opposite directions, so I don't understand why that wouldn't work.

      The link provided mentioned BarsInProgress, but since I am sending both orders on Instrument #1, I would think that if 1 goes they should both go.

      Comment


        #4
        Methods that generate orders (excluding market orders) to enter a position will be ignored if:
        • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
        This rule is in place to prevent the strategy from confusing itself about what position is open. Remember if you EnterLong and then EnterShort after you have a long position the EnterShort will automatically submit a Close position order on your long. This gets muddled up easily if you try to place two Enter limit orders in opposite directions.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          So how can I work around that?

          Comment


            #6
            Unfortunately you simply can't place simultaneous orders in opposite directions within the same strategy. The only workaround available is to create two identical strategies except for the order direction. Run both at the same time.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Help....

              how to add multiple targets to a strategy and add a trailing stop.

              Comment


                #8
                Please have a look at this sample here - http://www.ninjatrader.com/support/f...ead.php?t=3751

                You can either use the SetTrailStop() method, or adjust your SetStopLoss() values as needed -

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                574 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                333 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                553 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X