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

Slope strategy

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

    Slope strategy

    Hello,

    I am trying to progr a strategy that if the slope of an indicator (RSI) is positive or turn positive, I will enter a long. And vice versa for shorts. I am having a hard te figuring out how to do this on the wizard. Any suggestions?

    Respectfully

    Corbett

    #2
    Hello,

    In the Condition Builder window within the Strategy Wizard, you can pull down the Misc section and select "Slope." You can then change the input series for the Slope to the RSI indicator, and compare the results to a numeric value (also found in the Misc section). This way you could test to see whether the slope of the RSI is greater than or equal to a certain number, or whether it crosses above or below a certain number.

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Ok. That's sound great! Thanks for the response. Now rather than comparing the slope of RSI to a number. How would I get it to read if it just either a positive slope, or negative slope. Basically, positive sloping RSI I want to be long, negative sloping RSI I want to be short.

      Thanks

      Comment


        #4
        If that is the case, then you probably do not need to use Slope at all. I recommend trying Rising and Falling (also in the Misc section) instead. Rising will return true if the RSI is rising, and Falling will do the opposite.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Right on! Thanks you! That's just what I needed!

          Comment


            #6
            I don't understand the use of Rising/Falling vs Slope, or how to use these options in NT8 Strategy Builder. Am I correct that Rising/Falling only compares current bar to prior? Can you clarify how to use these options with NT8 Strategy Builder?

            For instance, I want to look at whether the MACD is rising or falling, but not just compared to prior bar. I guess I want to see that it has some momentum, so really want to see whether slope is rising or falling. Would I use Slope, and exactly how? In the Builder, would I select Slope for indicator MACD, Value Plot MACD, and then set End Bar =0, Start Bar=4, then operator Greater, and on the right side do the same except End Bar = 1 and Start Bar = 5?
            In View Code, this results in:
            Slope(MACD1.Default, 4, 0) > Slope(MACD1.Default, 5, 1)
            I'm assuming 'Default' refers to the close, because in Builder for this same condition I see:
            Slope(MACD(Close,12,26,9).MACD,4,0)>Slope(MACD(Clo se,12,26,9).MACD,5,1)

            Or should I use a combination of Slope and Rising? How would I do this in Strategy Builder? Would I select Slope for indicator MACD, Value Plot MACD, and then set End Bar =0, Start Bar=4 (as above), then operator Rising? When I do this, on the right side I get the choice of input for Misc Series 1 and don't know what it's wanting. Do I just leave it with the default setting? If so, in View Code, I get:
            Slope(MACD1.Default, 4, 0) == IsFalling(Close)
            I don't know what 'Close' is referring to.
            In Builder, I see:
            Slope(MACD(Close,12,26,9).MACD,4,0)=IsRising(Defau ltInput)
            Again, DefaultInput seems to refer to price Close, but I just want to see whether the MACD itself is rising.

            Appreciate your help with clarification.

            Comment


              #7
              Hello,

              Thank you for the post.

              The Rising and Falling do compare the prior bar to know if the price is rising or falling.
              The slope measures the steepness between two points.

              I want to look at whether the MACD is rising or falling, but not just compared to the prior bar. I guess I want to see that it has some momentum, so really want to see whether slope is rising or falling. Would I use Slope, and exactly how?
              You could potentially use the slope for this, but you would need to check what values are output from the slope for the input you would be using to know what to check against. Once you know the value, you could compare the Slope against the right side Misc-> Numeric Value.

              The Slope produces a decimal value from -1 to 1 so it would be within that range always. You would likely need to create an Indicator that plots the return value of the Slope for the input used and then plot that on the chart you would use to see what the Slope is for the condition you want. It will be between -1 and 1 but I couldn't tell you what to use in the builder without completing this step first.

              The other option would be to create a larger set of conditions for the amount of BarsAgo you want to check is Rising or Falling. You could do this by adding if Close[0] > Close[1] and another for Close[1] > Close[2] etc.. for the number of BarsAgo you want to use in a single set. This would be PriceData -> Close in the wizard.

              Regarding DefaultInput, that would be the input being used, this defaults to the close series or last price series but would represent the Input series you select when applying the item.

              To answer the questions you have about using slope, I would likely suggest to Plot the syntax from an indicator similar to the following to get an idea of what values would be checked against. If you generate a new indicator the OnBarUpdate syntax would look like the following to display the Close slope:

              Code:
              Plot0.Set(Slope(Close, 5, 0));

              We have descriptions of the various items you can use in the builder in the help guide, for Rising, Falling and Slope:





              Please let me know if I may be of additional assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by alifarahani, Today, 09:40 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by RookieTrader, Today, 09:37 AM
              4 responses
              17 views
              0 likes
              Last Post RookieTrader  
              Started by PaulMohn, Today, 12:36 PM
              0 responses
              5 views
              0 likes
              Last Post PaulMohn  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              40 views
              0 likes
              Last Post love2code2trade  
              Started by junkone, Today, 11:37 AM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X