Discussion of article "Custom Indicators in MQL5 for Newbies"

 

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

 
 Very interesting article for those who start..... I hope that others as this.... thanks
 
Written and narrated with an A. After reading it, you will want to create something of your own. It is not very interesting to rewrite the code every time and MQL5 authors, realising this, have created a large library of built-in functions. Here is one of them:

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. very clear explanation for newbie like me. waiting for next article ...
 

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 ? 

 
In the article " Custom Indicators in MQL5 for Newbies" it is said, "It's better to use the increasing order [rather than "reverse order"] in indicators." But if the program runs on and on, it would eventually tend toward infinity, i.e. the (integer) buffer for the index numbers would soon run over, wouldn't it? How do you handle this?
Custom Indicators in MQL5 for Newbies
  • 2010.03.03
  • Nikolay Kositsin
  • www.mql5.com
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.
 

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中又说:

  1. "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.

MQL5 初学者:EA 交易技术指标使用指南
MQL5 初学者:EA 交易技术指标使用指南
  • 2013.09.04
  • Sergey Pavlov
  • www.mql5.com
为在EA 交易中获得内置或自定义指标的值,首先应使用相应函数创建指标的处理函数。本文中的示例说明了在创建自己的程序时如何使用技术指标。在本文中说明的指标使用 MQL5 语言构建。本文的目标受众是那些在交易策略开发上不具备太多经验的读者,并旨在通过使用提供的函数库提供简单明了的指标使用方式。
 
DxdCn:

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中又说:

  1. "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?