Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execution system development

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

    #16
    stefy,

    You will need to debug it then. Use print functions throughout your code and track the state of your bool. Also, look in Control Center for errors and use TraceOrders = true to see if your orders are being rejected for some reason.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      I run a backtest since 1/1/08 and after few trades it stops to trade.
      Running it for the current month alone, it doesn't.
      I don't get any warnings though.
      I tried to run the strategy in real time and I got "An Enter() method to submit an entry order at '16/09/2008 0.24.00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation."

      I looked it up but I didn't find any help.

      Thank you

      Comment


        #18
        Hi stefy,

        These may be two possible rules you are violating:

        Methods that generate orders (excluding market 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

        Methods that generate orders to exit a position will be ignored if a strategy position is open and:
        • An order submitted by an enter method (EnterLongLimit() for example) is active and this entry order is used to open a position in the opposite direction
        Those apply if you are submitting reversal orders. Otherwise you may be hitting the Set() order handling rules. Depending on how your overall code is, I cannot comment on which rule you are hitting exactly.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          I'm not submitting reversal orders.
          My strategy can simply go Long or Short.
          It has Stop Losses and Profit Targets.

          It looks like a lot of code, but it's very repetitive:
          // Entry Long Condition


          {

          if (Bars.PercentComplete <= 0.8
          && traded == false)
          {
          EnterLongLimit(0, true, Position.Quantity, Bid, "LongLimitBid");
          traded = true;
          }

          if (Bars.PercentComplete > 0.8
          && Bars.PercentComplete <= 0.9
          && traded == false)
          {
          EnterLongLimit(0, true, Position.Quantity, Instrument.MasterInstrument.Round2TickSize((Bid + Ask)/2), "LongLimitMidPrice");
          traded = true;
          }

          if (Bars.PercentComplete > 0.9
          && traded == false)
          {
          EnterLongLimit(0, true, Position.Quantity, Ask, "LongAsk");
          traded = true;
          }
          }


          // Entry Short Condition


          {
          if (Bars.PercentComplete <= 0.8
          && traded == false)
          {
          EnterShortLimit(0, true, Position.Quantity, Ask, "EnterShortAsk");
          traded = true;
          }

          if (Bars.PercentComplete > 0.8
          && Bars.PercentComplete <= 0.9
          && traded == false)
          {
          EnterShortLimit(0, true, Position.Quantity, Instrument.MasterInstrument.Round2TickSize((Bid + Ask)/2), "EnterShortLimitMidPrice");
          traded = true;
          }

          if (Bars.PercentComplete > 0.9
          && traded == false)

          {
          EnterShortLimit(0, true, Position.Quantity, Bid, "EnterShortLimitBid");
          traded = true;
          }

          // Exit Condition Long (requires traded == true and resets to traded = false)


          {

          if (Bars.PercentComplete <= 0.8
          && traded == true)

          {
          ExitLongLimit(0, true, Position.Quantity, Ask, "ExitLongLimitBid", "");
          traded = false;
          }

          if (Bars.PercentComplete > 0.8
          && Bars.PercentComplete <= 0.9
          && traded == true)

          {
          ExitLongLimit(0, true, Position.Quantity, Instrument.MasterInstrument.Round2TickSize((Bid + Ask)/2), "ExitLongLimitMidPrice", "");
          traded = false;
          }

          if (Bars.PercentComplete > 0.9
          && traded == true)

          {
          ExitLongLimit(0, true, Position.Quantity, Bid, "ExitLongLimitAsk", "");
          traded = false;
          }

          // Exit Condition Short


          {

          if (Bars.PercentComplete <= 0.8
          && traded == true)

          {
          ExitShortLimit(0, true, Position.Quantity, Bid, "ExitShortLimitBid", "");
          traded = false;
          }

          if (Bars.PercentComplete > 0.8
          && Bars.PercentComplete <= 0.9
          && traded == true)

          {
          ExitShortLimit(0, true, Position.Quantity, Instrument.MasterInstrument.Round2TickSize((Bid + Ask)/2), "ExitShortLimitMidPrice", "");
          traded = false;
          }

          if (Bars.PercentComplete > 0.9
          && traded == true)

          {
          ExitShortLimit(0, true, Position.Quantity, Ask, "ExitShortAsk", "");
          traded = false;
          }

          The same for Stop Losses (ExitLongLimit and ExitShortLimit with traded == true and new stamp traded = false).

          All the issues started to arise when I introduced the LiveUntilCancelled orders and the booleans.

          You say I may be hitting the Set() order handling rules: could you please elaborate on how it applies to this case?

          Thank you

          Comment


            #20
            No need to worry about the Set() methods. You are submitting reversal orders. When you have an open long position and then you submit an EnterShortLimit() that short order will think it will be reversing. It causes problems when you try to do that along with ExitLong methods. The exit method will try to close your position and the Enter short method will also try to close your long position. In the end it is very possible that you get a double fill where both exit and enter closed the long position leaving you with a short that is 2x in size. This is why we have the Internal Order Handling Rules. There is no way around them besides changing your strategy.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              I'm trading a breakout system.
              I want to go Long if it breaks out above a certain level, I want to go short if it breaks down below a certain (different) level.
              I do not want to reverse the trades: if I'm losing money, first the Stop Loss will kick in (flattening my position), then, eventually, I may enter a Short.

              What about just building a 1min array (assuming I'm working on 30min) with a new DataSeries with my limit prices and then using that as an input for my order, adjusting the limit order every minute?

              Thank you

              Comment


                #22
                stefy,

                I suggest you simplify your strategy as much as possible to start and then add complexity as you go. The problem is you cannot submit EnterShort__() methods while you still have an ExitLong___() order active. Likewise, you cannot submit EnterLong__() methods while you still have an ExitShort__() order active.

                A simple way to sidestep this is simply just to add the condition of Position.MarketPosition == MarketPosition.Flat to your entry conditions for both long and short orders.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                602 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                347 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                560 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                559 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X