Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Long short stop order coexisting?

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

    Long short stop order coexisting?

    I have the following code.
    The problem is the Short_Order never had any chance to be filled. I think it is actually been ignored by program.
    The funny thing is if I reverse the order of writing in the code, i.e define Short_Order first and then Long_order, as in the following commented out part, the opposite happens: short order filled and long order been ignored.

    I am wondering if I missed any setting and long / short stop order can not exist altogether?


    #region Variables
    private IOrder Long_Order = null;
    private IOrder Short_Order = null;
    #endregion

    protected override void OnBarUpdate(){

    Long_Order = EnterLongStop(0, true, Unit, Base_Entry_Price+ x, "L");
    Short_Order = EnterLongStop(0, true, Unit, Base_Entry_Price- x, "S");

    /*
    //this will let the short order be recognized, and long order been ignored.
    Short_Order = EnterLongStop(0, true, Unit, Base_Entry_Price- x, "S");
    Long_Order = EnterLongStop(0, true, Unit, Base_Entry_Price+ x, "L");

    */

    // other order to exit both the short and long position



    }

    #2
    Hello sunjoke399,

    Thank you for your post.

    Likely the EntriesPerDirection is set to 1. Both of your orders are enter long orders, so only 1 is permitted to be placed at a time. For information on EntiresPerDirection please visit the following link: http://www.ninjatrader.com/support/h...rdirection.htm

    Please let me know if you have any questions.

    Comment


      #3
      Thanks. That was actually a typo. In the actual code, it was long and short as the following.
      My point is if the Long_Order is placed first(as declare first), the short order will be ignore. And vice vesa.

      Using a same set of data and different order of placing orders, one will only trigger Long_Order while the other one only trigger the short. However, both of them should have enough chance to be triggered.

      I further checked the coexistence of order rule on Ninja and find that there are some rule that forbid placing too many order in a short period of time or simultaneously to avoid unnecessary trades. Wondering could that be the reason?

      #region Variables
      private IOrder Long_Order = null;
      private IOrder Short_Order = null;
      #endregion

      protected override void OnBarUpdate(){

      Long_Order = EnterLongStop(0, true, Unit, Base_Entry_Price+ x, "L");
      Short_Order = EnterShortStop(0, true, Unit, Base_Entry_Price- x, "S");

      /*
      //this will let the short order be recognized, and long order been ignored.
      Short_Order = EnterShortStop(0, true, Unit, Base_Entry_Price- x, "S");
      Long_Order = EnterLongStop(0, true, Unit, Base_Entry_Price+ x, "L");

      */

      // other order to exit both the short and long position

      Comment


        #4
        Hello,

        Using managed orders, you cannot place a simultaneous long and short order at the same time. There are internal order handling rules that prevent this from occurring.

        You can quickly identify these situations by initialize "TraceOrders":



        You can find information on the 'Internal Order Handling Rules that Reduce Unwanted Positions' below:



        If you are looking to trade with long and short orders at the same time, you will need to program this in the unmanaged approach and provide logic for your own order handling rules

        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        5 responses
        3,290 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        7 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        61 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        8 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        24 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X