fxDreema

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

    Check a condition for a period since last trade was closed

    Questions & Answers
    2
    4
    899
    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.
    • T
      trader.philipps last edited by trader.philipps

      Here I have something for the advanced folks.

      Let's assume I have a moving average. If price is above the MA I assume the price is trending up. If it is below the MA, I assume the price trending down. So far so good.

      I want to check the condition now, if since the last trade was closed (eg. long trade) the price ever was closing below my MA. Any idea?

      Probably I need some looping and maybe custom code. But any help I appreciate.

      0_1567874402025_Auswahl_521.png

      I like to share my knowledge, but expect the others to contribute as well.

      roar 1 Reply Last reply Reply Quote 0
      • roar
        roar @trader.philipps last edited by roar

        Hi @trader-philipps!

        Here's how I would approach this. It might still have some bug, I'm too lazy to properly test anything.
        Blocks:

        1. Load the last closed trade
        2. Save its ticket number
        3. Use custom code to get the trade closing candle ID
        4. Do something closed_ID times. When this process starts the first time:
        • set our final condition to FALSE,
        • set iteration ID to closed_ID

        When the process makes an iteration, decrease iter_ID by 1.

        1. Now we can just check the condition with MA indicator, using iter_ID in the Candle ID fields.
          If this condition is a success, modify variable belowcondition to TRUE
          0_1567877621370_773c2697-4173-459b-84f3-99e25c54f427-image.png

        Hope this helps.
        https://fxdreema.com/shared/JOQCkRG3e
        If you import the .mq4, you get the correct variables as well.
        0_1567877553885_check past.mq4

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        T 1 Reply Last reply Reply Quote 1
        • T
          trader.philipps @roar last edited by

          @roar Thanks. That is a good start. Is there a way to get the order type as well? As it influence the condition to check.

          I like to share my knowledge, but expect the others to contribute as well.

          roar 1 Reply Last reply Reply Quote 0
          • roar
            roar @trader.philipps last edited by roar

            @trader-philipps I would put a "Check type (last closed)" before the condition, and copy the condition and then just flip the comparator for the case of sell order:
            0_1567878578957_a1728c85-406f-4bec-a9db-3786af0721ad-image.png

            Need small help? Tag me in your post
            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

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

            Online Users

            H
            H
            M
            S
            S
            L
            E

            15
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors