Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Single entry but two targets?

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

    Single entry but two targets?

    Hello,
    Is it possible to enter two contracts at the same price
    Code:
    EnterLong(2, [COLOR="DarkRed"]"EnterLong2contracts"[/COLOR]);
    while setting individual Profit Target(and/or Stop Loss)?
    What I could come up with is to 'manually' check if the targets are met

    Code:
    [COLOR="Blue"]protected override void[/COLOR] OnBarUpdate(){
    	EnterLong(2, [COLOR="DarkRed"]"EnterLong2contracts"[/COLOR]);
    
    	[COLOR="blue"]if[/COLOR] (Position.Quantity == 2) 
    		[COLOR="blue"]if[/COLOR] (Close[0] > target1) [COLOR="DarkGreen"]// target1 met, for the 1st contract[/COLOR]
    			ExitLong(1, [COLOR="darkred"]"exit1stContract"[/COLOR],[COLOR="darkred"]"EnterLong2contracts"[/COLOR]);
    
    	[COLOR="blue"]if[/COLOR] (Position.Quantity == 1) 
    		[COLOR="blue"]if[/COLOR] (Close[0] > target2) [COLOR="DarkGreen"]// target2 met, for the 2nd contract[/COLOR]
    			ExitLong(1, [COLOR="darkred"]"exit2ndContract"[/COLOR],[COLOR="darkred"]"EnterLong2contracts"[/COLOR])
    }
    Is there a simpler, or more NT8 appropriate, way to do it?
    Thanks

    #2
    Originally posted by utilizator View Post
    Hello,
    Is it possible to enter two contracts at the same price
    Code:
    EnterLong(2, [COLOR=DarkRed]"EnterLong2contracts"[/COLOR]);
    while setting individual Profit Target(and/or Stop Loss)?
    What I could come up with is to 'manually' check if the targets are met

    Code:
    [COLOR=Blue]protected override void[/COLOR] OnBarUpdate(){
        EnterLong(2, [COLOR=DarkRed]"EnterLong2contracts"[/COLOR]);
    
        [COLOR=blue]if[/COLOR] (Position.Quantity == 2) 
            [COLOR=blue]if[/COLOR] (Close[0] > target1) [COLOR=DarkGreen]// target1 met, for the 1st contract[/COLOR]
                ExitLong(1, [COLOR=darkred]"exit1stContract"[/COLOR],[COLOR=darkred]"EnterLong2contracts"[/COLOR]);
    
        [COLOR=blue]if[/COLOR] (Position.Quantity == 1) 
            [COLOR=blue]if[/COLOR] (Close[0] > target2) [COLOR=DarkGreen]// target2 met, for the 2nd contract[/COLOR]
                ExitLong(1, [COLOR=darkred]"exit2ndContract"[/COLOR],[COLOR=darkred]"EnterLong2contracts"[/COLOR])
    }
    Is there a simpler, or more NT8 appropriate, way to do it?
    Thanks
    Try placing orders separately at the same time. each with its own target.
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Thanks RJay, I tried that
      Code:
      EnterLong(1, [COLOR="DarkRed"]"EnterLong1stContract"[/COLOR]);
      EnterLong(1, [COLOR="darkred"]"EnterLong2ndContract"[/COLOR]);
      but they fill at 1 tick difference, not at the same price. Any other ideas? Thanks

      Comment


        #4
        Hello utilizer,

        When you enable the strategy, have you increased the "Entries per direction" parameter to allow you to enter in a long position more than once? I have attached a screenshot of these settings and provided a link to our publicly available documentation on NinjaScript strategy parameters.

        I would also recommend to enable TraceOrders in the strategy and to observe the order submissions in the NinjaScript output window. This will tell you the exact reason why an order did not submit.

        TraceOrders - https://ninjatrader.com/support/foru...ead.php?t=3627

        Strategy properties - https://ninjatrader.com/support/help...tegyProperties

        Please don't hesitate to write back if this does not resolve your inquiry.
        Attached Files

        Comment


          #5
          Thanks NinjaTrader_Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          54 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          72 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X