Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems when re-enabling strategy in sim with realtime data

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

    Problems when re-enabling strategy in sim with realtime data

    Hello,
    I am running a strategy in sim mode, openning 2 positions and using SetStopLoss to set stop for both. When the strategy runs live, trades and orders are triggerd fine.
    If for some reason a connection is lost or the strategy is dissabled and I try to synchronise and re-enable I have the following problems:

    1. The old orders remain in working condition so I need to cancel them manually. Some old orders are even stuck and are shown as cancel pending (see attached image)

    2. When new orders are submitted, only one stop loss is set.

    What am I doing wrong?

    Here is my code


    else if (State == State.Realtime)
    {
    // one time only, as we transition from historical
    // convert any old historical order object references
    // to the new live order submitted to the real-time account
    if (longEntryOrder1 != null)
    longEntryOrder1 = GetRealtimeOrder(longEntryOrder1);

    if (longEntryOrder2 != null)
    longEntryOrder2 = GetRealtimeOrder(longEntryOrder2);


    if (shortEntryOrder1 != null)
    shortEntryOrder1 = GetRealtimeOrder(shortEntryOrder1);

    if (shortEntryOrder2 != null)
    shortEntryOrder2 = GetRealtimeOrder(shortEntryOrder2);
    }


    void Buy()
    {
    if (TradingFutures)
    {
    lots = (int) (InitialCapital / 50000);

    longEntryOrder1 = EnterLong ( lots , "L1");
    longEntryOrder2 = EnterLong ( lots , "L2");

    base.SetStopLoss("L1", CalculationMode.Price, stopPrice, false );
    base.SetStopLoss("L2", CalculationMode.Price, stopPrice, false );

    base.SetProfitTarget("L1", CalculationMode.Price, Ptarget, false);

    }

    }

    Kind regards
    Ioannis

    #2

    Hello Ioannis,

    Thank you for your post.

    To clarify, the behavior only occurs after a connection loss, is that correct? If you remove and re-add the strategy does the behavior go back to normal?

    "Stuck" orders can happen, but generally we see this with Sim accounts. Are you running this on your live account, or are you using Sim?

    Please write into to PlatformSupport[AT]NinjaTrader[DOT]Com along with your log and trace files and a link to this forum post.

    Include ticket number 2150628 in the body of the email.

    Please follow the steps below to manually attach your log and trace files to your response so I may investigate this matter further.
    Open your NinjaTrader folder under Documents.
    Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    Send the 2 compressed folders as attachments to this email.
    Once complete, you can delete these compressed folders.

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      Hello Kate,

      I am only running this on sim so far.

      As I am running it now I only have one stop triggered - how can this be? Strategy is set to immediately submit and synchronize account.

      If a strategy is disabled and re-enabled without losing connection there doesn't seem to be a problem with old orders being left stuck and no new orders are submitted.

      The problem arises once the connection is lost or say i need to shut down my pc and restart it. Then old orders are left there running - again how can this be as these are supposed to be OCO orders related to L1 and L2 ? And only one stop loss is set.

      I will also email platform support.

      Kind regards

      Ioannis

      Comment


        #4
        Hello Ioannis,

        Thank you for your reply.

        I haven't seen any tickets come in to the platform support queue for you as of yet, but I'll keep an eye out.

        Are these stuck orders filled? Or are these leftover orders your stops/targets? If you could provide screenshots of the behavior you're experiencing it would help me understand what exactly is going on.

        Thanks in advance; I look forward to assisting you further.

        Comment


          #5
          Hello Kate,

          I am now running the strategy live.

          When the order is triggered from an immediately submit and synchronize start behavior, only one stop and one profit target order is submitted. The other stop order I have to manually submit ! Even when the stop loss price is updated the problem persists.

          Please advise on how to resolve this.

          Kind regards

          Ioannis

          Comment


            #6
            Hello Ioannis,

            Thank you for your reply.

            Have you received my latest email from our ticketing system? Please reply to that as I'd like to keep the bulk of the issue in one place so I am better able to track the problem.

            Additionally, in your reply, please again follow the steps below to manually attach your log and trace files to your response so I may take a look at what is happening with your stops. If you are comfortable, larger samples of your strategy code would be helpful as well, as in your previous post I cannot see where the Buy() method is being called.
            • Open your NinjaTrader folder under Documents.
            • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
            • Send the 2 compressed folders as attachments to this email.
            • Once complete, you can delete these compressed folders.
            Thanks in advance; I look forward to assisting you further.

            Comment


              #7
              Hello Kate

              I have replied with part of my code.

              kind regards

              Ioannis

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              49 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              67 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X