Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

UnManaged = True problem

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

    UnManaged = True problem

    Hi all,

    Trying to create a Bracket Trade;

    I am using "SubmitOrder" in conjunction with "Unmanaged = True" as depicted in the snippet of code below.
    the problem however is that no orders are executed when the "if (entryOrder == null)" statement is included. without it the orders are made - just on every tick which is of course not the intention.



    Please assist


    private IOrder entryOrder = null; // This variable holds an object representing our entry order

    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    Unmanaged = true;

    }



    if (entryOrder == null)
    {
    /* The entryOrder object will take on a unique ID from our SubmitOrder()
    that we can use later for order identification purposes in the OnOrderUpdate() method. */

    entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "Enter Long");

    }

    #2
    Hello cocopod,

    Thank you for your note.

    I would expect the order to take place the first run through of the OnBarUpdate but anything there after would have no affect, as the IOrder object will be set to a value and not null.

    You would need to have a reset condition of your own that would reset the IOrder object back to null to place another order for it.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      entryOrder = null is the default

      Hi and thanks for your timely response.

      Actually no order is created even though the default value for the variable is null
      private IOrder entryOrder = null

      It appears to have something to do with the "If" statement because when removed I get an order every tick...

      if (entryOrder == null)
      {
      /* The entryOrder object will take on a unique ID from our SubmitOrder()
      that we can use later for order identification purposes in the OnOrderUpdate() method. */

      entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "Enter Long");

      }

      Comment


        #4
        cocopod,

        Have you tried using Print()'s in your script.
        I would like you to put -
        Print("I was null at " + Time[0]);

        inside the IF statement. You will also need to open the Output Window to see these prints, Tools -> Output Window

        http://www.ninjatrader.com/support/h...html?print.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Interesting

          In the output file I only have the following



          **NT** Enabling NinjaScript strategy 'Samsum/ecde57da85424fe99d5a26e5cdb53121' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=True EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
          I was null at 06/11/2014 23:12:30
          **NT** Error on calling 'OnExecution' method for strategy 'Samsum/ecde57da85424fe99d5a26e5cdb53121': 'ExitLong' method can't be called on unmanaged strategies.

          Comment


            #6
            Cocopod,

            There's the culprit,

            You cannot use the Managed Approach order methods with the Unmanaged set to true. You will need to use one or the other approach for your strategies.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hmmmm... no..its Synchronicity

              I removed the Methods related to the Managed approach. The remaining code is pasted below and the Output file is also below

              protected override void OnBarUpdate()
              {
              // Only Create order if none exists
              // Submit an entry limit order if we currently don't have an entry order open
              if (entryOrder == null)
              {
              /* The entryOrder object will take on a unique ID from our SubmitOrder()
              that we can use later for order identification purposes in the OnOrderUpdate() method. */

              Print("I was null at " + Time[0]);
              entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "Enter Long");
              }

              **NT** Enabling NinjaScript strategy 'Samsum/9653ca6ec5a84862aa88402a6e5daff2' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=True EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
              I was null at 06/11/2014 23:12:30

              Comment


                #8
                Cocopod,

                It looks like the print statement is being reached now, but the order is still not being placed?

                Do you see any errors in the log tab of the control center?
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  No...Nothing

                  Comment


                    #10
                    cocopod,

                    Please send me your script, so that I can test this on my end, to platformsupport [at] ninjatrader [dot] com

                    Put ATTN Cal in the subject, reference this thread in the body and attach the file, which can be found in (My) Documents -> NinjaTrader 7 -> bin -> Custom -> Strategies
                    Cal H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    558 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    324 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    545 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    547 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X