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 PaulMohn, Today, 12:36 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          36 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by rdtdale, Today, 01:02 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by RookieTrader, Today, 09:37 AM
          4 responses
          20 views
          0 likes
          Last Post RookieTrader  
          Working...
          X