Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple STO Cross problem

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

    Simple STO Cross problem

    I am trying to build a simple Sto cross indicator that alerts when the Sto 100 crosses below the 80 mark and I continue to get an index error.

    The error is on the following line:
    if (StochasticsFast(5,100)[0] < 80.0 && StochasticsFast(5,100)[1] > 80.0)

    It has problems with "StochasticsFast(5,100)[1]" . Index out of range.

    I have tried this with StochasticsFast(5,100).K[1] and quite a few other variations but have the same issue.

    Is this the correct way to obtain the previous value or is there a better way.

    Thanks,

    #2
    The following link will provide you the answer - http://www.ninjatrader-support.com/v...ead.php?t=3170

    Alternatively, you can use the following methods -

    CrossAbove() - http://www.ninjatrader-support.com/H...rossAbove.html
    CrossBelow() - http://www.ninjatrader-support.com/H...rossBelow.html
    RayNinjaTrader Customer Service

    Comment


      #3
      That worked. Thanks.

      BTW - CrossAbove/Below will only work in situations where the %K and %D cross, not for when the Moving Average pass a threshold.

      Comment


        #4
        Originally posted by gyoung View Post
        BTW - CrossAbove/Below will only work in situations where the %K and %D cross, not for when the Moving Average pass a threshold.
        Nope. There are 2 signatures, one that takes 2 data series and one that takes a constant.

        Comment


          #5
          I need to read the documentation better next time :-(
          You are correct.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X