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

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 -

                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Skifree, Today, 03:41 AM
                0 responses
                1 view
                0 likes
                Last Post Skifree
                by Skifree
                 
                Started by usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                23 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                22 views
                0 likes
                Last Post Pattontje  
                Working...
                X