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

Internal Order Handling Rules look like applied to market order

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

    Internal Order Handling Rules look like applied to market order

    good day,

    i have error of "an Set() method to submit an exit order has been ignored. Please seach on the term"Internal order Handing Rules"
    I´ve seen relevant information. As far as :
    Note
    : These rules do not apply to market orders, such as ExitLong() or ExitShort().


    In my strategy i have just market orders, simpe EnetLong(),ExitLong().
    Also i have :

    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.UniqueEntries;

    But my orders have different names:
    EnterLong("first");
    EnterLong("second").


    if i leave just one EnterLong().There is no more error. But when i increase number of entries por direction with one EnterLong(), it also produces error log.
    What should i change?
    Last edited by margandi; 10-09-2019, 03:12 AM.

    #2
    Hello margandi,

    Below is a link to the help guide on Internal Order Handling Rules.


    With the error you have specified this would be related to using SetStopLoss(), SetTrailStop(), or SetProfitTarget().

    Set() methods that generate orders to exit a position will be ignored if:
    •A position is open 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
    •A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active

    Are either of these the case in your script?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      "A position is open 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."

      Could SetStopLoss() be treated as position in the opposite direction ?

      Comment


        #4
        Hello margandi,

        SetStopLoss() is a method that attaches an exit order to an existing position.

        A stop loss itself is not the actual position and is instead used to close the position. The position is the amount of contracts you have bought or sold. For example Long 2 would mean two contracts have been bought.

        If a Set() is called while there are other working orders (with the same signal name or no signal name) that order will be ignored.

        I was not able to confirm, are you calling a set method in your script?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          if (Close[1] > SMA1[1]
          && Wr[1] <-80
          &&( ATR_percentage(100,14)[1] >= Bollinger( ATR_percentage(100,14),1,100).Upper[1] || ATR_percentage(100,14)[1] <= Bollinger( ATR_percentage(100,14),1,100).Lower[1] )
          )

          {
          double splitRisk = xAccountSize *percentToRisk;
          double xTickValue=Instrument.MasterInstrument.PointValue;
          int sharesToBuy= (int)(splitRisk/(GetCurrentBid()*0.03* xTickValue ));
          Print("sharesToBuy"+sharesToBuy.ToString()); //Prints Shares to buy
          EnterLong(sharesToBuy,"First");

          }

          if (Position.MarketPosition == MarketPosition.Long
          && BarsSinceEntryExecution()>1
          && Close[1] > SMA1[1]
          && Wr[1] <-80
          )
          {
          double splitRisk2 = xAccountSize *percentToRisk;
          double xTickValue=Instrument.MasterInstrument.PointValue;
          int sharesToBuy2= (int)(splitRisk2/(GetCurrentBid()*0.03* xTickValue));

          Print("sharesToBuy"+sharesToBuy2.ToString()); //Prints Shares to buy
          EnterLong(sharesToBuy2,"Second");
          }

          if (Wr[0]>-30 || Close[0]<SMA1[0])
          {ExitLong("wr"," ");}


          if( Position.MarketPosition == MarketPosition.Long && Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency, Close[0])>1.5*ATR(14)[0])
          {
          if (High[0]+14* TickSize<High[1]
          && Low[0]+14* TickSize<Low[1]
          && Low[1] <Low[2]
          && High[1]<High[2]

          )
          {ExitLong("LL","");}
          }


          I call take profit and stop loss from state.configure
          else if (State == State.Configure)
          {
          SetStopLoss(CalculationMode.Percent, 0.03);
          SetProfitTarget( CalculationMode.Percent, 0.06);
          }

          its NOT multi time frame.

          and it has :

          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.UniqueEntries;
          Last edited by margandi; 10-11-2019, 06:06 AM.

          Comment


            #6
            Hello margandi ,

            Thanks for your reply.

            Based on the code you have displayed it is not obvious as to the issue.

            Is it possible that the error message you saw was actually from a different strategy? If there is doubt, please close all other strategies and test this strategy to see if the error message persists with this strategy.

            If the error message persists, please either attach your strategy file source code here or send it in to PlatformSupport[at]NinjaTrader[dot]com.

            The strategy file can be found in Documents>NinjaTrader8>bin>Custom>Strategies> and will have the name of the strategy with a .cs type.

            In addition, please identify the instrument, time frame and bar type such that we can replicate the issue on our end.

            if you send in the strategy, please include a link to this thread within the e-mail and mark the subject "Atten: Paul" ticket #2301874

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              unfortunately, this error from that strategy.There is the same error on any symbol, lets say for instance ES 12-19.
              1 day time-frame..
              Attached Files

              Comment


                #8
                Hello margandi,

                Thanks for your reply.

                In looking through your code I do not see anything specific. I tried to run the strategy in the strategy analyzer however I do not have the Bear method or the ATR_Percentage. I commented out lines 125 and line 127 where these methods are referenced and recompiled without errors. I ran the strategy on ES 12-19 in the strategy analyzer from November 2014 until today, using daily bars as you directed. No errors were produced. I do see first and second trades on the chart.

                Can you try and reproduce on your end by commenting out lines 125 and 127? I don't see any linkage between the Bear() and ATR_Percentage as it relates to the stop level so I do not believe that is the issue but I am curious if you can reproduce the error without those lines.

                Without those lines, can you provide a specific set of circumstances that consistently generate the error?
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by margandi View Post
                  unfortunately, this error from that strategy.There is the same error on any symbol, lets say for instance ES 12-19.
                  1 day time-frame..
                  Whereas this is very poorly worded and circularly contradictory, the idea is that one cannot use both Exit() methods and Set() methods in the same Strategy script.

                  Support, please ask your Documentation team to word this better: this writeup implies that all exit orders will be ignored, as that is the only way that the statements can be simultaneously true.


                  Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded.jpg
