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 Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      4 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      41 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X