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 mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      20 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X