Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy and sell futures strategy (2 positions)

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

    Buy and sell futures strategy (2 positions)

    I know in version 6 it is not possible to have a strategy enter long and short at the same time. I have searched the forums and heard talk of this being a possibility in the future, has it been implemented in v7?

    I'm not looking to do a strangle where I go long if the market moves up and short if it goes down.

    I want to enter both directions at the same time. (thought being tight stop on both directions, one gets stopped and hopefully the market keeps going) My primary reason for wanting this in one strategy is so that I may test how its equity curve compares to picking one direction.

    #2
    shazzmoe, correct this has been implemented in NinjaTrader 7 with by offering the unmanaged order submission mode in strategies - http://www.ninjatrader.com/support/h...d_approach.htm

    Here the internal order handling rules are not effective and you have the ultimate flexibility in managing your trades.

    Comment


      #3
      Will this be able to post results in the strategy analyzer?

      when i've replaced

      EnterLong(Quantity, "Long1");

      with

      entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, Quantity, 0, 0, "", "Enter Long");

      The analyzer no longer displays trades. Am I to assume SetStopLoss and SetProfitTarget no longer work and an exit order must be submitted?

      Comment


        #4
        You should still be able to backtest in the Strategy Analyzer, however in this mode there's no signal tracking done by NT (as otherwise the Internal Order Handling Rules would be back) - the Set methods can't be used correct, you can use SubmitOrder, CancelOrder and ChangeOrder for the order management.

        Comment


          #5
          Thanks for the help so far, but how do I prevent orders from canceling each other out? In the following code how would I stop the entryOrderShort from being exited by the entryOrderLong ?

          I'm just trying to test out how to enter the market both directions at the same time with each direction having its own stop/target.

          Code:
          protected override void OnBarUpdate()
          {
              if(Bars.FirstBarOfSession){
                  entryOrderShort = SubmitOrder(0, OrderAction.SellShort, OrderType.Market, Quantity,  0,  0, "shortS", "Enter Short");
                  entryOrderLong = SubmitOrder(0, OrderAction.Buy, OrderType.Market, Quantity, 0, 0, "longS", "Enter Long");
              }
          }
          protected override void OnOrderUpdate(IOrder order)
          {
              if(order == entryOrderShort){
                  stopOrderShort = SubmitOrder(0, OrderAction.BuyToCover, OrderType.Stop, Quantity, 0, (Close[0]  + 8 * TickSize), "shortSide", "Stop Short");
                  targetOrderShort = SubmitOrder(0, OrderAction.BuyToCover, OrderType.Limit, Quantity, (Close[0]  - 76* TickSize), 0, "shortSide", "Target Short");    
              }
              else if(order == entryOrderLong){
                  stopOrderLong = SubmitOrder(0, OrderAction.Sell, OrderType.Stop, Quantity, 0, (Close[0] - 8 * TickSize), "longSide", "Stop Long");
                  targetOrderLong = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, Quantity, (Close[0]  + 76* TickSize), 0, "longSide", "Target Long");
              }
          }

          Comment


            #6
            Hello shazzmoe,

            With unmanaged orders, it does not mean that you can simultaneously hold long and short positions in the same account. Your net account position will always be reflective of the activity submitted to the account.

            One Buy Order + One Sell Order = flat account.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ok well then there must have been a misunderstanding as that was my original question. Thank you for the update. I had thought maybe it was possible since you can with ATM strategies.

              Comment


                #8
                shazzmoe - for the ATM's this is also just visual, when you're net flat in the account - you're net flat, same would be true for a NinjaScript strategy as the overall strategy position (combined) matters. If you like to see each position play out, it's easiest to split it to 2 strategies.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X