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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      104 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      52 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      34 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      38 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      74 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X