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

I want to learn more about adding the slope to a strategy

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

    I want to learn more about adding the slope to a strategy

    I'm currently using IsRising but it seems like the slope would be more stringent. because IsRising/IsFalling permits a trade on just the slightest of a rise that I don't care for as much.

    Slope seems like I can call for a specific kind of slope that needs to happen before allowing a trade to take place. I guess I need better understanding for the degrees of a slope, like 0 to 0 would be a flat line but 0 to 10 would be pretty sharp rise, I imagine. I want to wrap my understanding around the slope much better than what I have now.

    Is their strategy samples or videos talking about the slope? Thanks.

    #2
    Hello trdninstyle,

    The IsRising just checks if the current bar is rising compared to the last bar. If you needed to increase the amount of bars for a trend you would need to just use price conditions for that. For example Close[0] > Close[1] && Close[1] > Close[2] etc for however many bars in a row that you wanted.

    Slope is a measure of steepness of a price series (y value) measured by the change over time (x value). That will vary instrument to instrument so you would have to output the values you are seeing on each instrument you use to get an idea of how to form the condition based on the amount of steepness you wanted.

    There are no guides or samples for slope but you can read the help guide page about it: https://ninjatrader.com/support/help...lightsub=slope
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse,

      I was actually confusing this with the angle of a line. Note: The return value should NOT be confused with the angle (or radians) of a line that displays on the chart.


      But the bars are represented in, in this case, a 20 SMA tho?

      // Prints the slope of the 20 period simple moving average of the last 10 bars
      Print(Slope(SMA(20), 10, 0));

      Isn't it basically the same or is it just similar? It represents bars but by way of a line. But like that note suggest, is there a way to define the angle of a line that displays on a chart?

      (Hey, I got that 22-set working good, adding another set of variables was all I needed).

      Comment


        #4
        Hello trdninstyle,

        But the bars are represented in, in this case, a 20 SMA tho?

        Are you asking if the slope is returning the slope of the SMA?

        Isn't it basically the same or is it just similar? It represents bars but by way of a line. But like that note suggest, is there a way to define the angle of a line that displays on a chart?
        The help guide note about the line is that the slope value is not to be confused with an angle, slope is not an angle.

        If you think of normal math using graph paper and draw a line it has a certain angle and is generally represented in degrees or radians. The chart does not have a fixed x/y axis so using angles/radians on the chart doesn't really make sense. You could draw a 45 degree angle line but if the chart scales get expanded or contracted that line may now be visually any other angle depending on how the scales were changed. You can test this by drawing an angled line on the chart and then adjust the X or Y axis, you will see the line moves around as the chart changes making different degree angles. The line has fixed start and end points which relate to the chart bars and prices.

        The note about converting to a degree from slope would be so that you can in code use degrees instead of the steepness that the slope returns. You wouldn't be able to visually compare that value to a plot or line on the chart because the scales will adjust the angle of the plot/line based on the x and y axis. The steepness of that region of time won't change based on the scale because it is measuring the prices over a period of bars.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Okay, I'm following you now. Thanks for that explanation, I'm going to get familiar with the slope over the weekend.

          I have a question about LongShortBool I'll make a new post on Monday. Enjoy your weekend.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rhyminkevin, Today, 04:58 PM
          3 responses
          46 views
          0 likes
          Last Post Anfedport  
          Started by iceman2018, Today, 05:07 PM
          0 responses
          5 views
          0 likes
          Last Post iceman2018  
          Started by lightsun47, Today, 03:51 PM
          0 responses
          7 views
          0 likes
          Last Post lightsun47  
          Started by 00nevest, Today, 02:27 PM
          1 response
          14 views
          0 likes
          Last Post 00nevest  
          Started by futtrader, 04-21-2024, 01:50 AM
          4 responses
          50 views
          0 likes
          Last Post futtrader  
          Working...
          X