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

scale-out and update Stop Loss

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

    scale-out and update Stop Loss

    Hi, I know this has been posted many times, but I'm struggling to get this right.

    I'm opening a position of 3 contracts. I'm sending 3 orders because I want to scale out. All 3 contracts have the same Stop Loss with 3 different targets:

    if (LONG_CONDITION) {
    SetStopLoss("Long1", CalculationMode.Ticks , stop1Ticks, false);
    SetProfitTarget("Long1", CalculationMode.Ticks, target1Ticks);

    SetStopLoss("Long2", CalculationMode.Ticks, stop1Ticks, false);
    SetProfitTarget("Long2", CalculationMode.Ticks, target2Ticks);

    SetStopLoss("Long3", CalculationMode.Ticks, stop1Ticks, false);
    SetProfitTarget("Long3", CalculationMode.Ticks, target3Ticks);

    entryOrder = EnterLong(DefaultQuantity, "Long1");
    entryOrder = EnterLong(DefaultQuantity, "Long2");
    entryOrder = EnterLong(DefaultQuantity, "Long3");
    }

    Now, I'm struggling to update the stops when the first target is hit.
    When the first target is hit, I want to move the stops for Long2 and Long3 to Breakeven.

    Can anybody give me a quick code for the OnExecution function to do that?
    How do I identify which order was filled??

    Thanks for any help!

    #2
    Hi jbrooks727 - welcome to the NinjaTrader support forums! Please review this reference sample here - http://www.ninjatrader-support2.com/...ead.php?t=7499
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks, I was looking at different examples, I'll give it a try once again.

      So, basically I need to have different identifiers for each order, right? (and I can match the 'tokens' to identify each particular order)
      And I need to handle the OCO bracket manually, right? when the stop or the target is hit, then I need to cancel the other side manually...it'll not get done automatically??

      Thanks again for the quick reply!

      Comment


        #4
        That is all correct. You want to cancel remaining OCO orders.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by quicksandatl, 05-09-2024, 11:11 AM
        3 responses
        21 views
        0 likes
        Last Post quicksandatl  
        Started by morrnel, 05-12-2024, 06:07 PM
        6 responses
        67 views
        1 like
        Last Post NinjaTrader_Manfred  
        Started by algospoke, 05-13-2024, 06:53 PM
        2 responses
        21 views
        0 likes
        Last Post algospoke  
        Started by janio973, Yesterday, 07:24 PM
        6 responses
        29 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AlphaOptions, 06-18-2013, 08:24 AM
        5 responses
        2,170 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X