int iMA(
string symbol, // symbol name
ENUM_TIMEFRAMES period, // period
int ma_period, // averaging period
int ma_shift, // indicator horizontal shift
ENUM_MA_METHOD ma_method, // smoothing type
ENUM_APPLIED_PRICE applied_price // price type or handle
);
using which you can get the same result. But. How to get applied_price when using the short form int OnCalculate(). In other words, how to get to the values in the "Parameters" tab when initialising the indicator?
Thanks.
Thank you.It is very clear and useful for beginners.
if(prev_calculated==0) // check for the first start of the indicator
first=MAPeriod-1+begin; // start index for all the bars
else first=prev_calculated-1; // start index for the new bars
when first=MAPeriod-1+begin; which is current bar ? [0] or [rates_total] ?
when first=prev_calculated-1; it is a large number, need repeat calculate ?
- 2010.03.03
- Nikolay Kositsin
- www.mql5.com
Thanks for the article! Very useful material for a beginner and
for someone who is transitioning from another language.
Computer translated? Make do.
Compared to MQL4, the metrics array subscripts are calculated from the past and are fixed, not dynamic. I wonder what happens when you run it for a week or a month? Is the data all in memory? If it's all in memory, won't it run slower and slower?
However, at https://www.mql5.com/zh/articles/31中又说:
- "Setting the index of an element as a sequence is the same as in MQL4" - What does this mean? In our example, we use the element index as a time series. In other words, the current column (not yet formed) always has index [0], the previous one (already formed) has index [1], and so on.
So be careful which case is actually used. most of the MQL4 examples use an index array with current as 0, most of the MQL5 examples use an index array subscript with past as 0.

- 2013.09.04
- Sergey Pavlov
- www.mql5.com
Computer translated? Make do.
Compared to MQL4, the metrics array subscripts are calculated from the past and are fixed, not dynamic. I wonder what happens when you run it for a week or a month? Is the data all in memory? If it's all in memory, won't it run slower and slower?
However, at https://www.mql5.com/zh/articles/31中又说:
- "Setting the index of an element as a sequence is the same as in MQL4" - what does this mean? In our example, we use the element index as a time series. In other words, the current column (not yet formed) always has index [0], the previous one (already formed) has index [1], and so on.
So be careful, which case is actually used. most of the MQL4 examples use an array of indicators with the current as 0, and most of the MQL5 examples use an array of indicators with subscripts with the past as 0.
The ArraySetAsSeries() function is to be used in MQL5 to convert dynamic arrays (allocating memory to store the latest values in the direction of the larger index) into a time series form, i.e., the newest data is stored at index 0, the next newest data is stored at index 1, and so on, with the newest data being stored at index 0 forever.
Read with the copybuffer () function, from the position of index 0 to start reading backward elements of the array, read how many of their own definition on the line.
Nicholas!
Can you tell me why when I try to fill an indicator array in a loop using the formula Mass[ i ]= Mass[ i+1]+A; where A is a variable, compilation passes without errors, but when attached to the window, the message array out of range (out of array size) appears?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Custom Indicators in MQL5 for Newbies is published:
Any new subject seems complicated and hard-to-learn for a newbie. Subjects that we know seem very simple and clear to us. But we simply do not remember, that everyone has to study something from scratch, and even our native language. The same is with the MQL5 programming language that offers wide possibilities of developing one's own trading strategies - you can start learning it from basic notions and simplest examples. Interaction of a technical indicator with the MetaTrader 5 client terminal is consider in this article on the example of the simple custom indicator SMA.
Author: Nikolay Kositsin