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 techgetgame, Yesterday, 11:42 PM
          0 responses
          8 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          2 views
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,613 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          10 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          20 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X