Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inside bar order system

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

    Inside bar order system

    I'm trying to implement an automated order entry system in Sim mode for now. If an inside bar is created, send two orders based on the most recent bar, enter long with a stop limit at the high + 1 tick of the most recent bar (inside bar), and enter short stop limit at the low -1 tick of most recent bar (inside bar). When I apply this to a symbol, the long entry order works perfect, but the short entry order is not generated. Is Ninja limited to entering only one order based on a condition? How should I fix this? Below is the code for the conditions and order entry.

    // Condition set 1
    if (High[0] <= High[1]
    && Low[0] >= Low[1])
    {
    EnterLongStopLimit(DefaultQuantity, High[0] + 1 * TickSize, High[0] + 1 * TickSize, "");
    EnterShortStopLimit(DefaultQuantity, Low[0] + -1 * TickSize, Low[0] + -1 * TickSize, "");
    }
    }

    #2
    Hello Marshmellowhead,

    Your results are expected with the managed order system. Please see our for our Internal Order Handling rules. I have excerpted the rule you're running into.

    Methods that generate orders to enter a position will be ignored if:
    • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
    • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
    • The entry signal name is not unique
    • 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
    We introduced an unmanaged order entry system in version 7 that allows you to submit both long and short orders at the same time. Please see here for an introduction to unmanaged strategies.
    http://www.ninjatrader.com/support/helpGuides/nt7/unmanaged_approach.htm
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      OK, I'll try simply putting the following in my code and see if that works.

      Unmanaged = true;

      Will the code change take immediate affect, or do I have to toggle the strategy on/off or anything?
      In the control center view, I have the same strategy applied to 4 symbols. Under the "Strategy" tab, some are highlighted in Yellow, others green. What does this mean?

      Comment


        #4
        OK, well simply adding that line didn't work. How do I figure out why the strategy doesn't work on one chart which is highlighted in yellow in the control panel?

        Comment


          #5
          You'll have to do more than place Unmanaged = true in your Initialize method.

          You can't combine managed order methods like EnterLong(), ExitShort() with unmanaged order methods. Unmanaged order methods use SubmitOrder() for all order submission.

          There's also a lot going on under the hood with the managed order system that you'll be responsible for with an unmanaged system.

          Please review the following page ->

          Critical considerations when using Unmanaged order methods
          http://www.ninjatrader.com/support/helpGuides/nt7/unmanaged_approach.htm

          Will the code change take immediate affect, or do I have to toggle the strategy on/off or anything?
          You must remove and reapply any instances of the strategy after making code changes.

          In the control center view, I have the same strategy applied to 4 symbols. Under the "Strategy" tab, some are highlighted in Yellow, others green. What does this mean?
          Green highlighted cells indicate a currently running strategy.
          Yellow highlighted cells indicate the strategy is waiting until it reaches a flat position to be in sync with the account position before fully starting. (Please see the options Strategies Tab section for configuration options.)
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Can "Submit Order()" be created using the Wizard, or do I have to do it manually within the code?

            Comment


              #7
              SubmitOrder and unmanaged systems require working with code directly. These methods are not available with the strategy wizard.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                I have the following two lines for Order submission:

                SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, 1, High[0] + 1 * TickSize, High[0] + 1 * TickSize, 0, "IB long");
                SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, Low[0] + -1 * TickSize, Low[0] + -1 * TickSize, 0, "IB short");

                I'm getting "invalid argument ' errors for these statements. Can I have arguments like High[0] +... or do I need to use a variable?

                Comment


                  #9
                  You can use values like High[0] in these methods.

                  You're seeing an issue for specifying a value of 0 for string field OCOid.

                  You can use an empty string here if you don't want any OCO handling between the orders.

                  Code:
                   
                  SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, 1, High[0] + 1 * TickSize, High[0] + 1 * TickSize, [COLOR=red][B]""[/B][/COLOR], "IB long");
                  SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, Low[0] + -1 * TickSize, Low[0] + -1 * TickSize, [COLOR=red][B]""[/B][/COLOR], "IB short");
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Is High[0] + 1 * tick size acceptable?
                    I'm basically bracketing the last bar with two orders and if one gets triggered, i want the other cancelled. How do I do that using the OCO id field?

                    Comment


                      #11
                      Yes, High[0] + 1 * TickSize is acceptable.

                      To tie two orders together as OCO, use the same string in both.


                      Code:
                       
                      SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, 1, High[0] + 1 * TickSize, High[0] + 1 * TickSize, "EntryOrders", "IB long");
                      SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, Low[0] + -1 * TickSize, Low[0] + -1 * TickSize, "EntryOrders", "IB short");
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        OK, thanks. It compiles now, but it doesn't generate any orders when it sees an inside bar.

                        Comment


                          #13
                          Are you sure the condition is triggering at all? Please add Prints or drawing objects for a quick visual check to confirm the condition would indeed work as you would expect.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Ok, well I redid the strategy, added a print statement, but now I can't enable it. It compiles. I've attached the script. Can someone advise me exactly where to put the "Unmanaged = True;" statement.
                            Attached Files

                            Comment


                              #15
                              protected override void Initialize()
                              {
                              Unmanaged = true;
                              }
                              Ryan M.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gbourque, Today, 06:39 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post gbourque  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              1 response
                              17 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by benmarkal, Yesterday, 12:52 PM
                              3 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by helpwanted, Today, 03:06 AM
                              1 response
                              20 views
                              0 likes
                              Last Post sarafuenonly123  
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Working...
                              X