Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

canceled targets

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

    canceled targets

    Hi support,

    I have a problem handling multiple contracts to scale out a position by using the advanced orderhandling api.

    Sometimes it happend that my first target is touched and all other target orders will be canceled, only the stop order stays is the market. There is no code that cancels any order manually. I'm really confused that it happend sometimes, no pattern that I find out.

    The trace is enabled and I get the following output:

    01.10.2009 13:06:52 Entered internal PlaceOrder() method at 01.10.2009 13:06:52: Action=Sell OrderType=Stop Quantity=4 LimitPrice=0 StopPrice=69,87 SignalName='SL' FromEntrySignal=''
    01.10.2009 13:06:52 Entered internal PlaceOrder() method at 01.10.2009 13:06:52: Action=Sell OrderType=Limit Quantity=1 LimitPrice=70,15 StopPrice=0 SignalName='T1' FromEntrySignal=''
    01.10.2009 13:06:52 Entered internal PlaceOrder() method at 01.10.2009 13:06:52: Action=Sell OrderType=Limit Quantity=1 LimitPrice=70,19 StopPrice=0 SignalName='T2' FromEntrySignal=''
    01.10.2009 13:06:52 Entered internal PlaceOrder() method at 01.10.2009 13:06:52: Action=Sell OrderType=Limit Quantity=1 LimitPrice=70,31 StopPrice=0 SignalName='T3' FromEntrySignal=''
    01.10.2009 13:10:57 Entered internal PlaceOrder() method at 01.10.2009 13:10:57: Action=SellShort OrderType=Market Quantity=4 LimitPrice=0 StopPrice=0 SignalName='ENTRY' FromEntrySignal=''
    01.10.2009 13:10:57 Cancelled pending exit order, since associated position is closed: Order='e01c0b3d24134881830f1e0ac1ede8d9/Replay101' Name='T3' State=Working Instrument='CL 11-09' Action=Sell Limit price=70,31 Stop price=0 Quantity=1 Strategy='BWTPrecisionAutoTraderC' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='e01c0b3d24134881830f1e0ac1ede8d9' Gtd='01.12.2099 00:00:00'
    01.10.2009 13:10:57 Cancelled pending exit order, since associated position is closed: Order='863ae9c993914065a780afd8af975e09/Replay101' Name='T2' State=Working Instrument='CL 11-09' Action=Sell Limit price=70,19 Stop price=0 Quantity=1 Strategy='BWTPrecisionAutoTraderC' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='863ae9c993914065a780afd8af975e09' Gtd='01.12.2099 00:00:00'
    01.10.2009 13:10:57 Cancelled pending exit order, since associated position is closed: Order='bca21b4f71ac4a5d95ddf38af7ce00a3/Replay101' Name='T1' State=Working Instrument='CL 11-09' Action=Sell Limit price=70,15 Stop price=0 Quantity=1 Strategy='BWTPrecisionAutoTraderC' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='bca21b4f71ac4a5d95ddf38af7ce00a3' Gtd='01.12.2099 00:00:00'
    01.10.2009 13:10:57 Cancelled pending exit order, since associated position is closed: Order='5992663565d34faaaadebd16ba7ed7e6/Replay101' Name='SL' State=Accepted Instrument='CL 11-09' Action=Sell Limit price=0 Stop price=69,87 Quantity=4 Strategy='BWTPrecisionAutoTraderC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='5992663565d34faaaadebd16ba7ed7e6' Gtd='01.12.2099 00:00:00'
    01.10.2009 13:10:57 Entered internal PlaceOrder() method at 01.10.2009 13:10:57: Action=BuyToCover OrderType=Stop Quantity=4 LimitPrice=0 StopPrice=70,18 SignalName='SL' FromEntrySignal=''
    01.10.2009 13:10:57 Entered internal PlaceOrder() method at 01.10.2009 13:10:57: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=69,90 StopPrice=0 SignalName='T1' FromEntrySignal=''
    01.10.2009 13:10:57 Entered internal PlaceOrder() method at 01.10.2009 13:10:57: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=69,86 StopPrice=0 SignalName='T2' FromEntrySignal=''
    01.10.2009 13:10:57 Entered internal PlaceOrder() method at 01.10.2009 13:10:57: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=69,74 StopPrice=0 SignalName='T3' FromEntrySignal=''


    Here is a sequence of the code where the stop and target orders are created:

    if (entryOrder != null && entryOrder.Token == execution.Order.Token && Strategy.Position.MarketPosition == MarketPosition.Long)
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    {
    currentEntryPrice = entryOrder.AvgFillPrice;
    Pricing.CalculateStopsTargets(currentEntryPrice, _BWTPriceCalculation.LONG, PositionQuantity.Quantity1, PositionQuantity.TotalQuantity);
    _currentStop = _pricing.Stop;
    stopOrder = Strategy.ExitLongStop(0, true, execution.Order.Filled, _pricing.Stop, STOP, "");
    if(_positionQuantity.IsQuantity1)
    {
    Pricing.CalculateStopsTargets(currentEntryPrice, _BWTPriceCalculation.LONG, PositionQuantity.Quantity1, PositionQuantity.TotalQuantity);
    targetOrder1 = Strategy.ExitLongLimit(0, true, _positionQuantity.Quantity1, _pricing.Target1, TARGET1, "");
    }
    if (_positionQuantity.IsQuantity2)
    {
    Pricing.CalculateStopsTargets(currentEntryPrice, _BWTPriceCalculation.LONG, PositionQuantity.Quantity2,
    PositionQuantity.TotalQuantity);
    targetOrder2 = Strategy.ExitLongLimit(0, true, _positionQuantity.Quantity2, _pricing.Target2, TARGET2, "");
    }
    if (_positionQuantity.IsQuantity3)
    {
    Pricing.CalculateStopsTargets(currentEntryPrice, _BWTPriceCalculation.LONG, PositionQuantity.Quantity3,
    PositionQuantity.TotalQuantity);
    targetOrder3 = Strategy.ExitLongLimit(0, true, _positionQuantity.Quantity3, _pricing.Target3, TARGET3, "");
    }

    Trailing.Start = false;
    Trailing.LastStop = _currentStop;
    if (BreakEven != null)
    {
    BreakEven.Start = false;
    BreakEven.LastStop = currentEntryPrice;
    }
    }
    }


    Can you help me to find out what kind of problem is is?
    How are the orders associated?

    Thanks very much!
    cicondo
    Last edited by cicondo; 10-11-2009, 12:42 PM.

    #2
    cicondo, does the strategy reverse also at times? It looks to me like it cancelled stops and targets as it reversed the position, which is expected.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      cicondo, does the strategy reverse also at times? It looks to me like it cancelled stops and targets as it reversed the position, which is expected.
      Hi Bertrand,

      yes it should. But it reverse only if the certain trigger raises....but not on touching the target 1. And it is really scary that it sometime works and sometimes not.

      Thanks

      Comment


        #4
        Then you would need to debug your code and trade entry conditions, best is to use draw statements to visualize and Prints to doublecheck triggers values - http://www.ninjatrader-support2.com/...ead.php?t=3418

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 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