• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Patrick H.NinjaTrader Customer Service

    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":

        http://www.ninjatrader.com/support/f...ead.php?t=3627

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

        http://www.ninjatrader.com/support/h...d_approach.htm

        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

        http://www.ninjatrader.com/support/h...d_approach.htm
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by iq200, Today, 10:21 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by lunardiplomacy, Today, 07:52 AM
        1 response
        18 views
        0 likes
        Last Post caveat_lector  
        Started by rayko, Today, 10:20 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by derivtrader, Today, 10:14 AM
        0 responses
        4 views
        0 likes
        Last Post derivtrader  
        Started by Mindset, Today, 10:06 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X