Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven is cancelled on live

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

    Breakeven is cancelled on live

    Hello Ninjatrader support.
    My strategy follows the logic described below.
    1. Initially and each time the position gets flat the logic set stop loss with using
    Code:
    SetStopLoss(CalculationMode.Ticks, Stop_Loss_Ticks);
    2. Once entry condition is met the logic places 2 entry orders with signal names "Entry for TP #1" and "Entry for TP #2"
    3. Once target profit #1 condition is met the logic closes "Entry for TP #1" position and moves stop loss to breakeven in OnPositionUpdate callback
    Code:
    SetStopLoss(CalculationMode.Price, averagePrice);
    It works fine on Sim account. But it doesn't on live account (I use Interactive Broker). Each time the logic moves stop loss to breakeven NT8 cancels stop order for some reason... I guess it has something to do with isLiveUntilCancelled parameter. But the problem is Set methods don't have such a parameter. What can you advise? Should I use ExitLongStopMarket / ExitShortStopMarket instead of SetStopLoss?

    #2
    Hello PopovDS,

    Is there a Native message for the cancellation on the Log tab of the Control Center?

    You may need to use unique signal names for each entry and have separate stop losses using the from entry signals of those entries.

    Set methods do not have an isLiveUntilCancelled implementation and would not cancel for this reason.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No any native error text (see the attached screenshot). OK, I will try separate SL for each entry.
      Attached Files

      Comment


        #4
        Hello.
        I would like to resume the discussion of the issue of Stop Loss order cancellation on live account Interactive Broker. Note, that issue have never occurred on Sim account. The logic is as following:
        1. Each time the position gets flat stop loss at 140 ticks is placed.
        Code:
        SetStopLoss(CalculationMode.Ticks, 140);
        2. If entry condition is met and position is flat the logic places entry market order.
        Code:
        EnterLong(300, "Entry");
        3. If the position is not flat and target condition is met the logic takes profit.
        Code:
        ExitLong(200, "Profit", "Entry");
        4. Once TP is filled Breakeven is placed.
        Code:
        protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
        {
              if (orderState == OrderState.Filled)
              {
                    if (order.Name == "Profit")
                    {
                            var bid = GetCurrentBid();
                            var ask = GetCurrentAsk();
                            if ((Position.AveragePrice.ApproxCompare(bid) >= 0 && Position.MarketPosition == MarketPosition.Long) ||
                                (Position.AveragePrice.ApproxCompare(ask) <= 0 && Position.MarketPosition == MarketPosition.Short))
                            {
                                   // The stop price is above/below the market
                                   ExitLong();
                            }
                            else
                            {
                                   // Breakeven
                                   SetStopLoss(CalculationMode.Price, Position.AveragePrice);
                            }
                     }
              }
        }​
        Submitted Breakeven is cancelled sometimes. NT8 log doesn't clarify the reason... Perhaps the position size is calculated incorrectly when using IB broker connection... After TP is taken the position size remains at 100.
        Last edited by PopovDS; 03-28-2024, 03:23 PM.

        Comment


          #5
          Are there any suggestions regarding the request posted above?

          Comment


            #6
            Hello PopovDS,

            I recommend using separate entries with unique signal names for each quantity you want to scale out.

            Below is a link to an example.


            Or alternatively, use the unmanaged approach to have full control over the orders.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            90 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            137 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            120 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            72 views
            0 likes
            Last Post PaulMohn  
            Working...
            X