Distance between 2 points

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #55293 quote
    patmaba
    Participant
    Junior

    I needed for a strategy to get the geometric distance between 2 points. The platform does not provide the api of the ruler tool. So I implemented the function as an indicator and here is the code I share with you. This is not really an indicator but rather a utility function for developers. See below:

    // name : GeomDistance
    // author : patmaba
    // date : 2017/12/10
    //
    // Description
    // -----------
    // return the distance between two points
    //
    // parameters :
    // -----------
    // (pt1X, pt1Y) coordinate of first point
    // (pt2X, pt2Y) coordinate of second point
    //
    // return :
    // --------
    // distValue return the distance
    
    distValue = SQRT((pt2X-pt1X)*(pt2X-pt1X)+(pt2Y-pt1Y)*(pt2Y-pt1Y))
    return distValue as "distance"
    

     

    Nicolas thanked this post
    #55311 quote
    Nicolas
    Keymaster
    Master

    Thank you for this nice useful function. So what is the unit distance returned? Could we consider it as “time based”?

    #55384 quote
    patmaba
    Participant
    Junior

    When you take the tool ruler, the result of the tool displays a grey box with a distance value expressed in decimal number followed by a percentage which represents the difference between 2 points.

    The “GeomDistance” function calculates the decimal value that depends on the configuration of your user interface.

    #55386 quote
    Nicolas
    Keymaster
    Master

    Hmm, so it depends only of price? Why not a simple division between 2 prices? as the X coordinates isn’t needed in this case. Anyway, this is useful function, thank you 🙂 

    #55423 quote
    patmaba
    Participant
    Junior

    I use GeomDistanct on lines that are oblique and whose extreme points do not directly touch the candle.

    #55446 quote
    Nicolas
    Keymaster
    Master

    oh ok! Got a better idea now to know how to use it.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Distance between 2 points


ProBuilder support

New Reply
Author
author-avatar
patmaba @patmaba Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Nicolas
8 years, 1 month ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 12/10/2017
Status: Active
Attachments: No files
Logo Logo
Loading...