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

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 aa731, Today, 02:54 AM
                0 responses
                4 views
                0 likes
                Last Post aa731
                by aa731
                 
                Started by thanajo, 05-04-2021, 02:11 AM
                3 responses
                469 views
                0 likes
                Last Post tradingnasdaqprueba  
                Started by Christopher_R, Today, 12:29 AM
                0 responses
                10 views
                0 likes
                Last Post Christopher_R  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                166 responses
                2,237 views
                0 likes
                Last Post sidlercom80  
                Started by thread, Yesterday, 11:58 PM
                0 responses
                4 views
                0 likes
                Last Post thread
                by thread
                 
                Working...
                X