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 DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      41 views
      0 likes
      Last Post alifarahani  
      Working...
      X