Here is a purely theoretical explanation of MQL4 programming language:
It also applies to any other software language.
The purpose of this explanation is to build a strong foundation for learning MQL4 programming language and to make any future information based on a solid understanding of what the programming language originally means.
Like any other software language, this language, such as visual basic, Delphi or C, has rules that you must learn and walk on.
- In no way can you deviate from these rules in an inch.
Every letter, comma or arc has meaning, and any breach of these rules means that the program cannot implement the program in the first place.
- The programming language can be viewed as a spoken language like any language globally, such as Arabic or English.
- Spoken languages have rules for writing and reading, names, sentences, letters, and so on. These are the elements of language.
- You will not start writing a programme until you are thoroughly familiar with the essential elements and a large proportion of the sub-elements.
Means you can start programming after you have access to all the language's critical elements and thus enrich your experience and skills to understand the various additional elements.
- You may become a good programmer, but you do not know how to send an email or post your transaction information directly online.
- But you should know that there is this possibility at least if you need it.
- We go back to the programming language again... Programming language also has elements that are reserved words and a specific structure for writing them.
- The elements of the code language are almost the same in all programming languages, but each language is different from the other in writing and language structure.
- All programming languages deal with numbers and only with numbers and understand only the language of numbers.
- Any information that the code language deals with is ultimately a number, even if you see it as a text, image, or number.
- For example, to display a specific text on the screen, we use the Print command as follows:
- Print "Welcome World" you here you see the text, but it is all numbers as the letter the number like this represents w, and another number and so on represent the letter e.
- When the order is executed, the Print command returns the W number to the W on the screen and so on.
- Even images and sounds are converted into numbers to store or handle and when displayed or played for sound these numbers are converted into an image on the screen or a sound that passes to the sound card.
- So you should also think of the same way as the programming language so that you see things in front of you as numbers.
- Take, for example, the badge in front of you, which is numbers in numbers that the trading program displays in the form of time-related candles. Even time numbers too.
- We will learn in the next lessons hopefully to make our way of thinking purely digital and turn any idea or strategy into just numbers so that we can program this idea into an indicator or to an expert.
- At first glance, this information may seem self-evident, but it is essential. It must be well aware of them.
Any programming language consists of the following elements:
- Constant: As we said earlier since the code language deals only with numbers and because the human mind will not be able to memorize the meanings of all the numbers it needs. A vital software concept has evolved: constants.
- Instead of using the number 255 to indicate red, we write instead of 255, the word Red, which is a fixed mutant of 255.
- Thus, the problem of dealing with the semantics of numbers was solved by converting the numbers into constants for the programmer to deal with, and then the program converts these constants into numbers again when it deals with them.
- We will find many constants in the MQL4 programming language that dramatically facilitates the programming process.
- Of course, if our memory is too strong, we can use the numbers directly instead of constants, but this is not easy when writing the code or modifying it.
- Variables: These are transitions to store correct numeric values without comma, comma, text values, or logical values.
- Mutants are the words of names that we choose to save the information we want, and we can change their contents at any moment we want, unlike constants, whose content cannot be changed.
- These transformations are essential for the program's work, and no program can be without them.
- Arrays Are unique mutants like the arrays we studied in high school so that they are a mutant with one or more dimensions.
- Different values can be stored in each cell of this matrix, and we can work on them with loops, saving a lot of time and effort.
- An example of arrays that we will deal with a lot in our next lessons is the Close Price Matrix. [Close]0 gives us the closing price for the current candle.
- Moreover, [Close gives us the candle's closing price that precedes it and so on.
The prices of the opening, the highest and the lowest have their matrix, as we will see in the next lessons, God willing.
- Conditions: The conditions instruction enables us to execute a software order or a block of code orders when a specific condition or conditions are met.
- If the conditions are not met, the code orders for these conditions will not be executed. It is this characteristic that exists in all languages that give our program some human intelligence.
- Because most of our lives start from implementing something specific when its terms are met, we pray for the times, for example, if the times permit, i.e. that the condition has been fulfilled. We do not eat until we are hungry, i.e. fulfilling the condition of eating (theoretically).
We are always checking the requirement to do this work if the condition is met.
- Thus, programming languages are always looking for certain conditions to be fulfilled to execute commands associated with these conditions. A programme's strength is its comprehensive briefing on all possible conditions and possibilities, at which point the program knows what to do when each requirement is met.
- For example, one of the funny stories about one of the programs used in protection is that a bank's protection system is managed by an emergency communication program when any of the conditions for infiltration into this bank are met by sensitive devices.
- The important thing is that one of the thieves sneaked into the bank, and then this smart program felt it, and he called 911. However, the line was busy. Because this condition or this possibility did not address the possibility that the line would be busy, it did not reconnect again.
- They then imagined the complete collapse of this security system because it did not address all possible possibilities that made it easier for the thief to carry out his mission.
(I expect the thief to be the programmer himself)
- Loops: Loops are essential in any programming language and can never be dispensed with. It is a way in which we can replicate a consistent routine a certain number of times.
- For example, to draw a pointer on the chart, we use a loop that passes on each candle candle candle to draw our index on a candle according to its terms. If it were not for the episodes, we would have had to repeat the software order equal to the number of candles, which is of course, sterile.
- Functions: Functions are code blocks grouped into one function where we can call and execute all of this code block by typing only the job name.
- This saves the programmer from writing the code frequently and quickly editing and revising the code.
- For each parameter's function, which are values that enter the same function that you use in their programming mass (this will be explained in tedious detail)
- All functions can return a specific value that is calculated according to the information provided to them.
- Comments: Any programming language that provides the programmer with the ability to write an explanation or comments within the code itself, the function of this explanation is to make it easier to modify the code itself or explain the code to the unprogrammed in order to clarify an idea or explain how the program is used, for example.
- Compiler: It may be surprising to you that the program or computer will not understand your code directly, so each language has its translator that converts the code you are writing to another language, which is only numbers that it understands.
- As we said earlier, your computer does not understand the script you are writing, so it translates it first into its digital language to handle and execute your software.
- Development Environment: Each software language has its development program to write a new program with different possibilities such as copying, pasting, deleting, searching, replacing and other services.
- It also shows you your code of the colour that distinguishes commands from mutants' functions from the constants of comments and so on.
- It also helps us write the code and provide a direct explanation of all the language commands and then correct and revise the program and then save, translate and run.
- In our case, Meta Editor is the development environment for our Gold MQL4.
- System: The work system is the target system of our program we write a program in the language of C or visual basic to work under windows system.
- In our case, we are writing our program, which is an index or expert to work on the MetaTrader trading program.
- No programme will work unless it is designed.
- The visual basic or C program will not work under the MetaTrader system, and our index or expert software will not work under Windows.