Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

error : Cancelled expired order:

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

    error : Cancelled expired order:

    Hello, I would use a strategy to place orders, my system is to place several Orders at the same time according to the parameters provided by the user. at the same time I know for each entry Long, exit Short ("ES 06-16").I place only the entry BUY LMT in OnBarUpdate
    ENTRY level 0 | 2042.75 --- EXIT level 0 | 2043.25
    ENTRY level 1 | 2042.25 --- EXIT level 1 | 2042.75
    Code:
    [COLOR=blue][FONT=&quot]namespace[/FONT][/COLOR][COLOR=#080808][FONT=&quot]NinjaTrader[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]NinjaScript[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Strategies[/FONT][/COLOR][COLOR=black][FONT=&quot]{[/FONT][/COLOR]
    [COLOR=blue][FONT=&quot]public[/FONT][/COLOR][COLOR=blue][FONT=&quot]class[/FONT][/COLOR][COLOR=black][FONT=&quot] MyTest[/FONT][/COLOR][COLOR=black][FONT=&quot]: [/FONT][/COLOR][COLOR=#080808][FONT=&quot]Strategy[/FONT][/COLOR][COLOR=black][FONT=&quot]{[/FONT][/COLOR]
    [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot] override [/FONT][/COLOR][COLOR=blue][FONT=&quot]void [/FONT][/COLOR][COLOR=#080808][FONT=&quot]OnStateChange[/FONT][/COLOR][COLOR=black][FONT=&quot]()[/FONT][/COLOR][COLOR=black][FONT=&quot]{[/FONT][/COLOR]
    [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot] ([/FONT][/COLOR][COLOR=#080808][FONT=&quot]State[/FONT][/COLOR][COLOR=black][FONT=&quot] == [/FONT][/COLOR][COLOR=#080808][FONT=&quot]State[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]SetDefaults[/FONT][/COLOR][COLOR=black][FONT=&quot]) {[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]Description[/FONT][/COLOR][COLOR=black][FONT=&quot]  = [/FONT][/COLOR][COLOR=firebrick][FONT=&quot]@"[/FONT][/COLOR][COLOR=firebrick][FONT=&quot][COLOR=firebrick][FONT=&quot]MyTest[/FONT][/COLOR]"[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]Name[/FONT][/COLOR][COLOR=black][FONT=&quot]= [/FONT][/COLOR][COLOR=firebrick][FONT=&quot]""[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]Calculate[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Calculate[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]OnBarClose[/FONT][/COLOR][COLOR=black][FONT=&quot]; [/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]EntriesPerDirection[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=darkorange][FONT=&quot]100[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]EntryHandling[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]EntryHandling[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]AllEntries[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]IsExitOnSessionCloseStrategy[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=blue][FONT=&quot]false[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]IsFillLimitOnTouch[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=blue][FONT=&quot]false[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]MaximumBarsLookBack[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]MaximumBarsLookBack[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Infinite[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]OrderFillResolution[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]OrderFillResolution[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Standard[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]Slippage[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=darkorange][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]StartBehavior[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]StartBehavior[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]ImmediatelySubmitSynchronizeAccount[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]TimeInForce[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]TimeInForce[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Gtc[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]TraceOrders[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=blue][FONT=&quot]true[/FONT][/COLOR][COLOR=black][FONT=&quot];                                                
    [/FONT][/COLOR][COLOR=#080808][FONT=&quot]RealtimeErrorHandling[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]RealtimeErrorHandling[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]IgnoreAllErrors[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]StopTargetHandling[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]StopTargetHandling[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]PerEntryExecution[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]BarsRequiredToTrade[/FONT][/COLOR][COLOR=black][FONT=&quot] =[/FONT][/COLOR][COLOR=darkorange][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]DisconnectDelaySeconds[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=darkorange][FONT=&quot]100[/FONT][/COLOR][COLOR=black][FONT=&quot]; [/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]IsUnmanaged[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=blue][FONT=&quot]false[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR][COLOR=black][FONT=&quot]}[/FONT][/COLOR]  
    [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot]override[/FONT][/COLOR][COLOR=blue][FONT=&quot]void[/FONT][/COLOR][COLOR=#080808][FONT=&quot]OnBarUpdate[/FONT][/COLOR][COLOR=black][FONT=&quot]()[/FONT][/COLOR][COLOR=black][FONT=&quot]{[/FONT][/COLOR]
    [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot] ([/FONT][/COLOR][COLOR=#080808][FONT=&quot]CurrentBar[/FONT][/COLOR][COLOR=black][FONT=&quot]<[/FONT][/COLOR][COLOR=#080808][FONT=&quot]BarsRequiredToTrade[/FONT][/COLOR][COLOR=black][FONT=&quot])[/FONT][/COLOR][COLOR=black][FONT=&quot]{[/FONT][/COLOR][COLOR=blue][FONT=&quot]return[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR][COLOR=black][FONT=&quot]}[/FONT][/COLOR]
    [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot] ([/FONT][/COLOR][COLOR=#080808][FONT=&quot]IsFirst[/FONT][/COLOR][COLOR=black][FONT=&quot]==[/FONT][/COLOR][COLOR=blue][FONT=&quot]false[/FONT][/COLOR][COLOR=black][FONT=&quot]){ [/FONT][/COLOR][COLOR=black][FONT=&quot]//[/FONT][/COLOR][COLOR=#080808][FONT=&quot]IsFirst[/FONT][/COLOR][COLOR=black][FONT=&quot]: is first time; i execute my orders once, [/FONT][/COLOR] 
    [COLOR=#080808][FONT=&quot]IsFirst[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=blue][FONT=&quot]true[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]priceval[/FONT][/COLOR]=[COLOR=#080808][FONT=&quot]GetCurrentAsk[/FONT][/COLOR][COLOR=black][FONT=&quot]();
    [/FONT][/COLOR][COLOR=blue][FONT=&quot]for[/FONT][/COLOR][COLOR=black][FONT=&quot]([/FONT][/COLOR][COLOR=blue][FONT=&quot]int[/FONT][/COLOR][COLOR=#080808][FONT=&quot] i[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=darkorange][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR][COLOR=#080808][FONT=&quot]i[/FONT][/COLOR][COLOR=black][FONT=&quot]<nb[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR][COLOR=#080808][FONT=&quot]i[/FONT][/COLOR][COLOR=black][FONT=&quot]++){[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]Order[/FONT][/COLOR][COLOR=#080808][FONT=&quot] OrderE[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]OrderE[/FONT][/COLOR][COLOR=black][FONT=&quot]=[/FONT][/COLOR][COLOR=#080808][FONT=&quot]EnterLongLimit[/FONT][/COLOR][COLOR=black][FONT=&quot]([/FONT][/COLOR][COLOR=#080808][FONT=&quot]qty[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=#080808][FONT=&quot]price[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=firebrick][FONT=&quot]"entryL"[/FONT][/COLOR][COLOR=black][FONT=&quot]+[/FONT][/COLOR][COLOR=#080808][FONT=&quot]i[/FONT][/COLOR][COLOR=black][FONT=&quot]);[/FONT][/COLOR]
    [COLOR=#080808][FONT=&quot]lstS[/FONT][/COLOR][COLOR=black][FONT=&quot].[/FONT][/COLOR][COLOR=#080808][FONT=&quot]Add[/FONT][/COLOR][COLOR=black][FONT=&quot]([/FONT][/COLOR][COLOR=#080808][FONT=&quot]i[/FONT][/COLOR][COLOR=black][FONT=&quot],[/FONT][/COLOR][COLOR=#080808][FONT=&quot]OrderS[/FONT][/COLOR][COLOR=black][FONT=&quot]);[/FONT][/COLOR][COLOR=black][FONT=&quot]} [FONT=&quot]} [FONT=&quot]}
    [/FONT][/FONT][/FONT][/COLOR]
    I get an error for each order:2016-05-17 6:03:00 PM Strategy 'MyTest/75461805':Cancelled expired order: BarsInProgress=0, orderId='NT-00000-21' account='Sim101' name='entryGTL0' orderState=Working instrument='ES 06-16' orderAction=Buy orderType='Limit' limitPrice=2042.75 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 gtd='2099-12-01'
    Last edited by soma8; 05-23-2016, 04:45 AM.

    #2
    Hello,

    Thank you for the qustion.

    In general the message Cancelled expired order can mean that the order was cancelled because you had not re armed the order on the next bar. If the order is meant to persist more than 1 bar you would either need to ensure the logic remains true for that span of bars or use the LiveUntilCancelled overload set.



    EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)

    using true for liveUntilCancelled would keep the order open for multiple bars or until you cancel it. Can you check if this was the cause of the error?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, it works

      Please can you explain how to browse the current orders on the market, thanks

      Comment


        #4
        Hello,

        I am unsure I understand the wording for the question, are you asking how to check what orders the strategy you have created currently has open?

        Or are you referring to checking orders that are in the market, I.E. like the Superdom rows or depth of market?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks,

          I asking how to check all open orders by strategy.

          Comment


            #6
            Hello,

            Thank you for clairifying.

            Do you want to check this in the strategy or from the user interface to know what the strategy is doing?

            A strategy can be programmed to hold on to the orders as Variables, you could then retrieve information about each order from an Order variable to do logic. If this is what you are trying to do, the following example shows how to store an order as a variable, and later access its values.

            The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


            If you want to just see this from the user interface, you can open a second chart to the same instrument, then open a ChartTrader. This would display any active orders on the selected account.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by usazencort, Today, 01:16 AM
              0 responses
              1 view
              0 likes
              Last Post usazencort  
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              602 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              20 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Working...
              X