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

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 futtrader, 04-21-2024, 01:50 AM
          4 responses
          41 views
          0 likes
          Last Post futtrader  
          Started by Option Whisperer, Today, 09:55 AM
          1 response
          11 views
          0 likes
          Last Post bltdavid  
          Started by port119, Today, 02:43 PM
          0 responses
          1 view
          0 likes
          Last Post port119
          by port119
           
          Started by Philippe56140, Today, 02:35 PM
          0 responses
          3 views
          0 likes
          Last Post Philippe56140  
          Started by 00nevest, Today, 02:27 PM
          0 responses
          2 views
          0 likes
          Last Post 00nevest  
          Working...
          X