Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Use the Slope

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

    How to Use the Slope

    Hi,

    I've been struggling with this a few hours - reading old posts, etc. Im not talking about the regression slope but rather the simple rise over run steepness.

    In the Misc. section of the wizard/builder there is a slope. I have not graduated to coding yet so I was happy to see this (I've read a lot about slope() but I'm not there yet).

    What I've tried to do most recently is apply the slope in the left of the builder with the series being SMA(14) and start 10 end 0. On the right I created a user input (double) named Slope. The operand was > (also tried < but apparnetly that doesnt work with double).

    My goal is to be able to say If slope of SMA14 is greater than x, then do y - for example. This setup has done nothing varying the slope variable all over the place.

    How can I build a condition that considers the simple slope of a series?


    Meegwell
    Attached Files

    #2
    Hello,

    Thanks for your note.

    This should work.

    However in your comparingvariable what you you have for the user defined variable?

    Depending on the instruments its on, for example on the ES the slope can be -1 to positive 1. However on something like the DX with a different decimal point:
    Slop outputs a value anywhere from -.010 to .010 or greater for exaple.


    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks, glad I on the right track. I am doing a SMA of stock prices? and I experimented with a double and an int.

      Is there a way I can see what the output is at a given bar? Can I look somewhere to see what the readings are for the indicators I have? This way, I could choose a bar and look at what the slope actually is to understand what by comparable should be.

      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Thanks for your note.

      This should work.

      However in your comparingvariable what you you have for the user defined variable?

      Depending on the instruments its on, for example on the ES the slope can be -1 to positive 1. However on something like the DX with a different decimal point:
      Slop outputs a value anywhere from -.010 to .010 or greater for exaple.


      Let me know if I can be of further assistance.

      Comment


        #4
        Hello,

        There is a way to do it but would take custom programming.

        I setup a quick indicator for you to import in however. Apply this to a chart and it will show you the slop figures for the SMA.

        It is called testSlope

        Let me know if I can be of further assistance.
        Attached Files
        Last edited by NinjaTrader_Brett; 02-03-2011, 07:28 AM.

        Comment


          #5
          What is the calc of the slope? (is it [[last-first]/first] or something similar?) You mention the range for ES and DX, what about stocks? Although if I was sure of the calc I could figure this out. I am looking to inlcude the slope of a stock SMA in a condition.


          Thanks for all your help,

          Meegwell


          Originally posted by NinjaTrader_Brett View Post
          Hello,

          Thanks for your note.

          This should work.

          However in your comparingvariable what you you have for the user defined variable?

          Depending on the instruments its on, for example on the ES the slope can be -1 to positive 1. However on something like the DX with a different decimal point:
          Slop outputs a value anywhere from -.010 to .010 or greater for exaple.


          Let me know if I can be of further assistance.

          Comment


            #6
            Yes its Rise Over Run with the Starts Bars Ago/ End Bars Ago being the bar values compared.

            Let me know if I can be of further assistance.

            Comment


              #7
              Originally posted by NinjaTrader_Brett View Post
              Yes its Rise Over Run with the Starts Bars Ago/ End Bars Ago being the bar values compared.

              Let me know if I can be of further assistance.
              So back to stock question, it would be in $$ (US Market)?

              i.e. If I set 9 bars as the run, and the stock was $7.45 9 bars ago and at the end bar it is $5.88, Ninja Trader will return a value of .174 (-.174 I guess) as the slope? If the stock dropped to zero it would be -.83?

              Thanks

              Comment


                #8
                If you add the indicator I posted here you can confirm that from my indicator on any stock what its values would return. But what you mention is correct.

                Let me know if I can be of further assistance.

                Comment


                  #9
                  I can get yor indicator to work but I only want a slope of what I define, not a coded MACD which is what it appears you did.

                  I did the following - see pics - a strategy with IF slope of SMA 14 (close price) 10 bar period > User Input (double) enter long position.

                  On the chart, I made the variable .05

                  No trades entered.
                  Attached Files

                  Comment


                    #10
                    Hello,

                    My Indicator outputs slope of the SMA the 0 bars vs 10 bars ago. Not a MACD's slope and should do the trick for you.

                    Plot0.Set(Slope(SMA(20), 10, 0));

                    Comment


                      #11
                      Thanks Brett. Im trying to learn code a bit. I have 2 questions and then I'll tinker a bunch more before asking any more on this topic:

                      1.) What role does the MACD play in this code from your indicator:
                      Print(Slope(SMA(20), 10, 0));
                      double prev = Swing(MACD(12, 26, 9), 5).SwingHigh[0];
                      Plot0.Set(Slope(SMA(20), 10, 0));

                      2.) What is the data series this is an SMA of? Is it SMA 20 day Closing Price? How do I modify this so I can change the start end, and the data series to be anything?

                      (sorry I know question 2 is a couple questions.

                      Thanks so much for your patience.

                      Meegwell

                      Comment


                        #12
                        Hello,

                        Ahhhh, I see where you found that. Ok Thats just a dummy call I did as I was testing something and left it in there. That line is actually doing really nothing and can be deleted.

                        Also, you change SMA(20) to be like SMA(40) if you want a 40 period MA. Does that answer your second question?

                        I look forward to assisting you further.

                        Comment


                          #13
                          Originally posted by NinjaTrader_Brett View Post
                          Hello,

                          Ahhhh, I see where you found that. Ok Thats just a dummy call I did as I was testing something and left it in there. That line is actually doing really nothing and can be deleted.

                          Also, you change SMA(20) to be like SMA(40) if you want a 40 period MA. Does that answer your second question?

                          I look forward to assisting you further.

                          Thanks. That answers it partially. To help me understand the code, how do I know what the SMA is an SMA of? (is it the sma of the close price and how do I know that?)

                          After I get that explanation I think I'll have enough to get under the hood and tinker more.

                          Thanks.

                          Comment


                            #14
                            Hello,


                            Sure understood. So if you dont specify. The SMA() is always the Close price. Unless you specify otherwise through another paramter as detailed here:



                            I look forward to assisting you further.

                            Comment


                              #15
                              In reference in your confirmation that my math is correct in post #7:

                              See picture. I have put the indicator on a chart for stock AONE. The testslope indicator runs on the bottom an in the picture displays a slope in the area of -.15 while the stock price is at 16.10. Ten bars ago, the stock price was 20.85. The slope should be closer to -.47 (which is intuitively correct also given the major drop). What am I missing here?

                              The second picture shows the indicator paramaters.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FrancisMorro, Today, 03:24 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post FrancisMorro  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              10 responses
                              1,769 views
                              0 likes
                              Last Post Leafcutter  
                              Started by Rapine Heihei, 04-23-2024, 07:51 PM
                              2 responses
                              30 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by Shansen, 08-30-2019, 10:18 PM
                              24 responses
                              943 views
                              0 likes
                              Last Post spwizard  
                              Started by Max238, Today, 01:28 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Working...
                              X