How to start with MQL5 - page 7

You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
An example of get values from the iRSI indicator
Code: iRSI get value.mq5
Do not forget the rules: create the indicator handle ONCE in OnInit,
use CopyBuffer to get the data:
Result:
Рис. 1. iRSI get value
An example of get values from the iBands indicator
Code (Expert): iBands values on a chart.mq5
Do not forget the rules: create the indicator handle ONCE in OnInit,
use CopyBuffer to get the data:
Result:
Рис. 1. iBands values on a chart
Example of creating an indicator based on iATR
code: xSuperTrend.mq5
Step 1: In the MetaEditor, go to the folder with indicators (in my example, this is the "MyInd" folder). Next click the right mouse button:
Pic. 1. Step 1
Step 2: Choose the type of program: Custom Indicator
Pic. 2. Step 2
Step 3: Enter the name of the indicator
Pic. 3. Step 3
Step 4. We connect the full form for OnCalculate
Pic. 4. Step 4
Step 5. We add three graphical constructions to the indicator. We give them names and colors.
Pic. 5. Step 5
As a result, we get a blank indicator. Denote the version with the number '1.000'
To be continued ...
Example of creating an indicator based on iATR. Part 2.
code: xSuperTrend.mq5
Let's start filling our indicator: add input parameters, add the variable "handle_iATR" - the handle of the iATR indicator will be stored in it.
Note: the variable 'handle_iATR' is declared at the global program level (in the "header" of the program).
Save the version number 1.001
To be continued ...
Example of creating an indicator based on iATR. Part 3.
code: xSuperTrend.mq5
Works with help ( iATR )
Our indicator ('xSuperTrend') is equipped with iATR - which means we need one more buffer. Add a buffer.
It was:
It became:
We get the handle of the indicator (do not forget: the handle needs to be received ONE time in OnInit)
Save the version number 1.002
To be continued ...
Example of creating an indicator based on iATR. Part 4.
code: xSuperTrend.mq5
Works with help ( iATR ) - Copy paste :)
First, at the "top of the program", add a variable 'bars_calculated' - it stores the number of barors that the iATR indicator has counted.
We almost completely insert the code from the help (In the inserted code, replace 'handle' with 'handle_iATR')
Save the version number 1.003
To be continued ...
Example of creating an indicator based on iATR. Part 5.
code: xSuperTrend.mq5
Until this moment, we performed preparatory operations. Now it is time to write the indicator logic.
To avoid unnecessary calculations, we always work in the 'prev_calculated' variable
Remember that the indicator already has all arrays by the current character (ope, high, low, close, and others) - they are transferred through OnCalculate.
Save the version number 1.005
The end.
Step-by-step instruction: the indicator displays two iCCIs in one window.
So, step by step:
Fig. 1. Step one
Full text and code: CCI Dual:
Simple example One position
Code: Simple example One position.mq5
The EA holds one position in the market (of a given type) - as soon as you close this position, the EA will open one position again.
Example MultiTimeFrame iRSI get value
Code: Example MultiTimeFrame iRSI get value.mq5
It should be remembered that in MQL5 the indicator handle must be received once (in OnInit). Objective: there are three timeframes and their own parameters for RSI indicators. You need to get values from these indicators.
Algorithm of actions: at the global program level (in the "header" of the Expert Advisor), declare the 'arr_handle_iRSI' array - this array will store the handles of RSI indicators from different time frames.
Code:
Result of work: