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 Tim-c, Today, 03:54 AM
          0 responses
          3 views
          0 likes
          Last Post Tim-c
          by Tim-c
           
          Started by FrancisMorro, Today, 03:24 AM
          0 responses
          2 views
          0 likes
          Last Post FrancisMorro  
          Started by Segwin, 05-07-2018, 02:15 PM
          10 responses
          1,771 views
          0 likes
          Last Post Leafcutter  
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          31 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          945 views
          0 likes
          Last Post spwizard  
          Working...
          X