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

Accessing Weekly indicator values in minute based OnBarUpdate in Backtest

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

    Accessing Weekly indicator values in minute based OnBarUpdate in Backtest

    In my strategy I'm using an additional dataseries ( AddDataSeries(BarsPeriodType.Week, 1) to get the values of an weekly based indicator ( Momentum(Closes[1], 14) ).
    OnBarUpdate is called for my primary 1 minute dataseries.

    During a backtest, when I request the Momentum(Closes[1], 14)[0] in OnBarUpdate, let's say at Tuesday, 26. Nov 15:52, the value for which week will I actually receive ? The value for the current week ? But this should not be available because the week that includes Tuesday, 26 is not yet finished ?
    From my print logs it seems however that I receive exactly this value, which would distort the backtest's results, as it would take advantage of a future prediction.

    Evil trap ?

    #2
    Hello Derjan,

    In the use with 0 BarsAgo this would represent the last closed bars value so it would be the last weeks close while using a weekly input. A better way to explore this situation is to use a Print with the Times series and 0 BarsAgo:

    Code:
    Print(Times[1][0]);
    This would output the current bars time from the secondary series so you can see how it is processing and specifically what the last closed bar of the weekly series time was.

    You may be interested in doing a print like the following as well if you are using multiple series:

    Code:
    protected override void OnBarUpdate()
    {
       Print("BarsInProgress: " + BarsInProgress + " Time of bar: " + Time[0]);
    Whichever series calls OnBarUpdate will cause this print and show the order it was processed and time of the bar, this can help illuminate how the script processes and data being used.


    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Ok, here is the log output ( DD.MM.YYYY):

      Times[0][1]:22.10.2019 15:31:00 // = Tuesday

      Times[1][0]:18.10.2019 22:00:00 // = Friday
      Times[1][1]:11.10.2019 22:00:00 // = Friday

      Looks correctly.

      Thanks.



      Comment


        #4
        Accessing BzwOpeningRange indicator which was built by Patrick - I am getting double conversion issues -
        does anyone know the string for accessing this indicator high and low values? As you can see I use a multi-instrument series. Thanks to all


        if (BarsInProgress == 1)
        {
        ESFHOpeningRange = BzwOpeningRange4(Closes[1], @"1030");
        YMFHOpeningRange = BzwOpeningRange4(Closes[2], @"1030");
        NQFHOpeningRange = BzwOpeningRange4(Closes[3], @"1030");
        RTYFHOpeningRange = BzwOpeningRange4(Closes[4], @"1030");
        }

        if (BarsInProgress == 1)
        {
        ESFHHIGH = (ESFHOpeningRange.RangeHighSeries[0]);
        ESFHHIGH = (YMFHOpeningRange.RangeHighSeries[0]);
        ESFHHIGH = (NQFHOpeningRange.RangeHighSeries[0]);
        ESFHHIGH = (RTYFHOpeningRange.RangeHighSeries[0]);
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by GussJ, 03-04-2020, 03:11 PM
        15 responses
        3,276 views
        0 likes
        Last Post xiinteractive  
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        5 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X