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

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
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks NinjaTrader_Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ScottWalsh, Today, 04:29 PM
          0 responses
          4 views
          0 likes
          Last Post ScottWalsh  
          Started by rtwave, 04-12-2024, 09:30 AM
          2 responses
          21 views
          0 likes
          Last Post rtwave
          by rtwave
           
          Started by tsantospinto, 04-12-2024, 07:04 PM
          5 responses
          69 views
          0 likes
          Last Post tsantospinto  
          Started by cre8able, Today, 03:20 PM
          0 responses
          7 views
          0 likes
          Last Post cre8able  
          Started by Fran888, 02-16-2024, 10:48 AM
          3 responses
          49 views
          0 likes
          Last Post Sam2515
          by Sam2515
           
          Working...
          X