fxDreema

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

    My first MQL5 array doesn't work

    Questions & Answers
    7
    21
    2368
    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.
    • l'andorrà
      l'andorrà last edited by

      I created my first easy array for MT5 but I get more than 20 errors. Could someone please tell me where's the problem?

      https://fxdreema.com/shared/QMG0YDDBb

      (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

      (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

      (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

      jstap S 2 Replies Last reply Reply Quote 0
      • jstap
        jstap @l'andorrà last edited by

        @l-andorrà Have always stayed away from arrays, maybe roar can help, I have noticed this though when you create the variable you likely need this; array[], as for the number you use I am not sure, maybe you would need to set ort change array size before it will wrk.

        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! 😊

        l'andorrà 1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà @jstap last edited by

          @jstap This is my last frontier to explore! I find arrays can be very useful but I don't know hoe to create them in fxDreema. Any help would be much appreciated.

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          jstap roar fxDreema 3 Replies Last reply Reply Quote 0
          • jstap
            jstap @l'andorrà last edited by

            @l-andorrà I have never tried, well not recently, put this is a variable array[1], try to put data in it and display in a comment, if it works you can try adding 1 & 2 and display. if this doesn't work though you will have to see what custom code is needed. What always confused me with arrays is getting the value, getting max or min is simple but each value I'm not sure.

            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
            • roar
              roar @l'andorrà last edited by

              @l-andorrà the array works just fine in my backtest
              29c29d38-8490-49cf-83c0-624e64e00c52-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
              • fxDreema
                fxDreema @l'andorrà last edited by

                @l-andorrà said in My first MQL5 array doesn't work:

                This is my last frontier to explore!

                Haha, ok 😄

                What you did looks correct.

                Technically you can also do this in MQL:

                int array[] = {10, 20, 30};
                

                But for some reason in fxdreema if you define a variable with name array[] and value {10, 20, 30}, the array is added in the EA, but the value is not applied. I don't know why. I know I worked on this few times and its possible that this is intentional.

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

                  Ok, I made it now to work with initial values like {10, 20, 30}.

                  If no value is specified, and when the type of the array is numeric (int, double), the value will automatically appear as 0, which looks wrong when we work with arrays, but this 0 is not actually used. Even if you write any other numeric value, it will not be used. Only value containing { will be used as initial value.

                  l'andorrà 1 Reply Last reply Reply Quote 1
                  • S
                    seb 0 @l'andorrà last edited by

                    @l-andorrà
                    Did you get these errors on fxdreema trying to export the project as .ex5 ?

                    1 Reply Last reply Reply Quote 0
                    • l'andorrà
                      l'andorrà @fxDreema last edited by

                      @fxDreema Your changes apparently worked...partially. Now no errors are identified when compiling but when I run the EA on the chart no info is visible on the chart until I remove the EA!! 😮

                      Then I can see the results as per roar image. Can't the comment(ugly) block be executed on the on init for MT5, maybe? 😳

                      (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                      (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                      (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

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

                        @l-andorrà, I did nothing to fix any compiling errors. The example you posted in the first post compiles sucessfully, it has no problems, not even warnings. I tested it and my results are the same as @roar. I don't know what you did to get these compilation errors, and I don't know what they are. Maybe you can tell us what your errors are.

                        About the Init event... I noticed few times that when I try to run some EA in MT5 on the weekend, it says Market Closed or something. I didn't investigate this problem, I only noticed it. Do you have such errors?

                        By the way, the {10, 20, 30} thing doesn't work for Constants, because they are inputs. If we try to do this in MQL5:

                        input double myArray[] = {3, 3, 3};
                        

                        it gives us error: array is not allowed as input.

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

                          I think this is a graphics and chart refreshing issue, array itself works 🤔

                          If you print out the array elements (using Print() function) instead of commenting on the chart, it always works.

                          Also, if you make a ChartRedraw() after the comment block, the commenting works too.

                          https://fxdreema.com/shared/71T8DgAze

                          Mql5 is such a diva, always demanding some weird special tricks lol

                          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

                          fxDreema 1 Reply Last reply Reply Quote 0
                          • P
                            Pheaktra Capo last edited by

                            Excuse me. Can you tell me what is the purpose of using Array? What can it do?
                            I am not good at Raw Code. I want to learn more(from MQL, youtube, google, etc,.). Thank you.

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

                              @roar said in My first MQL5 array doesn't work:

                              Mql5 is such a diva, always demanding some weird special tricks lol

                              Absolutely. MQL5 is very annoying language. And I'm a JavaScript developer.

                              @Pheaktra-Capo Arrays contain multiple values, as many as you want. And you can iterate these values - access them one after another. So they are often used in for loops. A simple array is like one row (or column) of data in a table. In MQL there are multi-dimentional arrays that are more like whole tables of data... but you don't want to try these.

                              P 1 Reply Last reply Reply Quote 1
                              • R
                                RGoo @Pheaktra Capo last edited by

                                @Pheaktra-Capo
                                If you need your EA to calculate a lot of data related to a common ground, e.g. the data of a series of candles, you need to use arrays. Otherwise you lose track. You then only need one variable e.g. myarray[10][5] to replace 50 individual variables. A huge advantage!
                                And actually, working with arrays is very easy if you take some time and invest some practice.

                                RGoo

                                P 1 Reply Last reply Reply Quote 0
                                • l'andorrà
                                  l'andorrà last edited by l'andorrà

                                  It works now. Thank you all for your help. BTW. how can I remove the 'unsolved' tag on the thread? 🙂

                                  (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                  (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                  (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                  1 Reply Last reply Reply Quote 0
                                  • l'andorrà
                                    l'andorrà last edited by

                                    I finally found how to mark a thread as 'solved'. Why didn't anyone told me? :D.

                                    (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                    (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                    (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                    jstap 1 Reply Last reply Reply Quote 0
                                    • jstap
                                      jstap @l'andorrà last edited by

                                      @l-andorrà I see how did you do it?

                                      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! 😊

                                      l'andorrà 1 Reply Last reply Reply Quote 0
                                      • P
                                        Pheaktra Capo @fxDreema last edited by

                                        @fxDreema thank you very much. I will search and learn more about array.

                                        1 Reply Last reply Reply Quote 0
                                        • P
                                          Pheaktra Capo @RGoo last edited by

                                          @RGoo Sound very good. This might help ton of my variable. Thank you very much.

                                          1 Reply Last reply Reply Quote 0
                                          • l'andorrà
                                            l'andorrà @jstap last edited by

                                            @jstap You can find it on my other thread with questions on arrays.

                                            (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                            (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                            (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

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

                                            Online Users

                                            S
                                            M
                                            2
                                            M
                                            M
                                            N
                                            B
                                            A
                                            B
                                            S
                                            E
                                            W

                                            28
                                            Online

                                            146.6k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors