Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.IsTickReplay

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

    Bars.IsTickReplay

    Hi,

    How would I prevent an indicator from running if Bars.IsTickReplay is set?
    I've tried
    Code:
    protected override void OnBarUpdate()
    {
    if (Bars.IsTickReplay) return;
    }
    which doesn't seem to work. Does it have to go in "OnMarketData​"

    Thanks
    Thomas

    #2
    Hello Thomas,

    Thank you for your post.

    You mentioned it doesn't seem to work - what do you mean by that? Are you seeing other logic being processed? Using 'return' in OnBarUpdate() will stop the rest of the logic in OnBarUpdate() from running until it is called and checked again. For example, the following snippet uses prints to show when Tick Replay is enabled or not:
    Code:
            protected override void OnBarUpdate()
            {
                if (Bars.IsTickReplay)
                {
                    Print("Tick Replay is enabled");
                    return;
                    Print("this print should not appear");
                }
                else
                    Print("Tick Replay is NOT enabled");
            }​
    If you test this in a script with Tick Replay enabled while you have a NinjaScript Output window open, you will see the print for "Tick Replay is enabled" every time OnBarUpdate() is called. The print "this print should not appear" does not show up in the NinjaScript Output window at all.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Thanks for your reply. There was a semicolon that didn't give a compile error.

      Code:
              protected override void OnBarUpdate()
              {
                  if (Bars.IsTickReplay);            //this semicolon was the culprit
                  {
                      Draw.TextFixed(this,"TickReplayError",
                          "Please disable Tick Replay", TextPosition.TopRight,
                          ChartControl.Properties.AxisPen.Brush, ChartControl.Properties.LabelFont, Brushes.Transparent, Brushes.Transparent, 0);
                      return;
                  }
              }
      
      ​
      If I would have tried to use else the error would have been shown up in the compiler.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      601 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      347 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
      559 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