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

How can I extend the life time of a pending order?

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

    How can I extend the life time of a pending order?

    Hello again
    Based on the references of the forum and in the instruction manual I have successfully created a strategy that puts pending orders via "Unmanaged Approach"
    So far so good.
    But the problem is in the duration of the pending orders, the orders last a time determined by
    Code:
    protected override void Initialize ()
    }
    Add (PeriodType.Minute, 5);
    }
    I need orders that do not expire in time or that I can handle durability regardless of (PeriodType.x, x);

    Entry order is
    Code:
     myIOrder = SubmitOrder (0, OrderAction.Sell, OrderType.Stop, contracts, 0, GetCurrentBid () - 10 * TickSize, "", "Entry Short")
    If the price is not reached in 5 minutes the order is canceled and updated with new price after the next 5 minutes
    I want the order to stay active regardless of the timeframe

    thank you very much

    #2
    Hello franki,

    Thanks for your post.

    In your initialize method it does not appear you are declaring the strategy to be unmanaged. If not then your strategy would be managed and the default behavior in managed is that orders are canceled if not filled at the end of the bar.

    Please see: https://ninjatrader.com/support/help...d_approach.htm
    and https://ninjatrader.com/support/help...?unmanaged.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello franki,

      Thanks for your post.

      In your initialize method it does not appear you are declaring the strategy to be unmanaged. If not then your strategy would be managed and the default behavior in managed is that orders are canceled if not filled at the end of the bar.

      Please see: https://ninjatrader.com/support/help...d_approach.htm
      and https://ninjatrader.com/support/help...?unmanaged.htm

      Thanks for answering Paul
      The two links that you have placed belong to the instruction manual that I followed for the configuration

      The complete initialize method is:
      Code:
       protected override void Initialize()
              {
                  CalculateOnBarClose = false;
      			Unmanaged = true;
      			ExitOnClose = true;
      			entryLong = null;
      			entryShort = null;
      			Add(PeriodType.Minute, 5);
              }
      Everything works fine in terms of the position and execution of the orders, the problem is that the lifetime of the orders is equal to "Add (PeriodType.Minute, 5);" and I need a longer life time for the orders without changing the timeframe "5 minutes"

      CalculateOnBarClose It is false because
      a specific period of time not linked to bars is supplied, it also does not influence the temporality of life of the orders, it is already tested

      Thx
      Last edited by franki; 03-21-2018, 06:37 AM.

      Comment


        #4
        Hello franki,

        Thanks for your reply and clarifications.

        Adding a dataseries would not cause the order to be canceled.

        I've attached a test unmanaged strategy script that will place 1 historical order and 1 real time order, using the code you have shown. I placed the strategy on 1 minute chart of ES 06-18. The historical order is placed in the first day of data loaded on the first down bar (after the first 20 bars). The order remains in place until filled, certainly longer than the added 5 minute bars and does not get canceled. On the real time, same thing the order is placed once and remains until filled Please feel free to test on the sim101 account.

        You may need to review your code for other conditions that would lead to an order being canceled.
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello franki,

          Thanks for your reply and clarifications.

          Adding a dataseries would not cause the order to be canceled.

          I've attached a test unmanaged strategy script that will place 1 historical order and 1 real time order, using the code you have shown. I placed the strategy on 1 minute chart of ES 06-18. The historical order is placed in the first day of data loaded on the first down bar (after the first 20 bars). The order remains in place until filled, certainly longer than the added 5 minute bars and does not get canceled. On the real time, same thing the order is placed once and remains until filled Please feel free to test on the sim101 account.

          You may need to review your code for other conditions that would lead to an order being canceled.
          Thank you very much Paul
          It is the solution to my problem, everything solved, I have had to adjust CalculateOnBarClose to true and lower the timeframe that generates the strategy and achieved my purpose.
          once again
          Thank you very much.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          6 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          6 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          166 views
          0 likes
          Last Post jeronymite  
          Started by cre8able, Today, 04:22 PM
          0 responses
          8 views
          0 likes
          Last Post cre8able  
          Started by RichStudent, Today, 04:21 PM
          0 responses
          5 views
          0 likes
          Last Post RichStudent  
          Working...
          X