Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Emily C.NinjaTrader Customer Service

    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 Haiasi, 04-25-2024, 06:53 PM
      2 responses
      16 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      4 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,785 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,407 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X