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 adeelshahzad, Today, 03:54 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      7 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by merzo, 06-25-2023, 02:19 AM
      10 responses
      823 views
      1 like
      Last Post NinjaTrader_ChristopherJ  
      Started by frankthearm, Today, 09:08 AM
      5 responses
      22 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Working...
      X