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

How to fix this problem ?

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

    How to fix this problem ?

    I coded a simple indicator. This indicator is supposed to plot a histogram bar when the previous candle is an up candle. It compiles without problem. However, it just doesn't plot anything. After attaching it to the chart, the indicator window shows blank. The code is very simple, the OnBarUpdate() section only consists of one line. How to fix it ? The source code under OnBarUpdate() is as following:

    protected override void OnBarUpdate()
    {
    Value[0]=(Close[1]>Open[1] ? 1:0);
    }

    The complete source code file is as attached.

    Thank you in advance for anyone that can help. MyCustomIndicator1.cs

    #2
    Hello Pooh123,

    On the first bar, there is no bar 1 bar ago. When CurrentBar is 0, Close[1] is an invalid index.

    Are you getting any errors in the Log tab of the Control Center?

    If you print the value of Value[0] does anything print?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Yes, you were right. I tried adding the following code and it worked:

      if (CurrentBar < 1 ) return;


      It solved the problem.

      Thank you,
      Pooh

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Skifree, Today, 03:41 AM
      3 responses
      12 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by traderqz, Yesterday, 09:06 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by guillembm, Today, 11:25 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by owensd, 04-21-2024, 11:34 PM
      9 responses
      34 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by trilliantrader, 04-10-2024, 09:33 PM
      7 responses
      25 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X