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

Minimum bars required condition.

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

    Minimum bars required condition.

    When applying any strategy, one of the options in the drop down box is "minimum bars required". I always thought that it was "minimum " since start of market session. However, I see the signals begin with the first bar or well before the 20th bar. How can i fix that? Thanks.

    #2
    Hi ju1234,

    This input specifies the minimum number of bars before the backtest will start processing fills.



    For your needs, you could specify a time filter condition to limit the trading hours of your strategy - http://www.ninjatrader-support2.com/...ead.php?t=3226
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I am talking about applying the strategy to the live chart for generating signals (not the backtesting chart). The "minimum bars required" is part of the properties of the chart. The default value is 20. I have used a different number also. Still i notice that sometimes the buy or sell signal is genrated before the 20 bars (20 bars since the session began). The staochastics would not even be valid before at least those many number of bars because the price may be totally higher or lower than the closing time of the chart. Thanks.

      Comment


        #4
        ju1234,

        If you have min bars = 20 no strategy logic is even triggered until you have 20 bars on the chart. This is not 20 real-time bars. This is just 20 bars on the chart. You can verify this yourself by printing the Time[0] of the first bar that gets processed and match it up with the chart.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          You mean it is not "20 bars since the start of session" instead it is 20 bars on the entire chart? If that is correct, how can I make it X number of bars since the session start. The time frame in the chart properties does not work because that just starts the chart at a later date.

          The reason I am being so particular about this condition is: say the closing price of ES yesterday was 890. Today it opens at 880. The chart is continuous except for a devider line in between. The price change by itself moves the stochastics or other indicator down to the bottom of the range, but it is not a true change and it would trigger a buy although it would be a false signal. Are you with me. Thanks.

          Comment


            #6
            Not fully sure I follow - you should have a complete chart including the overnight action when setting your chart session times to 24hrs display.

            You could use FirstBarOfSession (http://www.ninjatrader-support.com/H...OfSession.html) in NinjaScript and count your elapsed bars since it returned true.

            Or you could add a time filter to your strategy, you could set it for example to trade only from 9:45 - 15:45 to let the market settle when the opening orders come in...

            See this reference sample here for details - http://www.ninjatrader-support2.com/...ead.php?t=3226
            BertrandNinjaTrader Customer Service

            Comment


              #7
              That is a good idea, but is there a way to add this condition through the wizard?

              Comment


                #8
                ju1234,

                Just use the Time node in the Condition Builder to create a time filter.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Iam also having a similar type of problem. One of the Moving average I use is 50 in my strategy. If i say minimum bars required as 20 none of the trades happen in the strategy but as soon as I make minimum bars required as 50 or more trades start happening. Why is it so ?

                  Comment


                    #10
                    I replied to you in your separate thread on this issue. Thanks
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      NT enhancement request: also log exceptions to Output window by default

                      Originally posted by kassaindia View Post
                      Iam also having a similar type of problem. One of the Moving average I use is 50 in my strategy. If i say minimum bars required as 20 none of the trades happen in the strategy but as soon as I make minimum bars required as 50 or more trades start happening. Why is it so ?
                      I think that NinjaTrader is most likely quietly (via just logging to trace log file) handling an exception in your scenario (I just recently had similar mystery why my Indicator wasn't plotting). It would be nice if Ninja also outputted exceptions to the Output window by default (or via global setting) - e.g., via the Print() method.

                      Here's a pattern you can use to quickly see if you are having any runtime errors via the Output window that you might not otherwise be aware of if you are not monitoring actual logs (...\Documents\NinjaTrader 6.5\trace\trace.*.txt):

                      Code:
                              protected override void OnBarUpdate() {
                                  try {
                                      //Your code here...
                                  } catch (Exception e) {
                                      Print(String.Format("Exception message: {0}", e.Message));
                                      Print(String.Format("Exception stack: {0}", e.StackTrace));
                                      if (e.InnerException != null)
                                          Print(String.Format("Exception inner stack: {0}", e.InnerException.StackTrace));
                                      throw;
                                  }
                              }
                      JD
                      Last edited by jdfagan; 06-03-2010, 08:59 PM.

                      Comment


                        #12
                        Thanks for the suggestion. I have added it to our feedback list.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jclose, Today, 09:37 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post jclose
                        by jclose
                         
                        Started by WeyldFalcon, 08-07-2020, 06:13 AM
                        10 responses
                        1,413 views
                        0 likes
                        Last Post Traderontheroad  
                        Started by firefoxforum12, Today, 08:53 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post firefoxforum12  
                        Started by stafe, Today, 08:34 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Started by sastrades, 01-31-2024, 10:19 PM
                        11 responses
                        169 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X