• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 saltminer, Today, 06:22 PM
      0 responses
      2 views
      0 likes
      Last Post saltminer  
      Started by saltminer, Today, 06:20 PM
      0 responses
      1 view
      0 likes
      Last Post saltminer  
      Started by escobar63, Today, 05:06 PM
      0 responses
      5 views
      0 likes
      Last Post escobar63  
      Started by i2w8am9ii2, Today, 04:41 PM
      0 responses
      5 views
      0 likes
      Last Post i2w8am9ii2  
      Started by Renorail, Today, 03:40 PM
      3 responses
      11 views
      0 likes
      Last Post Renorail  
      Working...
      X