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

Limit orders

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

    Limit orders

    Hi I am trying to place 2 limit orders (one buy, one sell) and control them differently. Also I would like to control the longs and the shorts differently (independent of each other like different trades with different parameters).
    Now I have noticed the following which may be a bug. When I have the following code

    EnterLongLimit(X[0], "L");
    EnterShortLimit(Y[0], "S");

    only one of the two works. Only the first one in particular. So if I comment the top one the orders I get are always short but if I leave them as above I get only long (!). Why is that?

    #2
    Hello Sktrader1,

    You are running into our internal order handling rules. Can read these at the bottom of this page.

    The one that you're seeing is highlighted in bold below.


    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
    • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
    • The strategy position is flat 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
    With our upcoming version 7, we have introduced unmanaged orders which will allow both of these submitted at same time. Version 7 is in public beta and you can download it here.

    See here for information on unmanaged orders in version 7.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I see. That is very limiting. I downloaded ninja7 but somehow when I apply the strategy to the chart it doesnt work. I will investigate further.

      Comment


        #4
        With version 7 there is an additional step needed once the strategy is applied to chart.

        You must set Enabled to true: Either through the Right Click > Strategies screen from chart or the strategies tab of the control center.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks that did work. So what am I looking at? Is it the unmanaged approach?

          Comment


            #6
            Yes, the unmanaged approach is needed if you would like to submit limit orders in both directions at the same time.

            There will be different order submission methods for this approach. An introduction to this is found at this link.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I try the following

              In the variables section:

              private IOrder entryOrderL = null;
              private IOrder entryOrderS = null;

              and in the main



              if (entryOrderL == null)
              {
              entryOrderL = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, X[0], 0, "", "Enter Long");
              }

              if (entryOrderS == null)
              {
              entryOrderS = SubmitOrder(0, OrderAction.SellShort, OrderType.Limit, 1, Y[0], 0, "", "Enter Short");
              }

              it seems to enter only the first short.
              Nothing on the long side. Is there something obviously wrong?

              Comment


                #8
                Sktrader1,

                Tested this over here on a real time basis and it submitted both orders. To test on Real Time only add if (Historical) return; to OnBarUpdate() method and set Minimum Bars required to 0.

                You will likely need to reset your IOrder objects when orders are filled or canceled.


                View a reference sample on working with IOrders at the link below:
                http://www.ninjatrader.com/support/forum/showthread.php?t=7499
                Last edited by NinjaTrader_RyanM1; 05-12-2010, 01:01 PM. Reason: Added additional link
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks for that. I will review what you told me and get back to you.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RubenCazorla, Today, 09:07 AM
                  1 response
                  5 views
                  0 likes
                  Last Post RubenCazorla  
                  Started by Irukandji, Today, 09:34 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post Irukandji  
                  Started by TraderBCL, Today, 04:38 AM
                  3 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  11 responses
                  1,423 views
                  0 likes
                  Last Post jculp
                  by jculp
                   
                  Started by BarzTrading, Today, 07:25 AM
                  2 responses
                  29 views
                  1 like
                  Last Post BarzTrading  
                  Working...
                  X