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

Angle of downward trending SMA.

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

    Angle of downward trending SMA.

    How can I find the ANGLE of a downward trending SMA.

    i.e.

    I look back 30 bars,

    SMA[0] is 1.4855
    SMA[30] is 1.5845

    The Adj of the triangle is (1.5845-1.4855) = 0.099
    and the Opp is 30 bars

    Tan t = Opp/Adj

    This may be a math question:
    How do I get the length value of Opp which is 30 bars
    so that it could be calculated.


    Thank you!



    Attached Files
    Last edited by johnnybegoode; 09-09-2019, 05:47 PM.

    #2
    I drew a triangle so you know what I am actually asking.

    Comment


      #3
      Hello johnnybegoode,

      Generally this is not something you can calculate due to the automatic scaling of the chart, the visuals will change as more or less data is included however the prices do not change. You could instead use the Slope function to find the steepness of the plot and then use math to convert that to degrees or other units. There is a sample in the help guide showing how to use this function along with a sample equation for degrees. https://ninjatrader.com/support/help...lightsub=slope

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

      Comment


        #4
        double Degree0 = Math.Atan(Slope(SMA0,21, 0))*180/Math.PI;
        double Degree1 = Math.Atan(Slope(SMA1,21, 0))*180/Math.PI;
        double Degree2 = Math.Atan(Slope(SMA2,21, 0))*180/Math.PI;

        Why do I get really tiny degree values in the 0.0001 ranges?
        The angles look steeper like 45 degrees and not 0.0001?



        Last edited by johnnybegoode; 09-13-2019, 07:01 PM.

        Comment


          #5
          Hello johnnybegoode,

          I believe this would be caused due to the variable return value of slope based on the prices seen. I located a sample which demonstrates converting prices to an angle rather than using the Slope indicator. You could try this approach instead, the underlying formula is similar to what is noted in the help guide for slope.



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

          Comment


            #6
            I downloaded the indicator and attached it to EURUSD on the chart. It is displaying only between the 179.0000000000000 and 180.000000000000
            range.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rapine Heihei, Today, 08:19 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 08:25 PM
            0 responses
            6 views
            0 likes
            Last Post Rapine Heihei  
            Started by f.saeidi, Today, 08:01 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 07:51 PM
            0 responses
            8 views
            0 likes
            Last Post Rapine Heihei  
            Started by frslvr, 04-11-2024, 07:26 AM
            5 responses
            98 views
            1 like
            Last Post caryc123  
            Working...
            X