Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries Synchronization

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

    DataSeries Synchronization

    I am developing indicator which uses additional data series via AddDataSeries(). For example chart is 30min and added series is 1min (same instrument). On 1min TF I calculate some values (cumulative) and then plot them on chart (30min).

    For example:
    Code:
    if (BarsInProgress == 0)
    {
    Plot[0] = x;
    }
    else if (BarsInProgress == 1)
    {
    x = x + High[0];
    }​
    Issue is, same timestamp in OnBarUpdate BarsInProgress==0 fires before BIP==1, like this:

    BIP==0 (chart)
    Time[0] = 6:30:00

    BIP==1 (1min)
    Time[0] = 6:30:00

    ..so problem is that the last 1min value to be added (6:29:00 - 6:30:00) is missing and then is added to the next chart bar plot value. In Historical the the BIP==0 is always before BIP==1. In RealTime it changes.


    I came across this but dont know how to get it working in my situation:
    Code:
    else if (BarsInProgress == 1)
    {
    // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
    }​
    Last edited by Marty125; 11-21-2024, 09:09 PM.

    #2
    Hello Marty125,

    Assign the plot value from BarsInProgress 1 as well.

    else if (BarsInProgress == 1)
    {
    x = x + High[0];
    Plot[0] = x;
    }​​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      On the same TF (30min chart, 30min BIP1) the plot is the same (correct). But when the BIP1 data is less (1min) the plot is shifted 1 bar to the left.
      Last edited by Marty125; 11-22-2024, 09:55 AM.

      Comment


        #4
        Hello Marty125,

        To confirm, you only want to set the value if the primary bar has also closed?

        else if (BarsInProgress == 1)
        {
        x = x + High[0];

        if (Times[0][0] == Times[1][0])
        Plot[0] = x;​
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          To confirm, you only want to set the value if the primary bar has also closed?
          Yes (or at least for now). I think I have to play with Times[][] so that the value is updated in Plot[0] or in Plot[1].

          Comment


            #6
            I´ve got it... stupid little bool. Thank you ChelseaB.

            Code:
            bool main_series = false
            
            if (BarsInProgress == 0)
            {
            main_series = true
            Values[0][0] = x;
            }
            
            else if (BarsInProgress == 1)
            {
            x = x + High[0];
            
            if (main_series && (Time[0] == Times[0][0])
            {
            Values[0][0] = x;
            }
            
            }​​

            Comment


              #7
              Also whats the purpouse of using Series<T>?

              Code:
              private Series<double> x_plot = null;
              
              if (State == State.DataLoaded)
              {
              x_plot = new Series<double>(this);
              }
              
              
              and then OnBarUpdate:
              
              x_plot[0] = High[0] + Low[0];
              Value[0] = x_plot[0];

              Comment


                #8
                Hello Marty125,

                A Series<T> object holds a value for every bar on the chart.

                If you need to store a value for every bar, use a Series<T> object to store these.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Yeah, but are there any advantages compared to just using Value[0] (when using plot) ?

                  Comment


                    #10
                    Hello Marty125,

                    Value is also a Series<T> object, but will show as a plot on the chart.

                    A custom series would not show as a plot on the chart.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

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