Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time and dataseries

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

    Time and dataseries

    Hello,

    I need to change in my code (which works ok in a minute chart) to run the calculations from BarsInProgress==1 (= minutes) because I want to add the indicator on my tickcharts (I would have too many charts when for all instruments the tickchart and always a minutechart for the calculations). But when adding if(BIP==1)... it doesnt work.

    if(BarsInProgress==1)
    {

    bool isTime = Time[0].TimeOfDay.CompareTo(startTime)>=0 && (Time[1].TimeOfDay.CompareTo(startTime)<0 || Time[0].Date!=Time[1].Date);

    // calculations for Tprice

    if (isTime)
    {LineStyle[0] = Closes[1][0]; Tprice=LineStyle[0];}
    else if (LineStyle.IsValidDataPoint(1))
    {LineStyle[0] = LineStyle[1]; Tprice=LineStyle[0];}
    }

    This works in a minutechart, but my line is not plotted in a tickchart. What do I miss please?

    Thank you!
    Tony
    Last edited by tonynt; 03-11-2022, 01:34 PM. Reason: translation error

    #2
    Hello tonynt,

    Thanks for your post.

    If you would like to calculate values from a secondary series, you would first need to add the secondary series to the script with AddDataSeries().

    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

    Then, if you would like to perform calculations on that added series, you would check if (BarsInProgress == 1) and add your logic.

    BarsInProgress: https://ninjatrader.com/support/help...inprogress.htm

    If you would like to access the Time for a secondary series, you could consider using Times[1][0].

    Times[1][0]: https://ninjatrader.com/support/help...ries_times.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello,

      thank you for your reply. I have added the dataseries and checked in the logic (I would have had error messages if not).

      My calculations are ok, but my line is not plotting (which is plotting correctly in a minute chart with Time[0] to access with BIP==0.

      The code for the plotting I have posted above.
      In properties I have
      public TimeSpan StartTime
      {
      get { return startTime; }
      set { startTime = value; }
      }

      [Browsable(false)]
      public string StartTimeS
      {
      get { return startTime.ToString(); }
      set { startTime = TimeSpan.Parse(value); }
      }

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> LineStyle
      {
      get { return Values[0]; }
      }

      What could be the reason that it is not plotting the line (I have with AddPlot(Brushes.DarkViolet, "LineStyle") and plots ok in the minute chart.

      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        Thanks for your note.

        I am not exactly sure what could be wrong with your script based on the information you shared.

        Whatever value is calculated from BarsInProgress 1 is going to be plotted at the primary series frequency.

        You could consider creating a class-level variable and assigning a value to that variable when BarsInProgress 1 is processing. Then, assign that variable value to the plot in BarsInProgress 0.

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Hello,

          thank you for your reply. The value (Tprice) calculated now in BIP1 is correct. It is correct now when I compare to the indicator in a minute-chart with calculating from primary dataseries. Perfect. How do I know without plotting the line? Because I have plotted the value as number in the chart. All perfect.

          But its not plotting the horizontal line with that value.

          I´m not sure if I understand your suggestion to resolve this. Do you mean like:
          if(BIP==0)
          {
          double PlotfromBIP1=Tprice;

          if (isTime)
          {LineStyle[0] = Closes[1][0]; PlotfromBIP1=LineStyle[0];}
          else if (LineStyle.IsValidDataPoint(1))
          {LineStyle[0] = LineStyle[1]; PlotfromBIP1=LineStyle[0];}
          }

          add info:
          I could make it plotting but it is plotting at the close of dataseries0. So its the same as I would have it calculated with BIP=0. How can I make it plotting with close of BIP=1 please (without running COBCfalse because of CPU)

          Thank you!
          Tony
          Last edited by tonynt; 03-12-2022, 07:19 AM. Reason: add info

          Comment


            #6
            Hello,

            I could make it by changing parts of the code one by another and it plots ok now. I have no idea why. lol

            Thank you for your support!

            Tony
            Last edited by tonynt; 03-12-2022, 08:42 AM. Reason: translation error

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            599 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            344 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
            557 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X