Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Timer Not Loading

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

    Bar Timer Not Loading

    Hello!

    Quick question, when I AddChartIndicator(BarTimer) it just never loads. Any idea what I am doing wrong?

    Thanks!

    #2
    Hello Vikuno1,

    Are you calling the indicator from the strategies OnBarUpdate? You would have to use the .Update() method with that indicator as it does not have any plots.

    Comment


      #3
      I am calling it from State.DataLoaded. Should I use the .Update() in OnBarUpdate still?

      Comment


        #4
        Hello Vikuno1.

        Yes you still need to call it from OnBarUpdate to have it process.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello Vikuno1.

          Yes you still need to call it from OnBarUpdate to have it process.
          Not quite what I was saying. Here is a sample script showing what I mean. I have added 2 stochastic indicators to the chart and it only adds 1 of them to the chart (I realize they have the same settings but even when I change them it doesn't display both). Changing the .Panel doesn't work either

          Let me know what I am doing wrong !
          Attached Files

          Comment


            #6
            Hello Vikuno1,

            If this is the specific code:

            stoch1 = StochasticsFast(3, 14);
            AddChartIndicator(stoch1); // 8
            // ChartIndicators[8].Panel = 2;
            stoch2 = StochasticsFast(3, 14);
            AddChartIndicator(stoch2); // 9

            That is because they are the same instance, you can't use AddChartIndicator twice on the same indicator. The values need to change from 3,14 to something else on one of the instances for it to be different. ​

            Comment


              #7
              Originally posted by NinjaTrader_Jesse View Post
              Hello Vikuno1,

              If this is the specific code:

              stoch1 = StochasticsFast(3, 14);
              AddChartIndicator(stoch1); // 8
              // ChartIndicators[8].Panel = 2;
              stoch2 = StochasticsFast(3, 14);
              AddChartIndicator(stoch2); // 9

              That is because they are the same instance, you can't use AddChartIndicator twice on the same indicator. The values need to change from 3,14 to something else on one of the instances for it to be different. ​
              Hey Jesse,

              Thanks for you response. I just realized I posted this on the wrong post but thank you for responding anyway.

              I went in and changed the inputs and still get the same result. Were you able to recreate that?

              Thanks!

              Comment


                #8
                Hello Vikuno1,

                DId you remove and re apply the strategy after making that change?

                Comment


                  #9
                  Hi Jesse, I tried to add BarTimer to the strategy so I got this

                  Code:
                  if (State == State.DataLoaded)
                  {
                  AddChartIndicator(BarTimer());
                  }​
                  Do I should add something in OnBarUpdate? what exacly? because I see it on the chart but the counter is not working.

                  It just says "BarTimer waiting for realtime data before starting" (when I tried in playback), in Live something says, not exacly that... anyways doesnt work neither

                  Comment


                    #10
                    I did, if someone need it, take it
                    Code:
                    namespace NinjaTrader.NinjaScript.Strategies
                    {
                    public class MomentumStrategy : Strategy
                    {
                    private BarTimer barTimer;
                    
                    protected override void OnStateChange()
                    {
                    
                    if (State == State.DataLoaded)
                    {
                    barTimer = BarTimer();
                    
                    AddChartIndicator(barTimer);
                    }
                    }
                    
                    protected override void OnBarUpdate()
                    {
                    if (CurrentBar < BarsRequiredToTrade)
                    return;
                    
                    if (barTimer != null)
                    barTimer.Update();
                    }
                    
                    }
                    }

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Today, 05:17 AM
                    0 responses
                    52 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    130 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    70 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    44 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    49 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X