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 bsbisme, Today, 03:42 PM
      0 responses
      1 view
      0 likes
      Last Post bsbisme
      by bsbisme
       
      Started by renner1984, Yesterday, 01:50 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Vikuno1, 06-15-2024, 10:22 PM
      6 responses
      33 views
      0 likes
      Last Post Vikuno1
      by Vikuno1
       
      Started by DonMiguelo, Today, 02:19 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by merc410, 05-02-2024, 03:41 AM
      5 responses
      206 views
      0 likes
      Last Post BonnPlayer  
      Working...
      X