Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ref previous bar in if statement

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

    Ref previous bar in if statement

    I realize there's something pretty basic that I'm not getting but. . .

    When I reference the previous bar in an if statement my plot stops displaying. I reduced my problem to the simplest possible example. If the current close is greater than last bar, plot the close as a green bar in a separate indicator window. If not, plot a red bar.

    if(Close[0]<500) This works
    if(Close[1]<500) This doesn't work

    if(Close[0] > Close[1]) This doesn't work
    {
    UpBar.Set(Close[0]);
    DwnBar.Set(0);
    }
    else
    {
    UpBar.Set(0);
    DwnBar.Set(Close[0]);
    }

    What I am really trying to do is color the volume bars in accord with Bill Williams' Profitunity Windows. I set up a dataseries bwMFI. There are four conditions based on whether bwMFI and volume are lower or higher than previous bar and thus four colors.

    If I use dummy variables in my if statements everything works fine. When I use bwMFi[1] or Volume[1] in the if statements the plots stop displaying.

    I would appreciate it if someone could give me a clue as to the problem.

    #2
    Hi esmet,

    Please check your Control Center logs for errors. The reason it is not working is most likely because of the situation described in this article: http://www.ninjatrader-support.com/v...ead.php?t=3170
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      That solved the problem. Thank you very much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      572 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      550 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X