Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      22 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Working...
      X