Distance between 2 points

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #55293 quote
    patmabapatmaba
    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
    NicolasNicolas
    Keymaster
    Legend

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

    #55384 quote
    patmabapatmaba
    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
    NicolasNicolas
    Keymaster
    Legend

    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
    patmabapatmaba
    Participant
    Junior

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

    #55446 quote
    NicolasNicolas
    Keymaster
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Distance between 2 points


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
patmaba @patmaba Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by NicolasNicolas
8 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/10/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...