fxDreema

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

    [MQL5] Dynamic level based stop

    Questions & Answers
    2
    8
    1303
    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
      dcg last edited by

      Hi,

      I'm running into a challenge which i can't figure out (yet) so if someone could provide a pointer or two that would be great.
      Problem:
      I'm using the Camarilla levels (indicator with n buffers, each buffer contains a level) as a stop.
      What i would like to do is detect a level cross by the price and based on that get the last previous level (or x levels away) . So, price breaks the Pivot level upwards so stop moves to the L3 level. Subsequent break of the H3 level and the stop moves to the Pivot level, etc.

      Obviously i could make a test for each level but that seems quite silly. I'm not a newbee when it comes to coding so i have a function that takes an array with values and the price and returns the proper level.
      The thing that i do not yet see is how to include such a custom function as a block in fxdreema.

      Any suggestion would be appreciated.

      Cheers,
      Fermin

      roar 1 Reply Last reply Reply Quote 0
      • roar
        roar @dcg last edited by roar

        Hi @dcg !

        There's a "custom mql code" block, you can do arrays there. You cannot make actual functions in fxdreema (except building your own blocks in studio), but you can treat the "custom mql code" block as your "function"

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

          Hi @roar ,

          Thx for your reply.
          This is indeed a thought that has crossed my mind but how do i gain direct access to an output-buffer of an indicator. In MQL5 we would use the handle, call the copyBuffer function and that would be it.
          How would one go about that in a custom block?
          Or, where could one find a snip of sample code reading indi buffers via the studio option you mentioned (did stumble across it already but without some sample snips it's a bit hard to decipher 😉 )

          Cheers

          roar 1 Reply Last reply Reply Quote 0
          • roar
            roar @dcg last edited by

            @dcg I'm afraid studio is the way to go here, unfortunately I can't provide any sample for that...

            Well, you could make an array for the latest buffer values, and update it in a loop.
            Maybe this is useful for you, I'm not sure:

            https://fxdreema.com/shared/jY7K1xSod
            0_1615073120597_1ec9689e-07b6-412b-9e2d-01b2ae756773-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
            • D
              dcg last edited by

              @roar Yes, this is indeed quite useful. I had completely missed the loop block (although i would not have come up with the way to access the array with the loop_index 😉 ).
              Guess i still have to write a custom block to test if a level was crossed by a certain bar and determine which level it was. As well as getting the next level going up or down.

              D 1 Reply Last reply Reply Quote 1
              • D
                dcg @dcg last edited by

                @roar
                Filling a static array will indeed work in the way you described.
                To make the whole setup complete one can add a condition block to the modify block that tests for the last index value, thus determining the end of the loop.

                roar D 2 Replies Last reply Reply Quote 0
                • roar
                  roar @dcg last edited by

                  @dcg awesome!

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

                    Following is the link to a sample prj containing a way to properly fill an array.
                    Array fill example

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

                    Online Users

                    A
                    G
                    Q
                    C
                    T
                    S
                    A
                    M

                    16
                    Online

                    146.7k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors