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

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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.
            Kate W.NinjaTrader Customer Service

            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 funk10101, Today, 09:43 PM
              0 responses
              4 views
              0 likes
              Last Post funk10101  
              Started by pkefal, 04-11-2024, 07:39 AM
              11 responses
              36 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Yesterday, 08:51 AM
              8 responses
              44 views
              0 likes
              Last Post bill2023  
              Started by yertle, Today, 08:38 AM
              6 responses
              26 views
              0 likes
              Last Post ryjoga
              by ryjoga
               
              Started by algospoke, Yesterday, 06:40 PM
              2 responses
              24 views
              0 likes
              Last Post algospoke  
              Working...
              X