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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          152 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          305 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          244 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          345 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          176 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X