A31Trader01: I am trying to make an indicator that can basically add a moving avg of other items than Price.
So as an example, I would like to create a moving average of Volume.
What I have been thinking is to add the iVol data to an array (although I dont know how to do this yet), and then to use iMAOnArray to get the MA.
Is this the correct way of doing this or can someone please point me into the right direction?
Also please point me in the direction on how to add the iVol data to an array then?
You don't need to code that. You can already do that with MetaTrader as it is. You can already add a Moving Average to the Chart's Main Window or one of the Sub-windows and have it based on a previous Indicator data.
Here is an example of adding an EMA to the Volume indicator data:
You don't need to code that. You can already do that with MetaTrader as it is. You can already add a Moving Average to the Chart's Main Window or one of the Sub-windows and have it based on a previous Indicator data.
Here is an example of adding an EMA to the Volume indicator data:
Thank you very much for the reply.
However, I would like to learn how to code it though.
I do not know how Array's work and then how to do calculations like MA on them and even if that is the route to go for doing this.
Can you help with how to go about coding it?
A31Trader01: However, I would like to learn how to code it though.
I do not know how Array's work and then how to do calculations like MA on them and even if that is the route to go for doing this.
Can you help with how to go about coding it?
In the case of volume, you don't need to do anything extra. The parameters passed to the OnCalculate() event handler, already has the volume presented as an array to you.
Also, there is no iVol or iMAOnArray in MQL5. Those are MQL4 functions. Since this is an MQL5 section (the MQL4 section is at the very bottom), either you posted in the wrong section or you need to have a look at the MQL4 to MQL5 differences.
Since, you seem to be quite a beginner coder, I will recommend reading the following books (either the MQL4 or MQL5):
MT4/MQL4 | MT5/MQL5 |
---|---|
Forum on trading, automated trading systems and testing trading strategies Sergey Golubev, 2017.09.16 05:40 Expert Advisor Programming for MetaTrader 4 This book will teach you the following concepts:
All of the source code in this book is available for download, including an expert advisor framework that allows you to build robust and fully-featured expert advisors with minimal effort. | Forum on trading, automated trading systems and testing trading strategies Sergey Golubev, 2017.09.16 05:48 Expert Advisor Programming for MetaTrader 5 This book will teach you the following concepts:
Whether you’re an experienced programmer moving from MQL4, or a novice just starting with MQL5, this book will give you the foundation to quickly program fully-featured and robust trading systems. |
In the case of volume, you don't need to do anything extra. The parameters passed to the OnCalculate() event handler, already has the volume presented as an array to you.
Also, there is no iVol or iMAOnArray in MQL5. Those are MQL4 functions. Since this is an MQL5 section (the MQL4 section is at the very bottom), either you posted in the wrong section or you need to have a look at the MQL4 to MQL5 differences.
Since, you seem to be quite a beginner coder, I will recommend reading the following books (either the MQL4 or MQL5):
MT4/MQL4 | MT5/MQL5 |
---|---|
Ok thank you very much.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to make an indicator that can basically add a moving avg of other items than Price.
So as an example, I would like to create a moving average of Volume.
What I have been thinking is to add the iVol data to an array (although I dont know how to do this yet), and then to use iMAOnArray to get the MA.
Is this the correct way of doing this or can someone please point me into the right direction?
Also please point me in the direction on how to add the iVol data to an array then?
Thank you very much for the advice and help.
Kind Regards