Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStop() getting cancelled

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

    ExitLongStop() getting cancelled

    I have a simple startegy where I am submitting a ExitLongStop() as soon as a buy order gets filled. But this order comes back as cancelled right away. (In backtesting)

    //******* RELEVANT CODE
    protected override void OnOrderUpdate(IOrder order)
    {
    Log(
    "DTMT2: " + Time[0].ToString() + order.ToString(), NinjaTrader.Cbi.LogLevel.Error);
    if (order.Action == Action.Buy && order.OrderState == OrderState.Filled)
    {
    buyprice=order.AvgFillPrice;
    sellprice=buyprice*sellstop;

    exitOrder = ExitLongStop(sellprice,
    "Initial Stop", "EDC Purchase");
    }
    }
    //******************************

    THis is what shows up in logs for ExitLongStop() orders -
    9/10/2009 7:39:00 AMOrder='NT-00010/Back101' Name='Initial Stop' State=Cancelled Instrument='EDC' Action=Sell Limit price=0 Stop price=119.3801 Quantity=0 Strategy='EDC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='257cd921dce241f791ddb255a3c47c26' Gtd='12/1/2099 12:00:00 AM'
    9/10/2009 7:39:00 AMOrder='NT-00010/Back101' Name='Initial Stop' State=PendingCancel Instrument='EDC' Action=Sell Limit price=0 Stop price=119.3801 Quantity=0 Strategy='EDC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='257cd921dce241f791ddb255a3c47c26' Gtd='12/1/2099 12:00:00 AM'
    9/10/2009 7:38:00 AMOrder='NT-00010/Back101' Name='Initial Stop' State=Working Instrument='EDC' Action=Sell Limit price=0 Stop price=119.3801 Quantity=0 Strategy='EDC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='257cd921dce241f791ddb255a3c47c26' Gtd='12/1/2099 12:00:00 AM'
    9/10/2009 7:38:00 AMOrder='NT-00010/Back101' Name='Initial Stop' State=Accepted Instrument='EDC' Action=Sell Limit price=0 Stop price=119.3801 Quantity=0 Strategy='EDC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='257cd921dce241f791ddb255a3c47c26' Gtd='12/1/2099 12:00:00 AM'
    9/10/2009 7:38:00 AMOrder='NT-00010/Back101' Name='Initial Stop' State=PendingSubmit Instrument='EDC' Action=Sell Limit price=0 Stop price=119.3801 Quantity=0 Strategy='EDC' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='257cd921dce241f791ddb255a3c47c26' Gtd='12/1/2099 12:00:00 AM'

    #2
    cheeky123, please make sure TraceOrders = true is enabled in the Initialize() of your strategy, then follow the output window for more detailed debug info regarding your order behavior - http://www.ninjatrader-support2.com/...ead.php?t=3627

    Comment


      #3
      Hi,

      I turned the trace ON, and this is what shows up in the output window.
      (its cancelling the exitstop order immediately.

      9/10/2009 6:38:00 AM Entered internal PlaceOrder() method at 9/10/2009 6:38:00 AM: Action=Buy OrderType=Market Quantity=7,398 LimitPrice=0 StopPrice=0 SignalName='EDZ Purchase' FromEntrySignal=''


      9/10/2009 6:38:00 AM Entered internal PlaceOrder() method at 9/10/2009 6:38:00 AM: Action=Sell OrderType=Stop Quantity=7,398 LimitPrice=0 StopPrice=7.78 SignalName='EDZ Sell' FromEntrySignal='EDZ Purchase'


      9/10/2009 6:39:00 AM Cancelled expired order: BarsInProgress=1: Order='NT-00001/Back101' Name='EDZ Sell' State=Working Instrument='EDZ' Action=Sell Limit price=0 Stop price=7.776 Quantity=7,398 Strategy='SetStops' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='98866ec6c0e44f32a349f668836589f3' Gtd='12/1/2099 12:00:00 AM'


      I have tried all the options without any luck. I will really appreciate any help you can provide.

      Also please let me know if it is possible to back test against "tick by tick" data instead of "minute by minute".

      thanks.

      Comment


        #4
        cheeky123, thanks for the reply - your order just expires which is default behavior at the end of each bar if not resubmitted or set to liveUntilCancelled in the overload - http://www.ninjatrader-support.com/H...tLongStop.html

        To backtest with intrabar resolution, please check into this sample here - http://www.ninjatrader-support2.com/...ead.php?t=6652

        Comment


          #5
          Hi,

          I looked at the example. Example does not go for tick by tick. Both bar series in example are minute based.
          Any way this is what I have in my code -

          (Inside Initilaize)
          Add(PeriodType.Tick, 1); //For default instrument - FAS.
          Add(
          "FAZ", PeriodType.Tick, 1);

          protected override void OnBarUpdate()
          {

          if(BarsInProgress == 0) // Condition set 1 for FAS
          { }
          else if(BarsInProgress == 1) // Condition set 2 for FAZ.

          Now when i try to backtest it with FAS instrument, (selecting "tick - 1 as the value for dataseries) I do not get any output. Nothing is posted to the logs. Trace shows some entries regarding connecting to TD Ameritrade (my data provider), thats it. Also if I change the code and replace "tick" with "minute", it works fine. Please help!

          Comment


            #6
            cheeky123, bars object 0 is the primary one you start this strategy from i.e. your 1 minute chart.

            For the added two tickstreams this would then mean the correct objects to reference are 1 and 2 in your BarsInProgress call.

            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
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            574 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X