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
Nikolay, thank you. It's a great tutorial!
But I think that variable
const int begin
will always be zero valued, in the code. Is it significant for calculation?
Nikolay, thank you. It's a great tutorial!
But I think that variable
will always be zero valued, in the code. Is it significant for calculation?
The value of "begin" will be different depending on what indicator applied to. If you apply to RSI, "begin" will be 14, for example.
If you try to compile for the first time, you may get buffer error. So please change the amount of buffers:
Later on, you can switch back to 1 (one) buffer:
#property indicator_buffers 1
- 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