fxDreema

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

    How to code condition block for change % of an indicator

    Questions & Answers
    2
    5
    336
    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.
    • D
      Davidbike1 last edited by

      I am having trouble with figuring how to use the adjust section of the condition block correctly. Let's say I am using the 5 minute time frame and I want to place a buy now if the MACD indicator value 5 minutes ago was at -10 and then it increased in value to -8 or higher over the next 5 minutes.

      David Craven

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

        It is a lot easier to use a fixed number -10 to -8 is +2, do you need a %?

        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 1
        • D
          Davidbike1 last edited by Davidbike1

          Yes preferably I was looking for a relative notable percentage change in a Macd value from a previous point in time to a present or closer to present point in time as a condition to pass or not. I could do fixed numbers it may just take me more time to code.

          David Craven

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

            You will need to get the value at a given place, by doing this:

            // Define two numbers
            num1 = 50;
            num2 = 70;

            // Calculate the absolute difference
            double absoluteDifference = MathAbs(num1 - num2);

            // Calculate the percentage difference relative to num1 (or you could use num2 or average)
            percentageDifference = (absoluteDifference / num1) * 100;

            Num1 and num2 are the 2 indicator values, you will need to create the variable to save the result.

            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
            • D
              Davidbike1 last edited by

              I am sorry, I think I miscommunicated. I am not looking to find a certain percent. I am looking for the bot to place a buy trade if condition the Macd value is greater than -15 and if yes to place a buy trade if the Macd value increased by 20% or more from the previous candle bar. When I plugged in 120% after backtesting the bot placed a trade at 17:40 when the Macd value was decreasing. When I plugged in 20% after backtesting the bot did not place a trade at 16:40 or 16:45 when the Macd value was greater than -15 value and it increased more than 20%. Screenshot (91).png Screenshot (90).png Screenshot (89).png Screenshot (88).png

              David Craven

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

              Online Users

              R
              A
              T
              N
              K
              R
              R

              15
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors