fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Convert Price To Pips

    Questions & Answers
    2
    4
    467
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MelloMatt last edited by

      Hello, I'm trying to check the distance between the Support and Resistance objects in my project, convert that to pips, and then divide the distance in pips by 2 to use as take profit and stop loss. I've looked at a ton of threads in this forum trying to figure out how to do this correctly, but wasn't able to get it working. I'm only able to get it working by dividing the price by 0.0001 (EURGBP).

      Here is my project: https://fxdreema.com/shared/25OiIW1ve

      Is there anyway to adjust this so that I can use it on multiple pairs? Currently doing the price to pip conversion in the "Convert to Pips" formula.

      1 Reply Last reply Reply Quote 0
      • jstap
        jstap last edited by

        You can do it with this code, create a variable called Distance, the price is relevent to what you are using:

        MQL4
        price1 = 1.2345;
        price2 = 1.2350;

        // Calculate the absolute difference in price
        double difference = MathAbs(price1 - price2);

        // Convert the difference to points and store in Distance
        Distance = difference / Point;

        // Optionally, you can print the value of Distance for verification
        Print("The distance in points is: ", Distance);
        MQl5:
        price1 = 1.2345;
        price2 = 1.2350;

        // Calculate the absolute difference in price
        double difference = MathAbs(price1 - price2);

        // Convert the difference to points and store in Distance
        Distance = difference / _Point;

        // Optionally, you can print the value of Distance for verification
        // Print("The distance in points is: ", Distance);

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Don’t miss out

        Click here➡️ https://mybook.to/fxDreema to get your copy today!

        Enjoy! 😊

        1 Reply Last reply Reply Quote 0
        • M
          MelloMatt last edited by

          Sorry for the late reply, but this works perfectly thank you so much!

          jstap 1 Reply Last reply Reply Quote 0
          • jstap
            jstap @MelloMatt last edited by

            @MelloMatt You are welcome

            Learn fxDreema Without the Wait!

            My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

            The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

            Don’t miss out

            Click here➡️ https://mybook.to/fxDreema to get your copy today!

            Enjoy! 😊

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post

            Online Users

            P
            S
            L
            M
            F
            B
            Z
            J
            G

            26
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors