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

Understanding Slope

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

    Understanding Slope

    I want to use slope to help identify periods of consolidation. To understand how slope works I created 3 SlopeTest strategies which I've attached to this post. All three strategies draw a line between the bars used to define the slope to help visualize the slope. They also draw an up green arrow or a red down arrow based on the direction of the slope. All strategies were tested on EURAUD via Playback Connection using data from 9/9-9/15.

    SlopeTest0. The only strategy that seems to work. In this strategy I draw the up arrow if slope is > 0, the down arrow is drawn when slope < 0. This works, as price movement changes from down trending to up trending the arrows change accordingly.

    SlopeTest1 This does not work. In this strategy the up arrow is to draw when slope is > .1. The down arrow should draw when slope is < -.1. Unfortunately the arrow never changes from the down arrow regardles of the direction of the slope indicated by the line I'm drawing.

    SlopeTest2 Does not work and produces the same result as SlopeTest1. This strategy differs from SlopeTest1 in that I created a separate set of conditions to draw a white diamond if the slope is >= -.1 and also <= .1.

    My understanding of slope is that +1 would equal a +45 degree angle, -1 would equal a -45 degree angle. Therefore a fraction of 1, say .5 should equal 22.5 degrees, .1 approxamitely equal to 4.5 degrees. Same for negative slope only negative numbers. Is this not true? As my line goes from downward sloping to upward sloping why do my decimal thresholds of .1 or -.1 not reflect this cahnge?

    Thanks

    Attached Files

    #2
    Hello cupir2,

    Thank you for the post.

    The Slope function does not specifically return an angle, this is just a decimal number representing the steepness. Converting to an angle is not something I could specifically provide a solution for as this will vary depending on the instruments used. There is a sample in the help guide however that will only work on instruments priced similar to the ES. Instruments with lower values like forex will have different slopes reported and that calculation no longer holds true.

    In your tests I would suggest adding a Print() for the slope to see what values your script is actually seeing. Based on what is reported back you could adjust the conditions to be more specific for the instrument being tested.

    You can additionally search on the forums for other posts where users have used this indicator, some users have explored using angles however as noted this is not something we have a specific recommendation on.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I am not trying to use it as an angle, I AM using decimals. Did you look inside my strategies? If NinjaTrader "Slope" uses decimals, why doesn't my strategy work as the slope being measured crosses from negative to positive? I am using Strategy Builder and I don't see how to control where "Print" will output its information. Could it be directed to the Log? How?
      Thanks again.

      Comment


        #4
        Hello cupir2,

        I did look at the files, but you did mention using Angles in your question so that is why I had mentioned angles.

        My understanding of slope is that +1 would equal a +45 degree angle, -1 would equal a -45 degree angle. Therefore a fraction of 1, say .5 should equal 22.5 degrees, .1 approxamitely equal to 4.5 degrees. Same for negative slope only negative numbers. Is this not true? As my line goes from downward sloping to upward sloping why do my decimal thresholds of .1 or -.1 not reflect this cahnge?
        If you are only using decimals I would suggest to avoid including extra information that is not relevant toward the question.

        When using the strategy builder you can create a print by making a new "Set" and adding just an Action of Misc -> Print. The Print command can choose items like the Slope to output its value to the NinjaScript output window. You can open the output window by clicking New -> NinjaScript Output Window

        It is likely the value you are looking for is not the value being reported, a Print could help clear that up. You are passing the EMA to the Slope which additionally modifies its value, for example on the EURUSD the Slope of the EMA is reporting as values of -0.000126089910062526, your conditions in the two scripts don't look for a value that low.

        https://ninjatrader.com/support/help...=output+window



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by samish18, Yesterday, 08:31 AM
        4 responses
        14 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by funk10101, Yesterday, 09:43 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        5 responses
        551 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rtwave, 04-12-2024, 09:30 AM
        5 responses
        37 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by funk10101, Today, 12:02 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X