Views:	645
Size:	68.9 KB
ID:	1074337

                  Comment


                    #10
                    Hello koganam,

                    Thanks for your reply.

                    From the example highlighted, a set method to exit a position (SetStopLoss, SetTrailStop, SetParabolicStop) would be ignored if a position exists and a non market order type is used, the ExitLongLimit() is shown as an example. Is the concern here that we need to explicitly say "does not apply to market order type such as ExitLong() and ExitShort()?

                    Can you provide an example of the wording that makes sense to you?
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      hello,
                      lines 125 and 127 dont provide that error. If script is run from 2014,there is no error, but try run it from 2005, and 28/11/2006 you Will have it.

                      In CL 12-19 there is no error in anytime. But In DOW30 depends on symbols there are a lot of "an set method an exit order at xx/xx/xxxx has been ignored"

                      P.S. if i delete the second enterlong(),there are no more errors. But i dont understand why and how to solve it.

                      Thanks.
                      Last edited by margandi; 10-15-2019, 03:01 AM. Reason: addiding info

                      Comment


                        #12
                        Hello margandi,

                        Thanks for your reply.

                        If you add print statements to each of your EnterLong and ExitLong sections what you will find, on the date(s) where you see the error, is that your coding is issuing Enterlong, Enterlong, and ExitLong at the same bar and this is causing the issue with the Set methods. The Set method is ignored because the positions are getting closed out by the Exit method which is exiting all positions. You would need to change your coding to prevent this (issuing Enterlong,Enterlong, and ExitLong at the same bar) from occurring.

                        "if i delete the second enterlong(),there are no more errors. But i dont understand why ", By not using a second entry the set methods are not trying to deploy for that 2nd entry at the same time the code was issuing ExitLong, so deleting the second entry prevents the condition that causes the Set methods to be ignored.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_PaulH View Post
                          Hello koganam,

                          Thanks for your reply.

                          From the example highlighted, a set method to exit a position (SetStopLoss, SetTrailStop, SetParabolicStop) would be ignored if a position exists and a non market order type is used, the ExitLongLimit() is shown as an example. Is the concern here that we need to explicitly say "does not apply to market order type such as ExitLong() and ExitShort()?

                          Can you provide an example of the wording that makes sense to you?
                          I do not mean to wax pedantic, but let us look at some things that make little sense, logically and sometimes grammatically.

                          Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded1.png
Views:	519
Size:	14.4 KB
ID:	1074723
                          Exit orders are not used to enter a position in any direction. The statement already is confusing, both in its logic, and its grammar: to which of the preceding orders, does "the order" in "the order is used to open a position in the opposite direction" refer?

                          If this section is meant to refer to entry orders that attempt to reverse the position, and hence automatically generate exit orders, then that is what is to be said. However, that has already been said in the paragraph that precedes the quoted paragraph, which would effectively make this statement redundant.

                          Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded2.png
Views:	519
Size:	141.0 KB
ID:	1074724
                          Really? So I cannot override the exit with a market exit order? If I can, then maybe, you want to explicitly let me know. This says that even an ExitLong() will be ignored in the situation.

                          Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded3.png
Views:	558
Size:	230.6 KB
ID:	1074725
                          Quite separate from the issue of "exit orders not being used to make entries", the highlighted bullets are exactly the same, so, using the text of the section itself, logically if "A position is open 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", then Exit orders will be ignored and Set() method orders will also be ignored. Is it really true that there would be no way to exit the position, as this argument then implies?

                          Click image for larger version

Name:	NT8ManagedApproahPoorlyWorded4.png
Views:	531
Size:	238.4 KB
ID:	1074726

                          These 2 highlighted sections imply that if I have Set() orders and ExitLongLimit() both coded, there is no way to exit the position, as they will both effectively be ignored. Is it even possible to simultaneously have ExitLongLimit() and Set() orders placed? If not, then you might want to clearly state what would happen if there is an attempt to place both.

                          That being said, is this whole section not redundant? It seems to have been misworded, but was intended to refer to order methods that automatically generate exit orders as part of their operation; such as orders that are intended to reverse the position. If so, that is already handled very clearly in the preceding paragraph. At best, all that might be required is to explain what situations will automatically generate exit orders. Even that should properly belong to a different section, I should think.

                          Comment


                            #14
                            Hello koganam,

                            Thanks for your reply.

                            Pedantic or not we always appreciate your feedback and insight.

                            I will provide this thread to our help guide group for their review.

                            Again, thank-you for taking the time and effort to clarify.




                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_PaulH View Post
                              Hello margandi,

                              Thanks for your reply.

                              If you add print statements to each of your EnterLong and ExitLong sections what you will find, on the date(s) where you see the error, is that your coding is issuing Enterlong, Enterlong, and ExitLong at the same bar and this is causing the issue with the Set methods. The Set method is ignored because the positions are getting closed out by the Exit method which is exiting all positions. You would need to change your coding to prevent this (issuing Enterlong,Enterlong, and ExitLong at the same bar) from occurring.

                              "if i delete the second enterlong(),there are no more errors. But i dont understand why ", By not using a second entry the set methods are not trying to deploy for that 2nd entry at the same time the code was issuing ExitLong, so deleting the second entry prevents the condition that causes the Set methods to be ignored.
                              The second entry schould not be exucuted on the same bar because of BarsSinceEntryExecution>1, >2...>10when its >10, there s no error since thereis no second entry..
                              Exit at the same bar should be if conditions for exit are met by my logic...

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              45 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              181 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X