Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting data on a secondary series

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

    Getting data on a secondary series

    Hi

    I sent this yesterday by email but I'm not sure the email system is working as have not received the regular auto-response (tried twice). Sorry for any duplication!


    I'm after some help with the an indicator I'm trying to write.

    I'm trying to load data from a secondary timeframe retrieving values of an indicator on the secondary timeframe so I can use those values to plot on the primary timeframe chart.

    I inherited the indicator which calculates the values I need (called NeuTrendForTimeframeTitan) and I'm creating an indicator called TimeframeTitan.


    NeuTrendForTimeframeTitan has 3 values that I'm looking to get:

    Trigger (double)

    Average (double)

    UpTrend (bool)

    I reviewed the SampleSyncSecondarySeries example from the help pages but my interpretation of this must be wrong as I'm getting the below error:

    Indicator 'Timeframe Titan': Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range

    Could you help me out with this?

    Code:
    private Series<double> primarySeries;
    private Series<double> htfTrigger;
    private Series<double> htfAverage;
    private Series<bool> htfUpTrend;
    [COLOR=#222222][FONT=Arial][/FONT][/COLOR]

    Code:
    else if (State == State.DataLoaded)
    {
    NeuTrend1 = NeuTrendForTimeframeTitan(false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
    Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
    
    primarySeries = new Series<double>(this, MaximumBarsLookBack.Infinite);
    htfTrigger = new Series<double>(SMA(BarsArray[1], 50), MaximumBarsLookBack.Infinite);
    htfAverage = new Series<double>(SMA(BarsArray[1], 50), MaximumBarsLookBack.Infinite);
    htfUpTrend = new Series<bool>(this, MaximumBarsLookBack.Infinite);
    }
    [COLOR=#222222][FONT=Arial][/FONT][/COLOR]

    Code:
    protected override void OnBarUpdate()
    {
    if (CurrentBar < BarsRequiredToPlot)
    return;
    
    if (BarsInProgress == 1)
    {
    if (CurrentBar < BarsRequiredToPlot) return;
    
    htfTrigger[0] = NeuTrend1.Trigger[0];
    htfAverage[0] = NeuTrend1.Average[0];
    htfUpTrend[0] = NeuTrend1.UpTrend[0];
    
    Print(Time[0] + " htfTrigger: " + htfTrigger[0] + " htfAverage: " + htfAverage[0] + " htfUpTrend: " + htfUpTrend[0]);
    }
    }
    
    
    [COLOR=#222222][FONT=Arial][/FONT][/COLOR]


    Thanks in advance
    Tim

    #2
    Hello Tim,

    If its coming from another timeframe, that's fine. Just be aware that plots are synchronized with the primary chart bars only and not with the secondary series.
    This means on any primary bar where the plot isn't getting a value from the secondary series, set this to the previous bars value to carry the line forward.

    Below is a link to an example.


    With the error "You are accessing an index with a value that is invalid since it is out-of-range", this means you are using an index that does not exist.

    Which specific line is causing the error?

    Is htfTrigger[0] = NeuTrend1.Trigger[0]; causing the error?

    Can you print NeuTrend1.Trigger[0] directly above this and see the value?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea

      I updated the code following the example you kindly provided but I'm still getting an error.

      The error is on this line: Indicator 'Timeframe Titan': Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range

      Code:
      HTFTrigger[0] = NeuTrend2.Trigger[0];
      and this is the updated code:

      Code:
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class TimeframeTitan : Indicator
      {
      
      private NeuTrendForTimeframeTitan NeuTrend1, NeuTrend2;
      private Series<bool> htfUpTrend;
      
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Name = "Timeframe Titan";
      Calculate = Calculate.OnBarClose;
      IsOverlay = true;
      tfValue = 69;
      AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Line, "HTF Trigger");
      AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Line, " HTF Average");
      AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Trigger");
      AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Average");
      }
      else if (State == State.DataLoaded)
      {
      NeuTrend1 = NeuTrendForTimeframeTitan(false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
      Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
      
      NeuTrend2 = NeuTrendForTimeframeTitan(BarsArray[1], false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
      Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
      }
      else if (State == State.Configure)
      {
      AddDataSeries((BarsPeriodType)103, tfValue);
      }
      }
      
      protected override void OnBarUpdate()
      {
      if (CurrentBar < BarsRequiredToPlot)
      return;
      
      if (BarsInProgress == 1 && CurrentBars[1] > 0)
      {
      HTFTrigger[0] = NeuTrend2.Trigger[0];
      HTFAverage[0] = NeuTrend2.Average[0];
      }
      
      else if (BarsInProgress == 0 && CurrentBars[0] > 0)
      {
      if (LTFTrigger[0] > 0) LTFTrigger[0] = NeuTrend1.Trigger[0];
      else LTFTrigger[0] = NeuTrend1.Trigger[1];
      
      if (LTFAverage[0] > 0) LTFAverage[0] = NeuTrend1.Average[0];
      else LTFAverage[0] = NeuTrend1.Average[1];
      }
      }
      #region Properties
      [NinjaScriptProperty]
      [Display(Name = "Timeframe Value", Description = "", Order = 1, GroupName = "Options")]
      public int tfValue
      { get; set; }
      
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> HTFTrigger
      {
      get { return Values[0]; }
      }
      
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> HTFAverage
      {
      get { return Values[1]; }
      }
      
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> LTFTrigger
      {
      get { return Values[2]; }
      }
      
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> LTFAverage
      {
      get { return Values[3]; }
      }
      #endregion
      }
      }
      Checking the values: NeuTrend2.Trigger[0] has value: 11561.311219053801 before the error is thrown.

      Not sure where I'm going wrong?

      Thanks

      Comment


        #4
        Hello Tim,

        Add prints before each line. Which print is the last to appear?

        Can you assign HTFTrigger[0] a value of 100 and then print HTFTrigger[0] to show it has 100 assigned?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Tim,

          Add prints before each line. Which print is the last to appear?

          Can you assign HTFTrigger[0] a value of 100 and then print HTFTrigger[0] to show it has 100 assigned?
          I tried that, but when trying to assign the value of 100, it returns below error on code: HTFTrigger[0] = 100; which I've placed within if (BarsInProgress == 1 && CurrentBars[1] > 0) section.

          System.ArgumentOutOfRangeException
          HResult=0x80131502
          Message=Index was out of range. Must be non-negative and less than the size of the collection.
          Parameter name: index
          Source=mscorlib
          StackTrace:
          at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
          at NinjaTrader.NinjaScript.Series`1.set_Item(Int32 barsAgo, T value)
          at NinjaTrader.NinjaScript.Indicators.TimeframeTitan. OnBarUpdate() in c:\Users\timcj\Documents\NinjaTrader 8\bin\Custom\Indicators\TimeframeTitan.cs:line 67
          at NinjaTrader.NinjaScript.NinjaScriptBase.Update(Int 32 idx, Int32 bip)

          Comment


            #6
            Hello timcjpfx,

            The code was changed so that these are plot series now instead of custom series. Plots are synchronized with the primary chart bars. Is CurrentBars[0] greater than 1?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello timcjpfx,

              The code was changed so that these are plot series now instead of custom series. Plots are synchronized with the primary chart bars. Is CurrentBars[0] greater than 1?
              Yes, I have a check for that. I changed the code to match the sample code you provided earlier.

              Here is the revised code:

              Code:
              namespace NinjaTrader.NinjaScript.Indicators
              {
              public class TimeframeTitan : Indicator
              {
              
              private NeuTrendForTimeframeTitan NeuTrend1, NeuTrend2;
              private Series<bool> htfUpTrend;
              
              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Name = "Timeframe Titan";
              Calculate = Calculate.OnBarClose;
              IsOverlay = true;
              tfValue = 69;
              AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Line, "HTF Trigger");
              AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Line, " HTF Average");
              AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Trigger");
              AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Average");
              }
              else if (State == State.DataLoaded)
              {
              NeuTrend1 = NeuTrendForTimeframeTitan(false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
              Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
              
              NeuTrend2 = NeuTrendForTimeframeTitan(BarsArray[1], false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
              Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
              }
              else if (State == State.Configure)
              {
              AddDataSeries((BarsPeriodType)103, tfValue);
              }
              }
              
              protected override void OnBarUpdate()
              {
              if (CurrentBar < BarsRequiredToPlot)
              return;
              
              if (BarsInProgress == 1 && CurrentBars[1] > 0)
              {
              HTFTrigger[0] = 100;
              Print(HTFTrigger[0]);
              
              Print("HTFTrigger[0] " + HTFTrigger[0]);
              Print("NeuTrend2.Trigger[0] " + NeuTrend2.Trigger[0]);
              HTFTrigger[0] = NeuTrend2.Trigger[0];
              
              Print("HTFAverage[0] " + HTFAverage[0]);
              Print("NeuTrend2.Average[0]" + NeuTrend2.Average[0]);
              HTFAverage[0] = NeuTrend2.Average[0];
              }
              
              else if (BarsInProgress == 0 && CurrentBars[0] > 0)
              {
              Print("LTFTrigger[0] " + LTFTrigger[0]);
              Print("NeuTrend1.Trigger[0] " + NeuTrend1.Trigger[0]);
              if (LTFTrigger[0] > 0) LTFTrigger[0] = NeuTrend1.Trigger[0];
              else LTFTrigger[0] = NeuTrend1.Trigger[1];
              
              Print("LTFAverage[0] " + LTFAverage[0]);
              Print("NeuTrend1.Average[0] " + NeuTrend1.Average[0]);
              if (LTFAverage[0] > 0) LTFAverage[0] = NeuTrend1.Average[0];
              else LTFAverage[0] = NeuTrend1.Average[1];
              }
              }
              #region Properties
              [NinjaScriptProperty]
              [Display(Name = "Timeframe Value", Description = "", Order = 1, GroupName = "Options")]
              public int tfValue
              { get; set; }
              
              [Browsable(false)]
              [XmlIgnore()]
              public Series<double> HTFTrigger
              {
              get { return Values[0]; }
              }
              
              [Browsable(false)]
              [XmlIgnore()]
              public Series<double> HTFAverage
              {
              get { return Values[1]; }
              }
              
              [Browsable(false)]
              [XmlIgnore()]
              public Series<double> LTFTrigger
              {
              get { return Values[2]; }
              }
              
              [Browsable(false)]
              [XmlIgnore()]
              public Series<double> LTFAverage
              {
              get { return Values[3]; }
              }
              #endregion
              }
              }

              Comment


                #8
                Hello timcjpfx,

                Looks like you have:
                if (BarsInProgress == 1 && CurrentBars[1] > 0)

                Please also check that CurrentBars[0] greater than 1.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello timcjpfx,

                  Looks like you have:
                  if (BarsInProgress == 1 && CurrentBars[1] > 0)

                  Please also check that CurrentBars[0] greater than 1.
                  Hi

                  That was already in there:

                  else if (BarsInProgress == 0 && CurrentBars[0] > 0)



                  Comment


                    #10
                    Hello timcjpfx,

                    That is a different if statement.

                    The issue is with calling HTFTrigger[0] = 100;.

                    Code:
                    if [B](BarsInProgress == 1 && CurrentBars[1] > 0)[/B]
                    {
                    HTFTrigger[0] = 100;
                    Print(HTFTrigger[0]);
                    
                    Print("HTFTrigger[0] " + HTFTrigger[0]);
                    Print("NeuTrend2.Trigger[0] " + NeuTrend2.Trigger[0]);
                    HTFTrigger[0] = NeuTrend2.Trigger[0];
                    
                    Print("HTFAverage[0] " + HTFAverage[0]);
                    Print("NeuTrend2.Average[0]" + NeuTrend2.Average[0]);
                    HTFAverage[0] = NeuTrend2.Average[0];
                    }
                    The else if is likely not the area causing the error.

                    Have you modified this and not provided the up-to-date code?

                    I am expecting to see 'if (BarsInProgress == 1 && CurrentBars[1] > 1 && CurrentBars[0] > 1)'
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello timcjpfx,

                      That is a different if statement.

                      The issue is with calling HTFTrigger[0] = 100;.

                      Code:
                      if [B](BarsInProgress == 1 && CurrentBars[1] > 0)[/B]
                      {
                      HTFTrigger[0] = 100;
                      Print(HTFTrigger[0]);
                      
                      Print("HTFTrigger[0] " + HTFTrigger[0]);
                      Print("NeuTrend2.Trigger[0] " + NeuTrend2.Trigger[0]);
                      HTFTrigger[0] = NeuTrend2.Trigger[0];
                      
                      Print("HTFAverage[0] " + HTFAverage[0]);
                      Print("NeuTrend2.Average[0]" + NeuTrend2.Average[0]);
                      HTFAverage[0] = NeuTrend2.Average[0];
                      }
                      The else if is likely not the area causing the error.

                      Have you modified this and not provided the up-to-date code?

                      I am expecting to see 'if (BarsInProgress == 1 && CurrentBars[1] > 1 && CurrentBars[0] > 1)'
                      Thanks Chelsea, after adding it to the statement you suggested, it stopped the error. I'm just checking the data as it looks a little odd on my chart. For the secondary series plots (higher time frame), I get lots of blanks, is that expected / how to get around it?

                      Comment


                        #12
                        Hello timcjpfx,

                        If no value is set, set the plot to the previous bars value to carry the plot forward.

                        This is demonstrated in the HigherTimeFrameIndicatorPlotExample example indicator on lines 66 and 67.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello timcjpfx,

                          If no value is set, set the plot to the previous bars value to carry the plot forward.

                          This is demonstrated in the HigherTimeFrameIndicatorPlotExample example indicator on lines 66 and 67.
                          Thanks again, I have the plot values repeating ok now.

                          One more thing I am trying to get to work.

                          As well as 2 plots, there is also a bool series (Uptrend) on the indicator whose value dictates what colour to paint the plots.
                          This works fine on the primary series (lower time frame) values, but for the higher time frame, it doesn't seem to work. (see image - the orange parts should be green)

                          Click image for larger version

Name:	Screenshot 2022-07-21 195421.png
Views:	491
Size:	26.1 KB
ID:	1209279

                          I'm using IsValidDataPoint as per the example, but I'm not sure it works with an added series?

                          Code:
                          else if (BarsInProgress == 0 && CurrentBars[0] > 1) // Primary Timeframe
                          {
                          LTFTrigger[0] = NeuTrend1.Trigger[0];
                          LTFAverage[0] = NeuTrend1.Average[0];
                          ltfUpTrend[0] = NeuTrend1.UpTrend[0];
                          
                          if (!Values[0].IsValidDataPoint(0))
                          Values[0][0] = Values[0][1];
                          if (!Values[1].IsValidDataPoint(0))
                          Values[1][0] = Values[1][1];
                          if (!ltfUpTrend.IsValidDataPoint(0))
                          ltfUpTrend[0] = ltfUpTrend[1];
                          
                          if (ltfUpTrend[0] == false)
                          {
                          PlotBrushes[2][0] = Brushes.Red;
                          PlotBrushes[3][0] = Brushes.Red;
                          }
                          else
                          {
                          PlotBrushes[2][0] = Brushes.Green;
                          PlotBrushes[3][0] = Brushes.Green;
                          }
                          
                          Print(Time[0] + " LTF --> Trigger: " + NeuTrend1.Trigger[0] + " Average: " + NeuTrend1.Average[0] + " UpTrend: " + NeuTrend1.UpTrend[0]);
                          }
                          for reference, here is the full version of the code:

                          Code:
                          namespace NinjaTrader.NinjaScript.Indicators
                          {
                          public class testTimeframeTitan : Indicator
                          {
                          
                          private NeuTrendForTimeframeTitan NeuTrend1, NeuTrend2;
                          private Series<bool> htfUpTrend, ltfUpTrend;
                          
                          protected override void OnStateChange()
                          {
                          if (State == State.SetDefaults)
                          {
                          Name = "Test Timeframe Titan";
                          Calculate = Calculate.OnBarClose;
                          IsOverlay = true;
                          tfValue = 69;
                          AddPlot(new Stroke(Brushes.Maroon, 2), PlotStyle.Line, "HTF Trigger");
                          AddPlot(new Stroke(Brushes.Maroon, 2), PlotStyle.Line, " HTF Average");
                          AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Trigger");
                          AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Average");
                          }
                          else if (State == State.DataLoaded)
                          {
                          NeuTrend1 = NeuTrendForTimeframeTitan(false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
                          Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
                          
                          NeuTrend2 = NeuTrendForTimeframeTitan(BarsArray[1], false, 30, Brushes.Green, Brushes.Red, false, 10, Brushes.Green,
                          Brushes.Red, false, "", false, Brushes.Green, Brushes.Red, Brushes.Green, Brushes.Red);
                          
                          htfUpTrend = new Series<bool>(this, MaximumBarsLookBack.Infinite);
                          ltfUpTrend = new Series<bool>(this, MaximumBarsLookBack.Infinite);
                          }
                          else if (State == State.Configure)
                          {
                          if (tfType == customTestTimeframeTitan.tfTypes.Minutes) AddDataSeries(BarsPeriodType.Minute, tfValue);
                          else if (tfType == customTestTimeframeTitan.tfTypes.Ticks) AddDataSeries(BarsPeriodType.Tick, tfValue);
                          else if (tfType == customTestTimeframeTitan.tfTypes.NeuBars) AddDataSeries((BarsPeriodType)103, tfValue);
                          }
                          }
                          
                          protected override void OnBarUpdate()
                          {
                          if (CurrentBar < BarsRequiredToPlot)
                          return;
                          
                          if (BarsInProgress == 1 && CurrentBars[1] > 1 && CurrentBars[0] > 1) // Secondary Timeframe
                          {
                          HTFTrigger[0] = NeuTrend2.Trigger[0];
                          HTFAverage[0] = NeuTrend2.Average[0];
                          htfUpTrend[0] = NeuTrend2.UpTrend[0];
                          
                          if (htfUpTrend[0] == true)
                          {
                          PlotBrushes[0][0] = Brushes.Green;
                          PlotBrushes[1][0] = Brushes.Green;
                          }
                          else
                          {
                          PlotBrushes[0][0] = Brushes.Red;
                          PlotBrushes[1][0] = Brushes.Red;
                          }
                          
                          Print(Time[0] + " HTF --> Trigger: " + NeuTrend2.Trigger[0] + " Average: " + NeuTrend2.Average[0] + " UpTrend: " + NeuTrend2.UpTrend[0]);
                          }
                          
                          else if (BarsInProgress == 0 && CurrentBars[0] > 1) // Primary Timeframe
                          {
                          LTFTrigger[0] = NeuTrend1.Trigger[0];
                          LTFAverage[0] = NeuTrend1.Average[0];
                          ltfUpTrend[0] = NeuTrend1.UpTrend[0];
                          
                          if (!Values[0].IsValidDataPoint(0))
                          Values[0][0] = Values[0][1];
                          if (!Values[1].IsValidDataPoint(0))
                          Values[1][0] = Values[1][1];
                          if (!ltfUpTrend.IsValidDataPoint(0))
                          ltfUpTrend[0] = ltfUpTrend[1];
                          
                          if (ltfUpTrend[0] == false)
                          {
                          PlotBrushes[2][0] = Brushes.Red;
                          PlotBrushes[3][0] = Brushes.Red;
                          }
                          else
                          {
                          PlotBrushes[2][0] = Brushes.Green;
                          PlotBrushes[3][0] = Brushes.Green;
                          }
                          
                          Print(Time[0] + " LTF --> Trigger: " + NeuTrend1.Trigger[0] + " Average: " + NeuTrend1.Average[0] + " UpTrend: " + NeuTrend1.UpTrend[0]);
                          }
                          }
                          #region Properties
                          [NinjaScriptProperty]
                          [Display(Name = "Timeframe Type", Description = "", Order = 0, GroupName = "Options")]
                          public customTestTimeframeTitan.tfTypes tfType
                          { get; set; }
                          
                          [NinjaScriptProperty]
                          [Display(Name = "Timeframe Value", Description = "", Order = 1, GroupName = "Options")]
                          public int tfValue
                          { get; set; }
                          
                          [Browsable(false)]
                          [XmlIgnore()]
                          public Series<double> HTFTrigger
                          {
                          get { return Values[0]; }
                          }
                          
                          [Browsable(false)]
                          [XmlIgnore()]
                          public Series<double> HTFAverage
                          {
                          get { return Values[1]; }
                          }
                          
                          [Browsable(false)]
                          [XmlIgnore()]
                          public Series<double> LTFTrigger
                          {
                          get { return Values[2]; }
                          }
                          
                          [Browsable(false)]
                          [XmlIgnore()]
                          public Series<double> LTFAverage
                          {
                          get { return Values[3]; }
                          }
                          #endregion
                          }
                          }
                          namespace customTestTimeframeTitan
                          {
                          public enum tfTypes
                          {
                          Minutes,
                          NeuBars,
                          Ticks,
                          }
                          }

                          Comment


                            #14
                            Hello timcjpfx

                            IsValidDataPoint() does work with added series, and with any series.

                            What isn't working?

                            The value of the bool is not what you expect?

                            Debug the script to understand the behavior.

                            When the bool is assigned a value, print the time of the bar, print a label for the bool variable, print the value of the bool.
                            Above the line where the bool is called, print the time of the bar, print a label for the bool variable, print the value of the bool.

                            Below is a link to a forum post that demonstrates using Print() to understand behavior.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello timcjpfx

                              IsValidDataPoint() does work with added series, and with any series.

                              What isn't working?

                              The value of the bool is not what you expect?

                              Debug the script to understand the behavior.

                              When the bool is assigned a value, print the time of the bar, print a label for the bool variable, print the value of the bool.
                              Above the line where the bool is called, print the time of the bar, print a label for the bool variable, print the value of the bool.

                              Below is a link to a forum post that demonstrates using Print() to understand behavior.
                              https://ninjatrader.com/support/foru...121#post791121

                              Thanks, the bool values were fine. Turns out I was just not painting the plots when BarsInProgress == 0. Needed to paint the higher time frame on both the primary and secondary BarsInProgress. Then it worked. Thanks again for your help.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              88 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              48 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              31 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              34 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              69 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X