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 trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        9 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X