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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      52 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      71 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      38 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      99 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      60 views
      0 likes
      Last Post PaulMohn  
      Working...
      X