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
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      11 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      7 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X