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

Invisible orders created by strategy stuck as active executions

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

    Invisible orders created by strategy stuck as active executions

    Hello folks,

    I have a strategy which has an OnExecutionUpdate function that gets called as soon as i add the strategy to the chart and enable it. I have a print statement that confirms it ("Execution update func hit " message below. This should not happen as i have no current entries/orders and StartBehavior=WaitUntilFlat.


    The output window(see below for more details) shows an order from 3 days ago which does not appear anywhere In Control Center -> Orders or Executions tab.

    I have already tried the following:

    - deleting the strategy and creating a new one with the same code (which in theory should not see the orders places by another strategy)
    - i reset AND repaired the db from Tools -Database management menu and restarted ninja

    That stuck execution is still being printed out in my output window and i just cant remove it.

    Any suggestions on how to do so ?


    This is the code and logs below:

    protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity,
    Cbi.MarketPosition marketPosition, string orderId, DateTime time)
    {
    Print ("Execution update func hit " + isRealTimeCondition);

    //if(State != State.Realtime) {
    //if(isRealTimeCondition) {
    if(true) {
    Print("Order Id still on " + orderId.ToString());
    Print("Execution is still on " + execution.ToString());​


    -----------------------------------------------------


    Strategy 'BKScalpAllDayAlgo/322413107': An Enter() method to submit an entry order at '03/17/2024 18:22:00' has been ignored. Please search on the term 'Internal Order Handling Rules that Reduce Unwanted Positions' in the Help Guide for detailed explanation.
    Execution update func hit

    Order Id still on NT-00000-26
    Execution is still on execution='NT-00000-26' instrument='MNQ JUN24' account='Sim101' exchange=Default price=18100.25 quantity=1 marketPosition=Long orderId='NT-00000-26' time='2024-03-17 18:25:00' sod=False statementDate='0001-01-01'
    Execution update func hit

    Order Id still on NT-00001-26
    Execution is still on execution='NT-00001-26' instrument='MNQ JUN24' account='Sim101' exchange=Default price=18095.25 quantity=1 marketPosition=Short orderId='NT-00001-26' time='2024-03-17 18:33:00' sod=False statementDate='0001-01-01'​

    #2
    Hello polobocu77,

    Welcome to the NinjaTrader forums!

    Is the strategy placing historical orders? Do you have 'if (State == State.Historical) return;' at the top of OnBarUpdate()?
    Historical will also update OnExecutionUpdate() and OnOrderUpdate(), however these virtual orders will not be real-time orders placed to the account and will not show on the Executions tab or Orders tab of the Control Center. These will appear in the Strategy Performance window when Historical is selected.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I am not using State == State.Historical in OnBarUpdate() as i want to place trades (real-time and historical) for Stategy Analyzer backtestability purposes.

      I am using State property in OnExecutionUpdate() so that i can look at the profit of last trade from either AllTrades or RealTimeTrades collections (depending on whether i am in real time trades or historical/backtesting trades).

      The issue is when i am in real-time mode. In historical mode (strategy analyzer) it works fine.

      At this point i am thinking of manually tracking the profit of the previous trade (not relying on AllTrades/RealTimeTrades collections) via OnPositionUpdate() or OnOrderUpdate() just to avoid this historical/real-time mode complication. However at the moment OnExecutionUpdate is stuck on those 2 orders listed above in real-time mode (by the way they do not show up in historical mode) even if i create a brand new strategy with the same code. How is that possible when the new strategy should not be seeing the executions generated by the other/older strategy ?

      To me it seems like those orders are cached in the Ninjatrader platform somewhere and i can not clear them.

      Any suggestions on how to proceed ? At this time i am contemplating reinstalling Ninjatrader.


      Comment


        #4
        Hello polobocu77,

        I overlooked that this is posted in the NinjaTrader 7 section of the forums and not NinjaTrader Desktop (NinjaTrader 8).

        To confirm this is for NinjaTrader 7, correct?

        A strategy is only able to see orders that are submitted by the strategy. Likely these orders were submitted in historical data before the strategy reached realtime processing.

        What do you mean by 'stuck'?
        As in OnBarUpdate() is not updating for new bars?
        Or new orders are being ignored because there is already a position open?

        Do you mean you are printing the last trade from SystemPerformance in OnPositionUpdate() when the position becomes flat and State is State.Realtime, but there is no trade?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,403 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        94 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        6 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X