Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose = false

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

    CalculateOnBarClose = false

    Hi NT team

    I have a strategy where I would like to print a value on yesterday's bar close. When I use daily data, yesterday's bar will only close when a new bar begins. Or at least this is my understanding .

    Example:
    today is Dec 29, 2015
    closing daily data available as of Dec 28, 2015

    I would like to print
    if (ToDay(Time[0]) == 20151228)
    {Print("print something");}

    It will not work. How can I set the strategy to print? In NT7 it worked when I set CalculateOnBarClose = false;

    How do I do this in NT8?

    Thank you
    whotookmnickname

    #2
    Hello,

    Thank you for the question.

    I wanted to ask, by print on yesterdays close, do you mean print when the date is equal to yesterday or print every to get its close values?

    The condition you provided seems to not be related to this statement: closing daily data available as of Dec 28, 2015, are you looking for the closing data or are you looking to perform an action when that data is found?

    What you have provided would only work going forward through time meaning if you start at bar 0 and move toward the right of the chart, this would become true for each day that is 20151228 but once you reach the current day it could never become true again because the date is specific and in the past.

    Is this what you had intended or are you trying to get a specific value such as yesterdays close? Can you provide more detail on what specifically you are trying to do?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse

      Sorry, I was not very precise. I have a strategy which I backtest to generate daily signals. This strategy is run on weekly data, but I have added a daily bar into the strategy. I use weekly to determine the overall trend, and run my calculations on the daily bars. This is were most of the logic is. I would now like to print statistics, entries, etc into the output window for further use.

      I only want to print for that day when the condition is true:
      if (ToDay(Times[1][0]) == 20151228)
      {Print("print something");}

      The primary bar is a weekly bar, and I only add the daily bar to it. Now if I run the backtest until today (29.12.2015) with data until 28.12.2015, it will not print. In NT7 it worked fine when I set CalculateOnBarClose = false. In NT8 this function is not available. How can I achieve it that the strategy either prints something if (ToDay(Times[1][0]) == 20151228) or when the backtest has finished?

      Thank you, whotookmnickname

      Comment


        #4
        Hello,

        I tried the what you provided in your most recent reply on the ES, I do see a print for the daily bar that is equal to the day you provided.

        Are you certain you have a daily bar on the instrument you are testing with that is exactly equal to the date you provided?

        If you do have the daily bar for that day, could you tell me what instrument you are testing on and also make a test script that is the most simple you can make it that still demonstrates the issue? If I can see the whole scope of what logic is not working it may be more apparent what is happening on your end.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          This is the code. I use Kinetick EOD (free) data. I am connected to the data source. I run the "strategy" below on weekly data until the recent date where I have data available (13.01.2016). It prints for every daily bar until 12.01.2016, however it will not print for the last bar (=13.01.2016). In NT 7 I am able to print the last date (13.01.2016) of the backtest when I set CalculateOnBarClose = false;

          How can I print the information from the last bar (13.01.2016) ?

          ]
          Code:
          public class MyCustomStrategy1 : Strategy
              {
                  
                  protected override void OnStateChange()
                  {
                      if (State == State.SetDefaults)
                      {
                      Description     = "TestDescription"; 
                      Name            = "TestName";// 
                      Calculate        = Calculate.OnEachTick;
                      }
                      else if (State == State.Configure)
                      {
                          // Add a 5 minute Bars object to the strategy
                          AddDataSeries(BarsPeriodType.Day, 1);
                                          
                      }
                      
                  }
          
                  protected override void OnBarUpdate()
                  {
                      if (CurrentBar < BarsRequiredToTrade)
                          return;
          
                     
          
                      if (CurrentBars[0] < 1 || CurrentBars[1] < 1) 
                          return;
          
                              
                      if (BarsInProgress == 1)
                      {
                          int value1 = 1;
          
                          if (ToDay(Times[1][0]) > 20160101)
                          {
                              Print(ToDay(Times[1][0]) + value1);
                          }
                      }
                  }
                  
              }
          Last edited by whotookmynickname; 01-14-2016, 07:58 AM.

          Comment


            #6
            Hello,

            Thank you for the reply.

            I tried the sample but was unable to produce the described result.

            I have attached an image of the settings I had used in the Analyzer, can you confirm are you using the Analyzer or a Chart? CalculateOnBarClose or the Calculation mode does not apply in a Backtest so I was uncertain with your comment regarding this setting. This would apply in a chart, but in the Analyzer would have no effect. Instead a secondary series of a smaller value would be needed for intrabar granularity

            I look forward to being of further assistance.
            Attached Files
            JesseNinjaTrader Customer Service

            Comment


              #7
              Print something on last bar or on termination of backtest

              Hi Jesse,

              Thank you for your continuing effort to look into this. I am using the Analyzer. To test, please make sure you test this on a stock, the market for this stock cannot have opened on 14.1.2016 and you don't have finer granularity than weekly and daily data (last daily data available for 13.01.2016). It will just not print.

              Alternatively, you could let me know how I print some logic that was calculated during the backtest, when the backtest terminates for this particular symbol?

              These threads have similar problems:

              "signals are not being generated until the start of the next bar."--> as I don't have data for 14.1.2016, and don'^t have access to granular data until the market has opened, how can I process the last bar on 13.1.2016

              Comment


                #8
                Hello,

                Thank you for the reply.

                To ensure I do the same test, can you instead post the exact steps you are using including the instrument, dates picked etc? Could you include an image of the settings used?

                I am unsure what instrument you were using specifically so likely we are not doing the same actions. If I can reproduce what is happening I could likely explain much better what is the reason.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                15 views
                0 likes
                Last Post Pattontje  
                Started by flybuzz, 04-21-2024, 04:07 PM
                17 responses
                229 views
                0 likes
                Last Post TradingLoss  
                Started by agclub, 04-21-2024, 08:57 PM
                3 responses
                17 views
                0 likes
                Last Post TradingLoss  
                Started by TradingLoss, 04-21-2024, 04:32 PM
                4 responses
                44 views
                2 likes
                Last Post TradingLoss  
                Started by cre8able, 04-17-2024, 04:16 PM
                6 responses
                57 views
                0 likes
                Last Post cre8able  
                Working...
                X