Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Timer with Customizable DataSeries for use in other Indicators/Strategies

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

    Bar Timer with Customizable DataSeries for use in other Indicators/Strategies

    Good Afternoon,
    I downloaded the BarTimerCounter indi from the EcoSystem link provided by
    HTML Code:
    https://forum.ninjatrader.com/member/96912-ninjatrader_manfred
    . I haven't tried that file but previously modified the BarTimer (attached below).
    I'm attempting to create an alert that I can use in other files by assigning a bool or dataseries if the time counts to below 15 seconds on a 1-minute chart.
    Partial code here:
    Code:
    else if (BarsPeriod.Value == 1)
                    {
                        if (barTimeLeft.Minutes < 1 && barTimeLeft.Seconds < 16)
                        {
                            if (!alerted15sec && SoundOn) PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\boathorn.wav");//new
                                alerted15sec = true;
    
                            _lessThan15Sec[0] = 1;
                        }
                        else
                        {
                            _lessThan15Sec[0] = 0;
                            alerted15sec = false;
    
                        }
                    }​
    It works as a DataSeries on my modified BarTimerv00 file but I'm trying unsuccessfully to get the other linking indicator attached using:
    Code:
    private BarTimerv00 btB0;
    //and
    btB0 = BarTimerv00(Inputs[0]);
    //and
    ​double btB0ltsec = btB0.LessThan15Sec.IsValidDataPoint(0) ? btB0.LessThan15Sec[0] : 0;
                ​
    Any thoughts or suggestions for this (or the parent script file)?
    Attached Files

    #2
    Hello zeller4,

    Is a series necessary?

    Is this just a bool you want to set? If so, you could use a public bool (with the Browesable(false) attribute).

    With a timer and a series you would need to use TriggerCustomEvent().



    And if calling from a host, it would likely be necessary to call .Update() on the indicator first.


    Note, this would not work in historical data.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      Thanks for your reply and I will look at what you posted to try out later this evening.

      In the meantime, I modified the sample time filter strategy with my inputs. See attached.
      error message I receive:
      Strategy 'SampleTimeFilterv00': Error on calling 'OnBarUpdate' method on bar 20: Index was outside the bounds of the array.
      i thought by adding
      Code:
      if (CurrentBar < BarsRequiredToTrade)
                  {
      
                      return;
                  }
                  ​
      I could resolve this common problem I run into. Please help towards a solution so I can learn for this and future projects. Thank you.


      Attached Files

      Comment


        #4
        Hello zeller4,

        Just to confirm, my previous suggestions were not helpful?

        You have testing setting a bool instead of a series?

        You are calling .Update() on the indicator first?

        The Timer is calling TriggerCustomEvent() before working any a series related objects?

        What is the specific line of code causing the error?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,
          Thanks for taking time with this.
          I read through your code on TriggerCustomEvent. If I understand correctly, the ForceRefresh() is doing the update? Or is there another way to do update? Normally, I do it in the properties section for the dataSeries but I didn't see you needed that.

          I will try to place my "rules" in the myTimer section /CustomMethod section.
          I'll let you know how it goes.

          Comment


            #6
            Hello zeller4,

            No, ForceRefresh() is used when doing something in OnRender() and you need to trigger a render pass.


            This is not related at all to synchronizing series before accessing them.
            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
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 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
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X