Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error when multiple order with Target PT1 and PT2 and SL dynamic change when Hit PT1

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

    Error when multiple order with Target PT1 and PT2 and SL dynamic change when Hit PT1

    Hello I am creating a scipt when cross occur, take 2 orders with same SL and different Target PT1 and PT2, After 1st order hit PT1, SL become BE.

    I am getting error " cant be submitted.The OCO ID '94239842394" cannot be reused. Please use new OCO ID affectedOrder: BuytoCover 1 limit @"

    i given SetprofitTarget and SetStoploss in Dataloaded.

    ​​​​​​SetProfitTarget("Long1", CalculationMode.Ticks,PT1);
    SetProfitTarget("Long2", CalculationMode.Ticks,PT2);
    SetStopLoss("", CalculationMode.Ticks, StopLoss, true);​

    And Dynamic SL i given in onbar update.

    ​​​​​​if (Position.MarketPosition == MarketPosition.Long)
    {
    if (Close[0] >= Position.AveragePrice + 10 * TickSize)
    {
    SetStopLoss(CalculationMode.Price, Position.AveragePrice);
    }
    }​

    #2
    Hello jenishij,

    Thanks for your post.

    You could use Exit order methods for your profit target and stop loss orders instead of using Set methods if you want to move the stop to breakeven.

    You can use exit order methods and add coding logic in the Strategy Builder to accomplish this goal. Please note that you would not be able to use the exit methods and the stops in the stop and targets window as that creates a violation of the managed approach internal order handling rules, linked here: https://ninjatrader.com/support/help...d_approach.htm

    My colleague Chelsea has created educational examples of strategy builder breakeven and trailing stop in the strategy builder here:

    https://ninjatrader.com/support/forum/forum/suggestions-and-feedback/suggestions-and-feedback-
    aa/103992-request-breakeven-functions-in-strategy-builder#post806596
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      I could not open both links. Showing page not found .

      Comment


        #4
        Hello jenishij,

        Thanks for your notes.

        I have readded the links below for you to view.

        Managed Approach: https://ninjatrader.com/support/help...d_approach.htm

        My colleague Chelsea has created educational examples of strategy builder breakeven and trailing stop in the strategy builder here:

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks Brandon. Exit order works. But when i place 2 order, It is executing only 1. We cannot do 2 orders in same condition with different name?

          if ((Position.MarketPosition == MarketPosition.Long)&& (Condition == 0)

          ​​​​​​{

          EnterLong(1, @"Long1");
          EnterLong(1, @"Long2");

          }

          Comment


            #6
            Hello jenishij,

            Thanks for your notes.

            The Entries Per Direction property should be set to 2 if you would like to have more than 1 position placed by the strategy at a time.

            EntriesPerDirection and EntryHandling could be used to control the maximum number of entries allowed per direction while a position.

            If you set Entry Handling to EntryHandling.AllEntries, NinjaScript will process all entry order methods up to the maximum allowable entries set in the EntriesPerDirection property. For example, if you set EntriesPerDirection to 3 and use EntryHandling.AllEntries, up to a total of 3 entry orders will process.

            If you set Entry Handling to EntryHandling.UniqueEntries, NinjaScript will process order entry methods up to the maximum allowable entries set by the EntriesPerDirection property for each uniquely named entry. For example, if you have two entry order methods using unique signal names ("entry1" and "entry2"), set EntriesPerDirection to 3, and use EntryHandling.UniqueEntries, a maximum number of 3 entry orders will process for each uniquely named entry order (up to 3 orders for "entry1" and 3 orders for "entry2").​

            EntriesPerDirection: https://ninjatrader.com/support/help...rdirection.htm
            EntryHandling: https://ninjatrader.com/support/help...ryhandling.htm
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7

              What exactly Stop price in the managed approach in EnterLongStopMarket(int quantity, double stopPrice, string signalName) means? document mentioned "The stop price of the order."

              Is stop price is like Stop Loss?


              Comment


                #8
                Hello jenishij,

                Thanks for your notes.

                EnterLongStopMarket() is used to submit a buy stop market order to enter a long position.

                These orders wait for the price of the instrument to pass your stop price. Once it passes the stop price the order becomes a market order for execution. Stop orders increase your chances of getting filled at a particular price, but are not guaranteed because they are still ultimately market orders.

                See the help guide documentation below for more information.

                NT8 Order Types: https://ninjatrader.com/support/help...rder_types.htm
                NT8 EnterLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                579 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X