Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unified X (time) / Y (price) unit?

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

    Unified X (time) / Y (price) unit?

    I admit I didn´t do to much forum reseach on this question, sorry:

    In order to do calculations such as trigonometry and vectors a single unit for the X and Y axis would simplify things. It there a mathematicaly safe way to do such a conversion (and back to time/price)?

    I noticed the following methods in the ChartControl namespace that I guess might be of value:

    GetXByBarIdx()
    GetXByTime()
    GetYByValue()

    Kindly, Fredrik

    #2
    Feel free to delete this thread... I realize the units in most (all) cases wont matter.

    My problem is out of the scoop of programming. If anyone happens to know, I´m happy to know:

    1. how k values (y= kx + a) can be converted to degrees/radians
    2. if the the sum om k values in a triangle is a constant (if so wich constant).
    Last edited by FREEN; 07-19-2015, 05:09 PM.

    Comment


      #3
      Hello FREEN,
      Thanks for posting.

      1. To convert radians to degrees you would need to multiply the radian value by pi/180. The inverse (degrees to radians) would be multiply your radian value by 180/pi.

      2. The k in the formula you are using (y= kx + a) is the constant of proportionality or slope. This constant is not a specific part of a triangle but rather a constant that can be used to determine another value of another triangle based on one triangles value.

      I am little confused on the formula you are using though as most directly proportional relantionships would simple be y= kx. Now y=mx+b would be a slope formula which is close to the formula you have shown. Since you mentioned triangles I assumed that you are using the k for similar triangle.

      If this is not the case can you tell how the formula you mentioned is being used and I can further assist or please let us know if we may be of further assistance for anything NinjaTrader.
      Alex G.NinjaTrader Customer Service

      Comment


        #4
        Alex, thanks for replying on a non NT related question!

        I had to refresh some highschool trigonometry before I ended up with the following methods:


        /// <summary>
        /// k value (slope) in y = kx + m
        /// </summary>
        /// <param name="x1">point 1 x</param>
        /// <param name="y1">point 1 y</param>
        /// <param name="x2">point 2 x</param>
        /// <param name="y2">point 2 y</param>
        /// <returns></returns>
        private double GetVectorK(double x1, double y1, double x2, double y2)
        {
        return (y2-y1) / (x2-x1);
        }

        /// <summary>
        /// m value (y intercept) in y = kx + m
        /// </summary>
        /// <param name="x">x value (non zero!)</param>
        /// <param name="y">y value</param>
        /// <param name="k">k value (slope)</param>
        /// <returns>m</returns>
        private double GetVectorM(double x, double y, double k)
        {
        return ((k * x) - y) * -1;
        }

        /// <summary>
        /// Vector angle to x-axis. (Pos 0-90 deg in Q1. Neg 0-90 deg in Q4. Not valid for Q2 and Q3).
        /// </summary>
        /// <param name="k">k value of vector (y = kx + m)</param>
        /// <returns>Angle in deg</returns>
        private double GetVectorXaxisAngle(double k)
        {
        if (k == double.NaN) return 90;

        return Math.Atan(k) * (180/Math.PI);
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by newdill, Today, 07:54 AM
        0 responses
        3 views
        0 likes
        Last Post newdill
        by newdill
         
        Started by qwertyjjj, Today, 06:52 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by NeverDownMoney, 09-25-2020, 09:40 PM
        1 response
        13 views
        0 likes
        Last Post NT-Roland  
        Started by wjadevries, Today, 04:21 AM
        1 response
        12 views
        0 likes
        Last Post wjadevries  
        Started by butt_toast, Yesterday, 01:16 PM
        1 response
        20 views
        0 likes
        Last Post NinjaTrader_Jason  
        Working...
        X