Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Not all code paths return a value error ?

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

    Not all code paths return a value error ?

    Sorry really overposting

    Not all code paths return a value error?

    my input array is 128 items, so is my _smoothHp.
    _hp is also an array of 129

    I cant see my error? i return on an IF statement to _smoothHp array?

    private double HPfilter(double []InputArray)
    { // Detrend data by High Pass Filtering
    double alpha = (1-Math.Sin(twoPi/30))/Math.Cos(twoPi/30);
    for (int bar = 1; bar >128; bar++)
    {
    _hp[bar] = 0.5*(1+alpha)*(InputArray[bar]-InputArray[bar-1])+alpha*_hp[bar-1];
    if (bar>6)
    {
    return _smoothHp[bar-1] = (_hp[bar-1]+2*_hp[bar-2]+3*_hp[bar-3]+3*_hp[bar-4]+2*_hp[bar-5]+_hp[bar-6])/12;
    }
    else
    {
    return _smoothHp[bar-1]=0;
    }
    }
    }

    #2
    I believe you would likely need to return from outside of the for loop.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      for (int bar = 1; bar >128; bar++)

      This loop never starts because the very first value of bar is never >128.
      And in this case: like Josh mentioned already ...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,283 views
      0 likes
      Last Post Leafcutter  
      Working...
      X