fbtrader / estudando

0 stars 0 forks source link

Cap 1 #5

Open fbtrader opened 6 years ago

fbtrader commented 6 years ago

Book: Expert Advisor Programming For Metatrader 5 Andrew R. Young

Chapter 1 - MQL5 Basics 3 MQL5 Programs 3 File Extensions 3 Other File Types 3 File Locations 4 MetaEditor 5 MQL5 Wizard 7 Compilation 8 Syntax 8 Identifiers 9 Comments 9

fbtrader commented 6 years ago

expert advisor is an automated trading program that can open, modify and close orders. (just one per chart)

fbtrader commented 6 years ago

An indicator displays technical analysis data on a chart or in a separate window using lines, histograms, arrows, bars/candles or chart objects (multiple)

fbtrader commented 6 years ago

A script is a specialized program that performs a specific task. (one script per chart) (execute only once)

fbtrader commented 6 years ago

Extensions: Source code: MQ5 file (.mq5) EX5 file (.ex5): compiled MQH file (.mqh): include

fbtrader commented 6 years ago

An include file (.mqh) is a source code file that contains classes, functions and variables for use in an MQL program. Include files contain useful code that can be reused over and over again.

A library is an executable file that contains reusable functions, similar to an include file. Libraries are in EX5 or Windows DLL format.

fbtrader commented 6 years ago

An expert settings file or preset file (.set) contains trade parameters for an expert advisor.

fbtrader commented 6 years ago

File locations: C:\Program Files\MetaTrader 5\MQL5

• \Experts – This folder contains the MQ5 and EX5 files for expert advisors. • \Indicators – This folder contains the MQ5 and EX5 files for indicators. • \Scripts – This folder contains the MQ5 and EX5 files for scripts. • \Include – This folder contains MQH include files. • \Libraries – This folder contains the MQ5, EX5 and DLL files for libraries. • \Images – If your program uses bitmap images, they must be stored in this folder in .bmp format. • \Files – Any external files that you use in your programs, other than include files, libraries, images or other MQL programs, must be stored in this folder. • \Presets – This is the default folder for .set files that are loaded or saved from the expert advisor Properties dialog or from the Inputs tab in the Strategy Tester. • \Logs – The expert advisor logs are saved in this folder. You can view these logs in the Experts tab inside the Toolbox window in the main MetaTrader interface.

fbtrader commented 6 years ago

MetaEditor is the IDE (Integrated Development Environment) for MQL5 that is included with MetaTrader 5 MetaTrader interface by clicking the MetaEditor button on the Standard toolbar, or by pressing F4 on your keyboard

fbtrader commented 6 years ago

Ctrl+Shift+Space on your keyboard, or by selecting Parameter Info

fbtrader commented 6 years ago

MetaEditor has a built-in MQL5 Reference, which is useful for looking up MQL5 functions and language elements. Simply position the cursor over an MQL5 keyword and press F1 on your keyboard

fbtrader commented 6 years ago

https://www.youtube.com/watch?v=XVW_6X_uf8Q&index=2&list=PLltlMLQ7OLeKwyQwC8FhiKwjl9syKhOCK

fbtrader commented 6 years ago

Expert Advisor (generate) – This allows the user to create an expert advisor without any coding. The generated expert advisor uses the MQL5 standard library.

fbtrader commented 6 years ago

New Class – This will create an include file with a class definition from a built-in template. The created file is saved in the \MQL5\Experts folder, or a specified subfolder.

fbtrader commented 6 years ago

MQL5 is similar to other modern programming languages such as C++, C# or Java

fbtrader commented 6 years ago

When naming variables, functions and classes, you need to use a unique and descriptive identifier

You can use letters, numbers and the underscore character (_), although the first character in an identifier should not be a number. The maximum length for an identifier is 64 characters. This give you a lot of room to be creative, so use identifiers that are clear and descriptive.

Identifiers are case sensitive

fbtrader commented 6 years ago

Global variables, objects, classes and function names will capitalize the first letter of each word. For example: MyFunction() or MyVariable

Local variables and objects, which are declared inside a function, will use camel case. This is where the first letter is lower case, and the first letters of all other words are upper case. For example: myVariable or localObject.

Constants are in all upper case. Use underscores to separate words, for example: MY_CONSTANT.

fbtrader commented 6 years ago

// This is a comment

/ This is a multi-line comment These lines will be ignored by the compiler x = y + z; /

fbtrader commented 6 years ago

In the Edit menu, under the Comments submenu, the Comment Lines menu item will comment out the selected lines, while Uncomment Lines will remove comments from selected lines. The Function Header menu item will insert a commented function header similar to those in the auto-generated MQ5 files: // Function header generated by Edit menu –> Comments –> Function Header //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+

Editar>Avançado> Função Cabeçalho