• 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 HiddenPhilosopher, Yesterday, 11:58 PM
                1 response
                10 views
                0 likes
                Last Post NT-Roland  
                Started by vofupba6, Today, 02:54 AM
                0 responses
                6 views
                0 likes
                Last Post vofupba6  
                Started by Johnny, Today, 02:37 AM
                0 responses
                5 views
                0 likes
                Last Post Johnny
                by Johnny
                 
                Started by waliopaozae, Today, 01:44 AM
                0 responses
                9 views
                0 likes
                Last Post waliopaozae  
                Started by Futurestrader00, Today, 01:35 AM
                0 responses
                11 views
                0 likes
                Last Post Futurestrader00  
                Working...
                X