Discussing the article: "Introduction to MQL5 (Part 5): A Beginner's Guide to Array Functions in MQL5"

 

Check out the new article: Introduction to MQL5 (Part 5): A Beginner's Guide to Array Functions in MQL5.

Explore the world of MQL5 arrays in Part 5, designed for absolute beginners. Simplifying complex coding concepts, this article focuses on clarity and inclusivity. Join our community of learners, where questions are embraced, and knowledge is shared!

Part 5 of our series will introduce you to the fascinating world of MQL5, designed especially for complete novices looking for a gentle introduction to the intricacies of array functions. This section aims to dismantle the misconceptions that are frequently associated with array functions, guaranteeing that each line of code is not only understood but comprehended thoroughly. Regardless of prior coding experience, I sincerely believe that everyone should have the opportunity to learn about the MQL5 language, which is why I will always be committed to creating an inclusive environment.

In this article, simplicity and clarity are the primary themes. I want to serve as a conduit for people who are curious about coding and the uncharted territory of it. Though they can be confusing at first, I intend to walk you through each array function one line at a time so that you have a fun and educational learning experience. Together, we will solve the puzzles surrounding array functions and equip you with the knowledge necessary to successfully negotiate the complex world of algorithmic trading. This isn't just an article—it's an invitation to go on an amazing journey of coding transformation. 

But things don't stop here. Beyond the code, we hope to create a community where both novice and seasoned programmers can congregate to exchange ideas, pose queries, and promote teamwork. This is an invitation to go on a life-changing coding adventure, not just an article. Greetings from Part 5, where knowledge and accessibility collide and everyone who codes is appreciated. Have fun with coding!

Author: Israel Pelumi Abioye

 
Thank you for sharing your knowledge on the difference between ArrayGetAsSeries and ArrayIsSeries which I have been trying to figure out for a while now. I like your approach on explaining complex topic in a beginner friendly way backed up with analogy… I’m also a bit confused about the difference between ArrayCopy and ArrayInsert. I’d appreciate if you can include that in your next article.
 
Oluwatosin Mary Babalola #:
Thank you for sharing your knowledge on the difference between ArrayGetAsSeries and ArrayIsSeries which I have been trying to figure out for a while now. I like your approach on explaining complex topic in a beginner friendly way backed up with analogy… I’m also a bit confused about the difference between ArrayCopy and ArrayInsert. I’d appreciate if you can include that in your next article.
Hello Oluwatosin, your request has been noted
 
Oluwatosin Mary Babalola #:
Thank you for sharing your knowledge on the difference between ArrayGetAsSeries and ArrayIsSeries which I have been trying to figure out for a while now. I like your approach on explaining complex topic in a beginner friendly way backed up with analogy… I’m also a bit confused about the difference between ArrayCopy and ArrayInsert. I’d appreciate if you can include that in your next article.

Do you know about the MQL5 programming book? Specifically, it covers array "seriesness" (direction) functions, as well as copies and inserts - here is an excerpt:

Unlike the ArrayInsert function, the ArrayCopy function does not shift the existing elements of the receiving array but writes new elements to the specified positions over the old ones.

Both sections contain example programs.

MQL5 Book: Common APIs / Working with arrays / Timeseries indexing direction in arrays
MQL5 Book: Common APIs / Working with arrays / Timeseries indexing direction in arrays
  • www.mql5.com
Common APIs - MQL5 Programming for Traders - MetaTrader 5 algorithmic/automatic trading language manual
 
Oluwatosin Mary Babalola #:
Thank you for sharing your knowledge on the difference between ArrayGetAsSeries and ArrayIsSeries which I have been trying to figure out for a while now. I like your approach on explaining complex topic in a beginner friendly way backed up with analogy… I’m also a bit confused about the difference between ArrayCopy and ArrayInsert. I’d appreciate if you can include that in your next article.

Difference between ArrayInsert and ArrayCopy:

The main difference between "ArrayInsert()" and "ArrayCopy()" is how they handle elements that already exist. "ArrayCopy()" may modify the original array by substituting elements from another array for those at a given position. On the other hand, "ArrayInsert()" preserves the array's structure and sequence by moving the current elements to make room for the new ones. Essentially, "ArrayInsert()" provides a versatile method for manipulating arrays in MQL5, akin to adding a new element to a sequence without causing any other pieces to move. Comprehending this distinction enables you to precisely manipulate array operations in your programming pursuits.

Note that for static arrays, if the number of elements to be inserted equals or exceeds the array size, "ArrayInsert()" will not add elements from the source array to the destination array. Under such circumstances, inserting can only take place if it starts at index 0 of the destination array. In these cases, the destination array is effectively completely replaced by the source array.

Analogy

Imagine you have two sets of building blocks (arrays), each with its unique arrangement. Now, let's say you want to combine these sets without messing up the existing structures. "ArrayInsert()" is like a magic tool that lets you smoothly insert new blocks from one set into a specific spot in the other set, expanding the overall collection.

Now, comparing "ArrayInsert()" with "ArrayCopy()": When you use "ArrayCopy()," it's a bit like rearranging the original set by replacing some blocks with new ones from another set. On the flip side, "ArrayInsert()" is more delicate. It ensures the existing order stays intact by shifting blocks around to make room for the newcomers. It's like having a meticulous assistant who knows exactly where to put each block, maintaining the set's original design.

For static sets (arrays), there's an important rule. If the number of new blocks is too much for the set, "ArrayInsert()" won't force them in. However, starting the insertion process from the very beginning of the set (index 0) can effectively replace the entire set with the new blocks.

Reason: