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

Slope()...

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

    #16
    This is good stuff.....weeds out the flat times!

    How would......

    if ((System.Math.Atan(Slope(EMA(50),CurrentBar-1,CurrentBar))*180/Math.PI) > 20)
    // Do something

    look on a 5 minute chart?

    Comment


      #17
      I'm not sure what it will look like. You'll have to take it from here and play with it yourself.
      Josh P.NinjaTrader Customer Service

      Comment


        #18
        Is this code still correct? I've been 'playing' with it and its not very fun...

        Searching in the forums for help, it appears the syntax has changed numerous times which makes it even more confusing.

        If you have time, it might be helpful to make a sample ninjascript that shows how both kinds of slope work in the context of both long and short positions.

        Slope seems like it would be perfect to help avoid rapid whipsaw trades in a sideways markets, but for some reason, what is so obvious visually is so hard to code.


        -EDIT-
        The MASlopeBox indicator has been updated, which is very helpful.
        Last edited by Elliott Wave; 04-13-2008, 02:27 AM.

        Comment


          #19
          The current DOC accurately demonstrates that proper syntax for the Slope() method.
          RayNinjaTrader Customer Service

          Comment


            #20
            Thanks, for the clarification.

            I couldn't find much in the manual on "system.math.atan" type slopes and how they differ, whether or not the value is in degrees, between 1, -1, etc and with the syntax change, looking for answers in the forum raised as many questions as it answered.

            Now that the MASlopeBox works, I'm using that for sample code and by including it in a wizard generated strategy I can see the code in a more usable context, which 'Print(Slope(SMA(20), 10, 0)); ' didn't quite provide.

            Comment


              #21
              If I remember correct the System.Math.Atan provides the answer in radians. You can check the MSDN documents to confirm.
              Josh P.NinjaTrader Customer Service

              Comment


                #22
                I'm pretty sure thats right, from looking at the MASlopeBox code.

                To see if I get this straight:

                ((180/Math.PI) *(Math.Atan(Slope(EMA(Period),1,0)))

                returns a slope value in degrees whereas the NT Slope function returns a value between -1 and 1.

                i.e if the first example returns a 10 degree slope, the NT slope function would return 0.1...

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ScottWalsh, Today, 06:52 PM
                0 responses
                0 views
                0 likes
                Last Post ScottWalsh  
                Started by ftsc2022, 10-25-2022, 12:03 PM
                5 responses
                255 views
                0 likes
                Last Post KeyonMatthews  
                Started by ScottW, Today, 06:09 PM
                0 responses
                3 views
                0 likes
                Last Post ScottW
                by ScottW
                 
                Started by Board game geek, 10-29-2023, 12:00 PM
                14 responses
                244 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Waxavi, 04-19-2024, 02:10 AM
                4 responses
                56 views
                0 likes
                Last Post sonia0101  
                Working...
                X