• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Printing ZigZag points to output window

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

    Printing ZigZag points to output window

    Hi,

    I've been trying to Print the date, as well as the value of the ZigZag points that appear on a chart in the output window (using the print function) and I've had no success, I would really appreciate some help.

    Thank you for your time.

    #2
    Welcome to our forums here - which code snippet were you using please? Any error on running it in the log tab of NT's Control Center?

    Here's a helpful tip on printing / debugging : http://www.ninjatrader.com/support/f...ead.php?t=3418
    BertrandNinjaTrader Customer Service

    Comment


      #3
      My problem was with historical data, I am new to ninjatrader, I didn't know that OnBarUpdate() ran through the old bars, then all the way up to real-time so the data I was getting back was nonsensical because I didn't know that.

      So, after OnBarUpdate() gets to the current bar I have

      int HighBarsAgo = 0;
      int LowBarsAgo = 0;
      for(int i = 1; HighBarsAgo != -1 && LowBarsAgo != -1; i++)
      {
      HighBarsAgo = ZigZag(DeviationType.Points, 0.5, false).HighBar(0, i, 1000);
      LowBarsAgo = ZigZag(DeviationType.Points, 0.5, false).LowBar(0, i, 1000);

      if(HighBarsAgo != -1)
      Print("The " + i + " ZigZag High was " + High[Math.Max(0, HighBarsAgo)] + " which was " + HighBarsAgo + " bars ago");
      if(LowBarsAgo != -1)
      Print("The " + i + " ZigZag Low was " + Low[Math.Max(0, LowBarsAgo)] + " which was " + LowBarsAgo + " bars ago");
      }

      which outputs:


      The 1 ZigZag High was 37.74 which was 6 bars ago
      The 1 ZigZag Low was 36.01 which was 13 bars ago
      The 2 ZigZag High was 36.9 which was 16 bars ago
      The 2 ZigZag Low was 34.22 which was 27 bars ago
      The 3 ZigZag High was 35.7 which was 35 bars ago
      The 3 ZigZag Low was 34.67 which was 37 bars ago
      The 4 ZigZag High was 36.3 which was 41 bars ago
      The 4 ZigZag Low was 34.47 which was 43 bars ago
      The 5 ZigZag High was 35.7 which was 46 bars ago
      The 5 ZigZag Low was 31.88 which was 63 bars ago
      ...
      ..
      .

      so, problem solved.

      Thank you for your time.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by markus3500, Today, 03:29 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by bohenriksen, Today, 04:00 AM
      1 response
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by brett0, Today, 12:33 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Started by lordvader34, Today, 11:12 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by tausifkhan, Today, 05:18 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Working...
      X