• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

pattern reads?

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

    pattern reads?

    Hi

    I wondered if it may be possible to write code that will "read" the "shape" of indicator lines to determine, for example--if a right angle has formed or perhaps a flat line?

    Thank you in advance.

    #2
    You can get the data points of any plot and apply and math you wish. This is in the scope of standard programming.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thank you. What is a mathmatical value of a right angle (90 degrees)?

      Comment


        #4
        Hi,

        I did an Internet search and found the following formula that's supposed to determine the angle based upon the slopes of 2 lines:

        value = (m2 - m1) / 1 + (m2 * m1)
        arctan(value)

        where m1 and m2 are the line slopes...

        I wrote the following code based upon this...however it seems faulty, I believe it is because of the arctan calculation the other stuff seems to calculate fine, here's the code:

        LSLOPE = Slope(TEST().Mov, CurrentBar - 1, CurrentBar);
        LSLOPE2 = Slope(TEST().Mov, CurrentBar -
        2, CurrentBar - 1); //SLOPES of Mov line for periods 0 AND 2
        LSLOPE_DIFF = (LSLOPE2 - LSLOPE) / (1 + (LSLOPE * LSLOPE2));
        LSLOPE_ROC = Math.Atan(LSLOPE_DIFF);

        Anybody know the error here? Thank you.

        Comment


          #5
          Unfortunately due to bandwidth issues I cannot review your code intimately, but if all you want is the value of a right angle why don't you just put in 90 degrees since you already know that without any calculations?
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Hi,

            Forgive me, but I'm not sure I follow. If I output the arctangent of 90 like this:

            value = Math.atan(90);

            I get an answer of like 1.55...which is incorrect (should be 1).

            Comment


              #7
              Have not tested your code, but doesn't Math.Atan return a value in radians, and need to be converted to degrees (180/Math.PI)?

              Comment


                #8
                Thanks MJT, that could be the problem...I wasn't aware atan was returning values in radians.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Welovethelibrary, Yesterday, 09:51 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by JoeSkeeRock, Today, 06:28 AM
                2 responses
                17 views
                0 likes
                Last Post NinjaTrader_EricB  
                Started by ldemarchi, Today, 07:20 AM
                3 responses
                28 views
                0 likes
                Last Post ldemarchi  
                Started by ashwania, Yesterday, 04:10 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by waldoalvarez, Yesterday, 03:27 PM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X