Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Errors Generated when moving stops

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

    Errors Generated when moving stops

    I'm encountering issues where error codes are generated when I'm trying to move stops to breakeven... I've done TraceOrders == true;, and the following is the output.... but can't seem to figure out why it is giving an error....

    PHP Code:
    8/7/2009 8:35:28 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:28 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1005.50 StopPrice=0 SignalName='ShortA' FromEntrySignal=''
    8/7/2009 8:35:28 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:28 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1005.50 StopPrice=0 SignalName='ShortB' FromEntrySignal=''
    8/7/2009 8:35:35 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:35 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1006.50 SignalName='ShortStopA' FromEntrySignal='ShortA'
    8/7/2009 8:35:35 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:35 AM: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=1003.50 StopPrice=0 SignalName='ShortTargetA' FromEntrySignal='ShortA'
    8/7/2009 8:35:35 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:35 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1006.50 SignalName='ShortStopB' FromEntrySignal='ShortB'
    8/7/2009 8:35:35 AM Entered internal PlaceOrder() method at 8/7/2009 8:35:35 AM: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=1003.25 StopPrice=0 SignalName='ShortTargetB' FromEntrySignal='ShortB'
    8/7/2009 8:36:31 AM Entered internal PlaceOrder() method at 8/7/2009 8:36:31 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1005.50 SignalName='ShortStopB' FromEntrySignal='ShortB'
    8/7/2009 8:36:31 AM Amended matching order: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1005.50 SignalName=ShortStopB' FromEntrySignal='ShortB'
    8/7/2009 8:37:56 AM Cancelled pending exit order, since associated position is closed: Order='4856d51404d747ea9630d240d0984e2e/Replay101' Name='ShortStopA' State=Accepted Instrument='ES 09-09' Action=BuyToCover Limit price=0 Stop price=1005.5 Quantity=1 Strategy='SkeletonTest2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='4856d51404d747ea9630d240d0984e2e' Gtd='12/1/2099 12:00:00 AM'
    8/7/2009 8:37:56 AM Entered internal PlaceOrder() method at 8/7/2009 8:37:56 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1003.75 StopPrice=0 SignalName='ShortA' FromEntrySignal=''
    8/7/2009 8:37:56 AM Entered internal PlaceOrder() method at 8/7/2009 8:37:56 AM: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1005.50 SignalName='ShortStopB' FromEntrySignal='ShortB'
    8/7/2009 8:37:56 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1005.50 SignalName=ShortStopB' FromEntrySignal='ShortB' Reason='There already is a matching order with same prices and quantity'
    8/7/2009 8:37:56 AM Entered internal PlaceOrder() method at 8/7/2009 8:37:56 AM: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1005.50 SignalName='ShortStopB' FromEntrySignal='ShortB'
    8/7/2009 8:37:56 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1005.50 SignalName=ShortStopB' FromEntrySignal='ShortB' Reason='There already is a matching order with same prices and quantity'
    Cancelled custom managed order at 8/7/2009 8:37:56 AM: Order='50b68f7da0fd466b9c016aa2d44727b5/Replay101' Name='ShortA' State=Working Instrument='ES 09-09' Action=SellShort Limit price=1003.75 Stop price=0 Quantity=1 Strategy='SkeletonTest2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='50b68f7da0fd466b9c016aa2d44727b5' Gtd='12/1/2099 12:00:00 AM'
    8/7/2009 8:37:56 AM Cancelled pending exit order, since associated position is closed: Order='5ef40f3540d842d193ee2d46e93c2685/Replay101' Name='ShortStopB' State=Accepted Instrument='ES 09-09' Action=BuyToCover Limit price=0 Stop price=1005.5 Quantity=1 Strategy='SkeletonTest2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='5ef40f3540d842d193ee2d46e93c2685' Gtd='12/1/2099 12:00:00 AM' 
    
    the error code is

    8/10/2009 10:32:30 AM Strategy Error on calling 'OnBarUpdate' method for strategy 'SkeletonTest2': Object reference not set to an instance of an object.


    This error is only generated when I have more than one contract
    Last edited by BigDog008; 08-10-2009, 09:42 AM.

    #2
    my code is as follows:

    Code:
    // LONG ORDER A
                if (longentryOrderA == null
                    && golong == true
                    && goshort == false
                    && chop == false
                    && Position.MarketPosition != MarketPosition.Short)
                {
                    longentryOrderA = EnterLongLimit(0, true, DefaultQuantity, GetCurrentBid() - 1 * TickSize, "LongA");
                }
                // BREAKEVEN STOPLOSS
                if (longentryOrderA != null
                    && longstopOrderA != null
                    && longentryOrderA.OrderState == OrderState.Filled
                    && GetCurrentBid() - longentryOrderA.AvgFillPrice >= 6 * TickSize)
                {
                    longstopOrderA = ExitLongStop(0, true, longentryOrderA.Filled, longentryOrderA.AvgFillPrice, "LongStopA", "LongA");
                }
    
    // LONG ORDER B
                if (longentryOrderB == null
                    && golong == true
                    && goshort == false
                    && chop == false
                    && Position.MarketPosition != MarketPosition.Short)
                {
                    longentryOrderB = EnterLongLimit(0, true, DefaultQuantity, GetCurrentBid() - 1 * TickSize, "LongB");
                }
                
                // BREAKEVEN STOPLOSS
                if (longentryOrderB != null
                    && longstopOrderB != null
                    && longentryOrderB.OrderState == OrderState.Filled
                    && GetCurrentBid() - longentryOrderB.AvgFillPrice >= 4 * TickSize)
                {
                    longstopOrderB = ExitLongStop(0, true, longentryOrderB.Filled, longentryOrderB.AvgFillPrice, "LongStopB", "LongB");
                }
    
    // SHORT ORDER A
                if (shortentryOrderA == null
                    && goshort == true
                    && golong == false
                    && chop == false
                    && Position.MarketPosition != MarketPosition.Long)
                {
                    shortentryOrderA = EnterShortLimit(0, true, DefaultQuantity, GetCurrentAsk() + 1 * TickSize, "ShortA");;
                }
                
                // BREAKEVEN STOPLOSS
                if (shortentryOrderA != null
                    && shortstopOrderA != null
                    && shortentryOrderA.OrderState == OrderState.Filled
                    && shortentryOrderA.AvgFillPrice - GetCurrentAsk() >= 6 * TickSize)
                {
                    shortstopOrderA = ExitShortStop(0, true, shortentryOrderA.Filled, shortentryOrderA.AvgFillPrice, "ShortStopA", "ShortA");
                }
    
    // SHORT ORDER B
                if (shortentryOrderB == null
                    && goshort == true
                    && golong == false
                    && chop == false)
                {
                    shortentryOrderB = EnterShortLimit(0, true, DefaultQuantity, GetCurrentAsk() + 1 * TickSize, "ShortB");
                }
                
                // BREAKEVEN STOPLOSS
                if (shortentryOrderB != null
                    && shortstopOrderB != null
                    && shortentryOrderB.OrderState == OrderState.Filled
                    && shortentryOrderB.AvgFillPrice - GetCurrentAsk() >= 4 * TickSize)
                {
                    shortstopOrderB = ExitShortStop(0, true, shortentryOrderA.Filled, shortentryOrderB.AvgFillPrice, "ShortStopB", "ShortB");
                }
    
            protected override void OnExecution(IExecution execution)
    
    // LONG ORDER A
                if (longentryOrderA != null && longentryOrderA.Token == execution.Order.Token)
                {
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    {
                        longstopOrderA = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "LongStopA", "LongA");
                        longtargetOrderA = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 8 * TickSize, "LongTargetA", "LongA");
                    }
                }
    
    // LONG ORDER B
                if (longentryOrderB != null && longentryOrderB.Token == execution.Order.Token)
                {
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    {
                        longstopOrderB = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "LongStopB", "LongB");
                        longtargetOrderB = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 9 * TickSize, "LongTargetB", "LongB");
                    }
                }
    // SHORT ORDER A
                if (shortentryOrderA != null && shortentryOrderA.Token == execution.Order.Token)
                {
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    {
                        shortstopOrderA = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopA", "ShortA");
                        shorttargetOrderA = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 8 * TickSize, "ShortTargetA", "ShortA");
                    }
                }
    
    // SHORT ORDER B
                if (shortentryOrderB != null && shortentryOrderB.Token == execution.Order.Token)
                {
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    {
                        shortstopOrderB = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "ShortStopB", "ShortB");
                        shorttargetOrderB = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 9 * TickSize, "ShortTargetB", "ShortB");
                    }
                }

    Comment


      #3
      BigDog008, this error normally occurs when you try to access an empty object, the trace output you refer to just informs you the order is already placed and thus the next attempt to place it again is ignored.

      Comment


        #4
        Bertrand,

        I understand that, and I'm fine with that...

        the issue is, that once I start trying to manipulate more than one order at a time, I encounter an OnBarUpdate() Error as stated, and then the strategy ceases to place existing orders

        Comment


          #5
          Likely has to do with trying to access a null IOrder object. Unfortunately the only thing to do would be to debug.

          Please see this tip about null objects. http://www.ninjatrader-support2.com/...ead.php?t=4226
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Josh View Post
            Likely has to do with trying to access a null IOrder object. Unfortunately the only thing to do would be to debug.

            Please see this tip about null objects. http://www.ninjatrader-support2.com/...ead.php?t=4226

            Hey Josh, that fixed the problem....

            as usual you're tops!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 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
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X