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

strategy halts/stops after first call to SubmitOrderUnamanged

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

    strategy halts/stops after first call to SubmitOrderUnamanged

    Hi,
    my strategy suddenly stops (does not even print debug messages after the first occurrence of an un-managed order... Any hints what might be wrong?
    IsUnmanaged = true; (OnStateChange/Set defaults)
    ...
    the call:
    entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, tradeSignal);

    entryOrder is defined (as data obj of the strategy):
    private Order entryOrder = null;

    the log:
    8:26 AM OnBarUpdate [BarsInProgress:1] => current bars:845
    8:27 AM OnBarUpdate [BarsInProgress:1] => current bars:846
    8:28 AM OnBarUpdate [BarsInProgress:1] => current bars:847
    8:28 AM OnBarUpdate [BarsInProgress:0] => current bars:37
    8:28:57 AM AutoPeriod = 4
    Enter SHORT: position quantity = 0x Flat => tradeSignal = -1
    3/23/2020 8:28:57 AM Strategy 'DeployNLS2003/-1': Entered internal SubmitOrderUnmanaged() method at 3/23/2020 8:28:57 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=-1 LimitPrice=0 StopPrice=0 SignalName=''
    Sate: defaults set
    Sate: defaults set
    Sate: defaults set
    Sate: defaults set
    ...
    ?

    I am new to UnmanagedOrder methods

    thank you -

    #2
    Hello momchi,

    Thank you for your note.

    When the strategy is enabled, do you see any errors in the Log tab of the Control Center? If so, what is the full text of the error?

    Does the strategy remain enabled, or does it disable itself?

    Do you see the entry order get placed/fill? Or does nothing at all occur after you see the notation regarding the SubmitOrderUnmanaged?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3

      Originally posted by NinjaTrader_Kate View Post
      Hello momchi,

      Thank you for your note.

      When the strategy is enabled, do you see any errors in the Log tab of the Control Center? If so, what is the full text of the error?

      Does the strategy remain enabled, or does it disable itself?

      Do you see the entry order get placed/fill? Or does nothing at all occur after you see the notation regarding the SubmitOrderUnmanaged?

      Thanks in advance; I look forward to assisting you further.
      Hi Kate, thanks for responding -
      interesting suggestion to try enable the strategy, result that I was originally describing was during Backtesting.

      A) So here is my log during Backtesting:
      ----------------
      State: Configured done.
      6:02 PMState: Data Loaded
      7:45 PM Processing main series ...
      ....
      8:28 AM Processing main series ...
      8:28 AM Enter SHORT: position quantity = 0x Flat => tradeSignal = -1
      3/23/2020 8:28:57 AM Strategy 'DeployNLS2003/-1': Entered internal SubmitOrderUnmanaged() method at 3/23/2020 8:28:57 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=-1 LimitPrice=0 StopPrice=0 SignalName=''
      Sate: defaults set
      Sate: defaults set
      Sate: defaults set

      Notice: after the first order - "Processing main series" stops (means OnBarUpdate() no longer called at all). Also does not seem to reach end of the OnBarUpdate method:
      if( entryOrder != null )
      Print(Times[BarsInProgress][0].ToShortTimeString() + " END OF OnBarUpdate... order state: " + entryOrder.OrderState.ToString() );
      else
      Print(Times[BarsInProgress][0].ToShortTimeString() + " END OF OnBarUpdate... order state: N/A" );
      does not print anything!?

      B) when run in simulation, instance of the strategy on an account - it, actually, reaches much further! It executes two orders, even checks their state - but then, also "just stops" with no error or warning in neither of the log files...?!

      Example:
      State: Configured done.
      6:04 PMState: Data Loaded
      6:16 PM Processing main series ...
      ....
      9:08 AM Processing main series ...
      9:08 AM Enter LONG: position quantity = 0x Flat => tradeSignal = 1
      3/30/2020 9:08:53 AM Strategy 'DeployNLS2003/137464090': Entered internal SubmitOrderUnmanaged() method at 3/30/2020 9:08:53 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName=''
      9:08 AM END OF OnBarUpdate... order state: Working
      9:25 AM Processing main series ...
      9:25 AM END OF OnBarUpdate... order state: Filled
      9:30 AM Processing main series ...
      9:30 AM END OF OnBarUpdate... order state: Filled
      9:32 AM Processing main series ...
      9:32 AM Enter SHORT: position quantity = 1x Long => tradeSignal = -2
      3/30/2020 9:32:47 AM Strategy 'DeployNLS2003/137464090': Entered internal SubmitOrderUnmanaged() method at 3/30/2020 9:32:47 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=-2 LimitPrice=0 StopPrice=0 SignalName=''

      after the second order - nothing seems to be running, and it does not print the "END OF OnBarUpdate" debug message...
      The strategy does disable itself after that.

      One thing that I might be doing wrong is that my entryOrder reference is defined as a strategy data-object:

      public class DeployNLS2003 : Strategy
      {
      ...
      private Order entryOrder;
      ...
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      ....
      entryOrder = null; // unmanaged only

      is this alright? I wanted the order reference to be kept "more static" between the calls to OnBarUpdate.

      Any suggestions would be very appreciated!!!

      Comment


        #4
        Hi Kate,

        that's totally embarrassing! Found out that due to a bug in my code, I was submitting the SubmitOrderUnmanaged() for shorts with a negative quantity i.e. -1 or -2 ...
        Once this was corrected all orders proceed as they should. Thank you for looking into this!

        Now you know what to check for when someone says "my orders are halting" LOL ....

        Comment


          #5
          Hello momchi,

          Thank you for your reply.

          Ah ha! That would do it. Looking at it again I see where I didn't catch that -1 quantity in the print when it enters the SubmitOrderUnmanaged - I think my brain just thought it was part of the equals sign. Glad you got it worked out.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          0 views
          0 likes
          Last Post adeelshahzad  
          Started by CortexZenUSA, Today, 12:53 AM
          0 responses
          2 views
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          5 views
          0 likes
          Last Post usazencortex  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,266 views
          0 likes
          Last Post sidlercom80  
          Working...
          X