Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

backtesting problem

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

    #16
    Josh, I don't understand your reply. Are you saying that this code i wrote below is valid for one bar or until the order is filled?
    {
    // EnterLongLimit() can be used to generate buy orders.
    EnterLongLimit(highestHigh+TickSize);
    }

    Comment


      #17
      It is valid for any bar that it reaches that code block. If every single bar update comes and touches that line, then it will keep the order alive. Once that line is not processed in an OnBarUpdate() event, then the order will auto expire and cancel out. Perhaps this article will explain it: http://www.ninjatrader-support.com/H...tml?Overview36
      Josh P.NinjaTrader Customer Service

      Comment


        #18
        so in effect what you are saying is as long as the limit order is "touched" on say the next 10 bars and i am still not filled, the order will stay "live". what happens if the price has made it upward move and is on its way down and touches the "limit" price? does the order come alive again?

        i am using the onbarupdate() function and i would like to cancel the order if the order is not filled within 10 bars.

        Comment


          #19
          kaywai,

          No. What I am saying is that as long as the method is sent, it will stay alive. It has nothing to do with the price touching or not. If the method is called on every single OnBarUpdate() then it will stay alive for every single bar. It will only expire and cancel if you stop calling the Enter() method in code.
          Josh P.NinjaTrader Customer Service

          Comment


            #20
            josh, if you wouldn't mind, how do i stop calling the enter() method?

            Comment


              #21
              kaywai,

              You would need to add if-statements to limit your logic.

              Code:
              if (some condition)
                  EnterLongLimit();
              When the condition is no longer true, the code will stop submitting long limits and thus get the order expired.
              Josh P.NinjaTrader Customer Service

              Comment


                #22
                josh, this is what i have.

                if (Bars.BarsSinceSession > 20 && Close[0] >= highestHigh + TickSize)

                EnterLongLimit(highestHigh+TickSize);

                how can i code this to cancel if it is not filled within 10 bars?

                Comment


                  #23
                  kaywai,

                  Add yourself a counter in there.

                  Code:
                  if (conditions && counter < 10)
                  {
                      EnterLongLimit(...);
                      counter++;
                  }
                  Note: This will only work if you are using CalculateOnBarClose = true. If you are using false you will need to tweak it further.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    sorry josh, is "counter" a code? i can't seem to find it in the manual...
                    what is counter++?

                    if (Bars.BarsSinceSession > 20 && Close[0] >= highestHigh + TickSize) && counter < 10

                    EnterLongLimit(highestHigh+TickSize);
                    counter++

                    is that correct?

                    Comment


                      #25
                      josh, i'm very new to programming as you can gather and any help i can get is much appreciated

                      Comment


                        #26
                        kaywai,

                        It is any variable you make yourself with any name you want.

                        private int counter = 0;
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

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