Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Blank Indicator Problem

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

    Blank Indicator Problem

    I'm having a blank indicator come up on my chart when trying to subtract yesterday's bar value from today's bar value. See code below. Appreciate some help. Very New at this code stuff.. Code works fine when both are set to [0] . Thanks...


    double pc = HMA ( Close , LongTerm ) [0];
    double pr = HMA ( Close , ShortTerm ) [1];
    VAEMA.Set(pc - pr);

    #2
    Shawn, if your indicator works fine when both are set to [0], this typically indicates a lack of data at bar number 1 of the chart.

    This tip explains with more detail.

    Basically, a data check is necessary to "skip" calculations when there isn't enough data present. Just about all indicators/strategies include a section called OnBarUpdate(), and this is where the modifications are necessary.
    Code:
    protected override void OnBarUpdate()
    {
    // these two lines need to be first.
    // this code will only allow processing to begin at bar number 2 on the chart
    if (CurrentBar < 1)
         return;
    
    // the rest of your indicator code goes here, probably like this:
    double pc = HMA ( Close , LongTerm ) [0];
    double pr = HMA ( Close , ShortTerm ) [1];
    VAEMA.Set(pc - pr);
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      Excellent

      Excellent

      Thank You...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      144 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      70 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      125 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      78 views
      0 likes
      Last Post PaulMohn  
      Working...
      X