Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scale out 2 contracts

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

    Scale out 2 contracts

    Hi to all,
    i've a nice problem to scale out 2 contract,

    i do the enterlong 2 times, one to contract (not setting the quantity at 2) because i want to give at every entry a different name...

    Code:
    EnterLong(1,"Long1");
    EnterLong(1,"Long2");
    set a common stoploss and different profit target,

    Code:
    SetStopLoss("Long1",CalculationMode.Ticks, 8, false);
    SetStopLoss("Long2",CalculationMode.Ticks, 8, false);
    SetProfitTarget(Long1",CalculationMode.Ticks, 8);
    SetProfitTarget("Long2",CalculationMode.Ticks, 16);
    when first contract (Long1) achieves the target i want to set stoploss of other contract (Long2) to breakeven (+2 point to Position.AvgPrice) ..
    In this case, which is the mode to do this? Which is the mode to detect profit target of first contract is hitted? Or is there a way to know the number of contract i actually have in market (in this mode, when i have only 1 contract, i change stoploss)?

    Another question: when i have 2 contracts in position, the object Position. ... which is the contract to refer this object? Both? Only the first? only the second?

    Thanks to all !!

    wyatt

    #2
    wyatt,

    The Position will reflect overall state there, so if you have 2 long orders your position is still Long.

    Here is a reference sample on modifying stop losses and profit targets : http://www.ninjatrader.com/support/f...ead.php?t=3222

    I would suggest using OnOrderUpdate() or OnExecution() to modify your stops since you said you wanted one position to close then to set breakeven.

    The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Ok, i find this way, isn't there a method for detect the number of contracts when i'm in market position?

      another question:

      you say: "The Position will reflect overall state there, so if you have 2 long orders your position is still Long"

      my ask: if i've 2 contract in position, Position.AvgPrice is the first contract entry price or second contract entry price?

      thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X