Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Slope in Strategy Wizard

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

    Slope in Strategy Wizard

    Hi,

    I wonder if anyone could help explain the following condition means in plain English. And what the "DefaultInput" is about??? Many thanks.

    // Condition set 1
    if (SMA(21)[0] >= Slope(DefaultInput, 10, 0)

    #2
    calvin, that code statement says this:
    if the current value of the 21 period SMA is greater than or equal to the slope of the default input (usually close) over the last ten bars.

    Please let us know if you have any other questions.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks Austin for your detailed explanation.

      Then the current value of the 21 period SMA should be a price value (close) e.g. 1.2729. What about the close of the slope over the last ten bars? How does the value look like / computed?

      BTW, I've searched about the slope questions in the forum. It appears to me the wizard condition builder can only test if the rising (or falling ) slope of a SMA/EMA is true or false, but not to compare the slope to a degree value, say if the rising slope => 30 degree etc. Is that correct or any other suggestions to do with the slope using the wizard condition builder?
      Last edited by pipal; 07-23-2010, 05:08 AM.

      Comment


        #4
        Pipal, the method Slope() returns the difference in the data series between the points separated by the number of periods you specify divided by the number of periods. So for an example of a one period slope and two period slope: if bar 1 closed at 100, bar 2 closed at 101, and bar 3 closed at 103, then at bar 3, Slope(Close, 1, 0) would return 2, which is bar 3 close - bar 2 close. Slope(Close 2, 0) would return 1.5, which is (bar 3 close - bar 1 close) / 2. It is the change in y divided by the change in x.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Another way for slope

          Code:
          if (base.Bars != null)
          {
          while (bars >= 0)
          	{
          	index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + bars;
          				
          if (ChartControl.ShowBarsRequired || ((index - base.Displacement) >= base.BarsRequired))
          	{
          		double val = MAHolder.Get(index);
          			if (!double.IsNaN(val) && (val != 0))
          			{
          int y2 = (bounds.Y + bounds.Height) - ((int) (((val - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
          					val =MAHolder[1];
          						
          					{
          int y1 = (bounds.Y + bounds.Height) - ((int) (((val - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
          
          							
          
          							{
          								
          degreeSlope = (int)((180/Math.PI) * Math.Atan2(y2-y1,ChartControl.BarSpace))*-1;
          										
          									break;
          Here is another way which produces degrees. MAHolder is just your Moving average data series value.

          Comment


            #6
            Mindset, I am trying to get a formula for a 'relative' slope myself. For charting, slope cannot be (x2 - x1)/(y2 - y1) because the X and Y axes are not fixed. Where did you get that formula above? What is its output, and would it work on any timeframe chart?

            Thanks!
            Bryan
            cassb
            NinjaTrader Ecosystem Vendor - Logical Forex

            Comment


              #7
              Slope

              cassb

              Can't remember where I got it but it seems to work. It is defining the slope in degrees remember so as the chart scale changes so does the slope - hence I think you will find it is correct.

              Comment


                #8
                Hm... so are you saying that if you squeeze the X axis so the bars are closer together and thinner, the slope changes as well? Relative to what?

                I think what I'm looking for is a "relative" slope, like on a scale of 1 to 10 or something. So that 1 is pretty flat, and 10 is almost vertical. The problem I'm having is that the actual slope calculation for a line that appears the same on a 1 min. chart vs. a daily chart is wildly different.
                cassb
                NinjaTrader Ecosystem Vendor - Logical Forex

                Comment


                  #9
                  Originally posted by Mindset View Post
                  Code:
                  if (base.Bars != null)
                  {
                  while (bars >= 0)
                      {
                      index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + bars;
                                  
                  if (ChartControl.ShowBarsRequired || ((index - base.Displacement) >= base.BarsRequired))
                      {
                          double val = MAHolder.Get(index);
                              if (!double.IsNaN(val) && (val != 0))
                              {
                  int y2 = (bounds.Y + bounds.Height) - ((int) (((val - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
                                      val =MAHolder[1];
                                          
                                      {
                  int y1 = (bounds.Y + bounds.Height) - ((int) (((val - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
                  
                                              
                  
                                              {
                                                  
                  degreeSlope = (int)((180/Math.PI) * Math.Atan2(y2-y1,ChartControl.BarSpace))*-1;
                                                          
                                                      break;
                  Here is another way which produces degrees. MAHolder is just your Moving average data series value.
                  I see the formula, but none of the variables are declared and the {} syntax is weird. What code is this and where did it come from?

                  Bryan
                  cassb
                  NinjaTrader Ecosystem Vendor - Logical Forex

                  Comment


                    #10
                    Relative Slope

                    Well slope is relative to how you look at it - bit like Space and Time really.
                    I show two charts below - same data but on one chart I have squeezed the data by changing the axes.
                    The EMA slope changes to reflect that. Slope is simply y over x, like a hill.

                    You say relative but I am unsure - relative to what?? This version is relative to the axes. I think you are looking for an absolute slope in which case you might want to look at price movement over time maybe? But again you still run into the chart axis issue.
                    I am intrigued if you can come up with something on a 1 -10 type scale - it nullifies subjectivity which is superb!

                    Re the variables - it wasn't meant to be a full on code - just the relevant section outlining source for this version of slope. I also attach a full indicator. I have been attempting to find a switch to turn an indicator on/off without going through the dialog box.
                    If you press Shift+H this hides/reveals the indicator but it doesn't update once hidden - so it's still a work in progress.
                    If anyone can see the way round this I would be grateful.


                    Attached Files
                    Last edited by Mindset; 03-26-2011, 01:31 AM.

                    Comment


                      #11
                      OK, I see. Yeah, that's not what I want though. I want something that would be relative to the chart's timeframe and bar length, but also fixed to some kind of scale. So that a slope of "3" on the chart is still a "3" no matter how you change the X-axis. I know... good luck with that, huh? :-)

                      Regarding turning the indicator on and off, our indicators at ProTradingTools have a switch, but you have to open the dialog like you said. I would be interested in being able to do that without opening the dialog as well. Let me know if you find anything. :-)

                      Bryan
                      cassb
                      NinjaTrader Ecosystem Vendor - Logical Forex

                      Comment


                        #12
                        Any luck with this...i'm also trying to determine an absolute slope...the Slope method provided in NT7 doesn't seem to do the trick.

                        Comment


                          #13
                          Originally posted by krakken View Post
                          Any luck with this...i'm also trying to determine an absolute slope...the Slope method provided in NT7 doesn't seem to do the trick.
                          With the ability to change the scale of the X and Y axes at will, I don't think it's possible to determine an absolute slope. It will always be relative to how the user sets the axes of the chart.
                          cassb
                          NinjaTrader Ecosystem Vendor - Logical Forex

                          Comment


                            #14
                            Slope of sma in strategy Wizard

                            hello,
                            Could you tell me how to set the following conditions in strategy wizard?
                            A/ sma200 = positive slope

                            B/ sma200 = negative slope
                            I guess that condition can be used using other indicators like macd or stoch or adx instead of the Sma
                            Thanks
                            Last edited by PEPBOSCH; 02-21-2015, 10:14 AM.

                            Comment


                              #15
                              Originally posted by PEPBOSCH View Post
                              hello,
                              Cuold you tell me how to set the following conditions in strategy wizard?
                              A/ sma200 = positive slope

                              B/ sma200 = negative slope
                              I guess that condition can be used using other indicators like macd or stoch or adx instead of the Sma
                              Thanks
                              I think you'd like to set a condition in your strategy to determine whether the SMA is rising or falling. This can be done in several ways:

                              Code:
                              if( Rising( SMA(200) )
                              
                              {do something}
                              
                              if(Falling( SMA(200) )
                              
                              {do something}
                              The logical equivalent of this is:

                              Code:
                              if( SMA(200)[0] > SMA(200)[1]  )
                              
                              {do something}
                              
                              if( SMA(200)[0] < SMA(200)[1]  )
                              
                              {do something}
                              If you want to determine whether this bar is the first rising/falling bar, this will do the trick:

                              Code:
                              if( SMA(200)[0] > SMA(200)[1] && SMA(200)[1] < SMA(200)[2]  )
                              
                              {do something}
                              
                              if( SMA(200)[0] < SMA(200)[1] && SMA(200)[1] > SMA(200)[2]  )
                              
                              {do something}
                              Yes, of course, the same syntax applies to all conventional continuous indicators.

                              Hope this helps.
                              Last edited by arbuthnot; 02-21-2015, 10:13 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fitspressoburnfat, Today, 04:25 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post fitspressoburnfat  
                              Started by Skifree, Today, 03:41 AM
                              1 response
                              4 views
                              0 likes
                              Last Post Skifree
                              by Skifree
                               
                              Started by usazencort, Today, 01:16 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post usazencort  
                              Started by kaywai, 09-01-2023, 08:44 PM
                              5 responses
                              604 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              6 responses
                              23 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X