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

set EnterShortStop and EnterLongStop at the same time

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

    set EnterShortStop and EnterLongStop at the same time

    Pls, help me. Why I can not to set EnterShortStop and EnterLongStop at the same time ?(works only one of the orders)
    It is example of code:

    Code:
    protected override void Initialize()
            {
    			
    			CalculateOnBarClose=true;
    			SetStopLoss(CalculationMode.Ticks,20);
    			SetProfitTarget(CalculationMode.Ticks,20);
    			EntryHandling = EntryHandling.AllEntries; 
            }
    
            protected override void OnBarUpdate()
            {
    	EnterShortStop(1,GetCurrentBid()-20*TickSize,"Sell");
    	EnterLongStop(1,GetCurrentAsk()+20*TickSize,"Buy");
            }
    As a result to take place always only first order(EnterShortStop)

    #2
    Hello AndreiFX,

    Thank you for your post.

    This is expected as how NinjaTrader handles orders. The link below goes over the internal order handling rules.


    You are running into:


    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
    A possible work-around if you want this behavior is to run multiple strategies and multiple charts.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      RayM,

      What if I wanted to enter a short and a long STOP order and have them OCO'd together?


      thanks!

      Comment


        #4
        HappyDev,

        You can do this with the unmanaged approach, which is new for NT 7. This allow you to submit without any internal order rules or any NT position management.

        The overloads for unmanaged orders also have an OCO field to use to tie together multiple orders with the same OCO id.

        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Really?

          I am having the very same problem. I want to test a VERY SIMPLE donchian strategy but it appears that this is very hard to do. Here is my code...

          protected override void OnBarUpdate()
          {
          EnterLongStop(1, DonchianChannel(Enter).Upper[0], "Long Entry");
          ExitLongStop(1,DonchianChannel(Exit).Lower[0]);
          EnterShortStop(1, DonchianChannel(Enter).Lower[0], "Short Entry");
          ExitShortStop(1,DonchianChannel(Exit).Upper[0]);
          }

          NT is only taking the first order (Long) and ignores the short side of the strategy. Does anyone have example code for making this work?

          Thanks!
          Adam

          Comment


            #6
            Hello Pentameter,

            Thank you for your post.

            The Enter() methods will essentially cancel each other out here. You will need to use the Unmanaged Order Approach for these bracket orders: http://www.ninjatrader.com/support/h...d_approach.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by naanku, Today, 07:25 PM
            0 responses
            6 views
            0 likes
            Last Post naanku
            by naanku
             
            Started by milfocs, Today, 07:23 PM
            0 responses
            5 views
            0 likes
            Last Post milfocs
            by milfocs
             
            Started by PaulMohn, Today, 06:59 PM
            0 responses
            7 views
            0 likes
            Last Post PaulMohn  
            Started by bortz, 11-06-2023, 08:04 AM
            48 responses
            1,755 views
            0 likes
            Last Post carnitron  
            Started by Jonker, 04-27-2024, 01:19 PM
            3 responses
            24 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X