fxDreema

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

    Help needed in modifying values in a sequence

    Questions & Answers
    4
    31
    7012
    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.
    • R
      rafaels919 last edited by rafaels919

      Hi, I'm looking for someone to help me create a small configuration in a form of a Block, so that I can use it in my project.
      I will gift a subscription to the person who can figure this out.

      The issue is concerning the "Sequence on loss" input in the "Buy Now" block and it's values.

      I need to be able to shift back to previous values in that sequence.

      Let's take the following as an example:
      alt text

      I have a custom sequence "sequence on loss": 1,2,3,4,5,6

      And let's say we had 3 consecutive losses in a row -> and we are currently on the 4th trade.
      If that's the case, then we are trading on the third input value of the "sequence on loss" ( value: 3)

      I want to be able to shift back to the second value instead (2) or the first value (1) whenever a condition is met (to be able to use a block as a controller would be best)

      I previously tried to store the "sequence on loss" in a variable, and change the data using "modify variables" block:
      alt text
      Unfortunately, this method didn't work. The EA either resets the sequence, or continues (I couldn't find a way to change the sequence or shift back to the previous value without breaking it).

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

        @rafaels919 Hi!

        I cannot offer a beatiful one-block solution, but putting the sequence into an array is one solution - check my example: https://fxdreema.com/shared/YYdcM1Wbb

        The array determines the sequence number with a variable loses, which tracks consecutive loses (and you can modify the variable directly as well)

        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 1
        • R
          rafaels919 last edited by

          Hi @roar , thanks for your response!

          How do I modify the "sequence on loss"?
          alt text

          Changing the "seq[]" variable didn't change the sequence in the EA (which is set to 1,2,3,4,5,6 somehow):
          alt text

          Also, how do I make a shift to the previous value in the sequence?
          ( This function is important, as long as this works and I can freely utilize it using conditions and what not, having "one block" is not that important)

          1 Reply Last reply Reply Quote 1
          • R
            rafaels919 last edited by rafaels919

            @roar
            In this reference, for example:
            alt text

            I have two conditions, where I shift back to the previous value in the sequence.

            I want to be able to do similar. It doesn't need to be just 1 block, but it needs to work in a similar fashion, where I can use it multiple times under different conditions.

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

              @rafaels919 @miro1360 created a manual martingale system that you may have a look at. Like that you might set or reset the next lot size by yoursel.

              https://fxdreema.com/shared/t0iMPPuGc

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

              1 Reply Last reply Reply Quote 0
              • R
                rafaels919 last edited by rafaels919

                @roar I see that you had the "sequence on loss" and the "baselot" stored in Constants. It makes sense now.
                But it still doesn't shift back. Could you explain the variables and what each one does?:
                alt text

                And how would I set it up to shift back in a similar configuration (having 2 or more separate conditions for a shift back simultaneously):
                alt text

                @trader-philipps I see. But reset is not what I'm looking for. Also that configuration seems to work only with a single value in a variable (e.g. I can't use "modify variables" block with multiple values - aka sequence, such as "1,2,3,4,5" for example, which you pointed out to me in a different topic)

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

                  @rafaels919 I'm on mobie right now and can't open blocks. But I think to remember that there was an array of the multiplicators. Each array has an index. So you can address each value by the index.
                  So if you assume to be at trade 3 and want to step back you'd access the value of the array for current index position -1

                  Does that make sense?

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

                  1 Reply Last reply Reply Quote 0
                  • R
                    rafaels919 last edited by

                    @trader-philipps I'm not sure what Roar did here, but I guess it's something similar to what you described:
                    alt text
                    I'm not sure how the "variables" function and how they are adjusting the sequence that is stored in the Constants:

                    Miro's project changes the lot size only as far as I understand, and uses the Multiplicator instead of a Sequence.

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

                      @rafaels919 Sorry, I mixed up the projects. I meant @roar 's approach.

                      I pimped the code a bit to make it more obvious what @roar or I with my answer meant.

                      In roar's project he sets the constants like that

                      0_1579244004087_fc9f20b3-b6eb-452d-ae0e-4e509eb51f0f-image.png

                      Those are 6 values. Roar splits that sequence string into 6 parts (seperator is the comma) and creates an array seq[i]. In the given case the array index has a size of 6. As arrays are 0 based, this means it starts counting by 0 (not by 1). You can read the integer value of each array position in the index like
                      seq[0], seq[1], ...,seq[5]

                      I print this out in the log and here is the result ..

                      0_1579243945176_57e9d83d-976c-46c3-bd7c-afeec8f49654-image.png

                      Knowing this, you can at each time go wherever you want in the index of the array by selecting the right index value.
                      So if you count your losses by a variable, you can use the array like roar did in the BUY block.

                      baseLot * seq[loses]

                      0_1579244484479_Auswahl_843.png

                      loses is the integer of your losses counter. So if you are at losses 3, it will do like baselot * seq[2]
                      Unfortunately there is a glitch in roar's code as the array is 0 based. So if the first value is not 1, it will not match corectly (or in other word works different to fxdreema). But that's not that important.

                      Did you get what I mean?

                      Again in short refering to roar's version.

                      Sequence is: 1, 3, 5, 7
                      Startlot is 0.01

                      Will result in ..

                      seq[0]: 1
                      seq[1]: 3
                      seq[2]: 5
                      seq[3]: 7

                      Where the numbers in brackets represent the value of you losses counter.

                      Is that clear?

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

                      1 Reply Last reply Reply Quote 2
                      • R
                        rafaels919 last edited by rafaels919

                        @trader-philipps
                        Let me know if I get this right.

                        1. So the sequence string that is in the Constants is converted into 6 separate parts, seq[0]... seq[5]
                        • What is the Variable "seq[]" used for?
                        1. And the "loses" variable is the consecutive losses counter - and if I set it to 3 for example, it will shift back one value, right?

                        So let's say the sequence is: 1,2,3,4,5,6 - just as in @roar 's project.
                        If the "loses" variable is set to 3, and I lost the third consecutive trade (value "3" from the array^) - then it won't proceed to value 4, instead it will repeat the value 3 once -> is this correct?

                        1. What is "seqLen" for?

                        I think I need to know what each variable is for to understand the logic behind the setup.

                        roar 1 Reply Last reply Reply Quote 1
                        • roar
                          roar @rafaels919 last edited by roar

                          @rafaels919 Hi!

                          That's right, my approach is to convert the sequence string to an int array (because you can't use a string in any calculation). This converting is done in the "on Init" tab.

                          • What is the Variable "seq[]" used for?

                          This is a special kind of variable: an array. Arrays dont store just one value, but multiple values - like a list, or a table.

                          In MQL, array indexing starts from 0, so the first value of your sequence is seq[0] = 1,
                          if the original sequence string was "1,2,3,4,5,6".
                          Last value would be seq[5].

                          0_1579251339989_18ca4577-095c-457d-8935-3326f526c40b-image.png
                          ^ This part is for resetting the sequence, in case we go to a 7th loss (and the array doesn't have a value for that). "seqLen" is the size of the array, and because arrays start from 0, the actual last index in the array is seqLen - 1.

                          I admit, this is very confusing setup, lol. But you don't necessarily need to know every detail, just know that you can modify the loses variable to set the sequence to whatever value you like.
                          If you want revert to 2nd sequence value, modify variable loses to 1.
                          For 3rd sequence value, modify variable loses to 2.

                          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 2
                          • roar
                            roar last edited by roar

                            https://fxdreema.com/shared/i6NwpEuZc
                            Here I fixed the array so that you can forget about the 0-start thing:
                            If you need 3rd value, use seq[3] and so on. (seq[loses] when loses = 3)
                            So now it is the same as the default "custom sequence" setting, I think it is more convenient to use this way.
                            (I did this by adding "1" to the beginning of the actual array)
                            0_1579252312712_77704fbc-4618-4131-9491-03107924dd68-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
                            • R
                              rafaels919 last edited by rafaels919

                              So I tried to run a little test following your description, but it didn't shift back neither did it reset at the "seqLen" Limit.

                              alt text
                              "loses" variable (to control the consecutive losses) - after which it should shift back one value or in other words, to not proceed to the next value in the array for that instance.
                              "seqLen" variable (to reset the array after number of consecutive losses)
                              alt text

                              I guess I'm doing something wrong again? @roar

                              Also, as I mentioned before - I need to be able to freely utilize the "shiftback", using conditions and what not. Could this be possible with your configuration?

                              By the way, if the sequence string is now an "Array", would it be possible to change that array using "Modify Variables" instead, which I described in my introduction text?
                              alt text
                              This^, which couldn't work storing the "sequence on loss" in a variable, because the "Modify Variables" block can't change string sequences. If I could somehow use a single block like that to change the whole array at a given condition, that would solve everything.

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

                                @rafaels919 said in Help needed in modifying values in a sequence:

                                So I tried to run a little test following your description, but it didn't shift back neither did it reset at the "seqLen" Limit.
                                0_1579263290588_749e022c-c000-44f4-844b-fea9569f8d80-image.png

                                You can't modify the variables in that builder window, just leave them 0 (because any value will be overwritten in the next step). The variables and arrays will be initialized according the given constants (see the "on Init" tab).

                                By the way, if the sequence string is now an "Array", would it be possible to change that array using "Modify Variables" instead, which I described in my introduction text?

                                Yes, you can use the "modify variables" block to modify your array, but only one element at a time. For example, if you want to take the first element of the array, use seq[0]. For second element, use seq[1] and so on... But why would you want to modify the sequence itself? Doesn't it suffice to just modify the "continuation", take a different part from the sequence?

                                If I could somehow use a single block like that to change the whole array at a given condition, that would solve everything.

                                Changing the whole array requires a loop and possibly re-sizing the array, if the resulting array is longer or shorter than the original. I don't think that is the easiest solution 😄

                                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

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

                                  @rafaels919

                                  Also, as I mentioned before - I need to be able to freely utilize the "shiftback", using conditions and what not. Could this be possible with your configuration?

                                  https://fxdreema.com/shared/hjSUXN3Zb
                                  Here I continue my example, with an arbitrary condition: when RSI crosses above 60, modify loses to 2.
                                  The sequence is the default "1,2,3,4,5,6".
                                  I also added a text under each candle to keep track of the active sequence value.
                                  Here's how it behaves:
                                  0_1579263051405_878ce1e6-d4f8-4da6-8995-5e1a4fa3380e-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 1
                                  • R
                                    rafaels919 last edited by rafaels919

                                    @roar I see. So I can use the "Modify Variables" block and change the "loses" variable -> and it will revert to that value from the array and continue from there, right?

                                    I will test that thoroughly a bit later with other conditions, so far I noticed few issues:

                                    1. When it loses 6 times in a row (full array length) it doesn't reset and stops working completely.
                                      alt text

                                    2. It skips second value from the array (0.02=0.01*2) from time to time, not sure why:
                                      alt text

                                    3. It also reverts back to the third value sometimes, which doesn't make sense (from 0.06 to 0.03):
                                      alt text

                                    PS: used your latest version. Didn't edit anything.

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

                                      @rafaels919 Don't take the code for granted! It should show you the way you can go.

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

                                      1 Reply Last reply Reply Quote 0
                                      • R
                                        rafaels919 last edited by

                                        @trader-philipps said in Help needed in modifying values in a sequence:

                                        Don't take the code for granted! It should show you the way you can go.

                                        What do you mean by that?

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

                                          @rafaels919 I fixed the bugs you found, check this one:
                                          https://fxdreema.com/shared/J3efZjb2e

                                          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 1
                                          • R
                                            rafaels919 last edited by rafaels919

                                            Hey @roar
                                            it looks great, the bugs are gone. Do you think it is possible to have it to shift two values back instead of reverting to value two?

                                            For example:

                                            1. We have the "loses" variable changed to "2" by "modify variables" block when RSI crosses 60 (just as in your example)

                                            2. If we are on 5th value - we don't revert back to the 2nd value - instead -> we shift back two values (so we would be on the 3rd value instead of 2nd value) -> so it doesn't REVERT to two when the condition triggers but SHIFTS BACK two values.

                                            Your configuration looks great, hopefully we can make this last adjustment.

                                            T roar 2 Replies Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            Online Users

                                            T
                                            G
                                            E
                                            M
                                            E
                                            A
                                            K
                                            M
                                            G
                                            C

                                            21
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors