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 gravdigaz6, Today, 11:40 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by MarianApalaghiei, Today, 10:49 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by XXtrader, Today, 11:30 PM
      0 responses
      4 views
      0 likes
      Last Post XXtrader  
      Started by love2code2trade, Yesterday, 01:45 PM
      4 responses
      28 views
      0 likes
      Last Post love2code2trade  
      Started by funk10101, Today, 09:43 PM
      0 responses
      9 views
      0 likes
      Last Post funk10101  
      Working...
      X