Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 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
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X