Announcement

Collapse
No announcement yet.

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.

    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 argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X