Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Iorder

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

    Iorder

    I am trying to understand the sample Cancel Order but I have problems to get it.
    I checked the ninjatrader help guider Iorder, but still confused.

    What's does "null" mean? Can you explain in different words Iorder please?

    Thanks

    Daniel

    #2
    Daniel, the IOrder object is simply a C# object holding info (the properties you can access) for an order you issue. C# doesn't like emtpy objects to be accessed and thus you have to check for null before accessing your IOrder object :

    Comment


      #3
      Ok, thanks, just a couple more of questions:
      1) If barnumberoforder = 0
      and then barnumberoforder=CurrentBar
      CurrentBar >barNumberoforder +3

      I don't get it, Can you give me an example with numbers please

      2)Apart from Position.MarketPosition == MarketPosition.Flat, we also need if(entryOrder ==null && mar****rder == null && Close[0] > Close [1] just in case there were any working entry order, is that correct?

      Thanks

      Daniel

      Comment


        #4
        Daniel, barNumberOfOrder simply stores the CurrentBar value when the order was submitted so you have it as a reference later.

        CurrentBar now is 1023 and we submit our order, we store this value as well at this time in barNumberOfOrder, our variable.

        We can then later check the CurrentBar against the variable stored value to determine, if we submitted the order 3 bars ago and need to cancel it then if still not filled.

        Yes, the checks are the entry condition (Close > Open), a flat strategy position and emtpy IOrders so no order is already working.

        Comment


          #5
          refresh on script

          I did this script but it doesn't refresh when conditions changes.

          Can you help me to do the refresh on script?


          if( (diffArr.Get(CurrentBar)<diffArr.Get(CurrentBar - 1))
          && Close[1]>Open[1] && Close[0]<Open[0])){

          BackColor = ShortEntry;

          Ty

          Comment


            #6
            rev2011, welcome to our forums here - are you running the script then with CalculateOnBarClose set to false?

            Comment


              #7
              Yes, I'm running the script with CalculateOnBarClose set to false.

              Comment


                #8
                Then please try incorporating and else block in your condition setting the BackColor to Color.Emtpy when your conditions is not true - http://www.ninjatrader.com/support/h.../backcolor.htm

                Comment


                  #9
                  Ty Bertrand

                  The BackColor is fixed, but for the MACD Histogram to be up and down dif color is not fixed, it needs a refresh.

                  diffArr.Set(macd - macdAvg);

                  Value.Set(macd);
                  Avg.Set(macdAvg);
                  if( diffArr.Get(CurrentBar)>diffArr.Get(CurrentBar - 1)){
                  DiffUp.Set(macd - macdAvg);
                  } else {
                  DiffDown.Set(macd - macdAvg);
                  }

                  Comment


                    #10
                    I would suggest looking into the Plot.Reset method for those cases, so when you set the Up Plot, reset the Down Plot and vice versa.

                    Comment


                      #11
                      Do you have any link to it?

                      Comment


                        #12
                        You can look into the first reference sample here - http://www.ninjatrader.com/support/f...ead.php?t=3227

                        Comment


                          #13
                          Thanks a lot, perfectly explained.
                          Going on with SampleCancelorder, I have doubts with :
                          "entryOrder == Order" and "entryOrder == execution.Order"

                          What do they mean?

                          Thanks again

                          Daniel

                          Comment


                            #14
                            You're welcome, this code just checks which IOrder object calls the OnOrderUpdate() or the OnExecution(), just keep mind NT is event based, this will simplify understanding the operating structure.
                            Last edited by NinjaTrader_Bertrand; 11-26-2011, 01:03 PM.

                            Comment


                              #15
                              About the orders Bertrand, what's >0 ? I mean, in the code you can see:
                              if (execution. Order.OrderState==OrderStateFilled || execution.Order.OrderState == OrderState.PartFilled || ..... and at the end it is execution.Order.Filled > 0.

                              What does it mean?

                              Then it says: Resets the entry Order object to null after the order has been filled.
                              if (execution.Order.OrderState != OrderStgate.Prtfilled)
                              {
                              entry order = null;
                              }

                              Shouldn't it be:
                              if (execution.Order.OrderStgate ==OrderState.Filled)
                              {
                              entryOrder = null)
                              }

                              Comment

                              Latest Posts

                              Collapse

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