- How to bring Previous indicator data from moving average indicator to EA?
- difference between offset and index
- help for simple code
I found the official CopyBuffer() documentation but I do not understand exactly how to use it.
https://www.mql5.com/en/docs/series/copybuffer
So my buffer[0] is in real time when OnTick() and buffer[1] is the previous moment?"starting position is performed from the present to the past"
But my code does not seem to work very well, I just do not understand what I'm doing wrong.
Thank you.

- www.mql5.com
copy to an target array;
double buffer[] // target array to copy
Call by the first position and the number of required elements
int CopyBuffer( |
Call by the start date and the number of required elements
int CopyBuffer( |
Call by the start and end dates of a required time interval
int CopyBuffer( |
But my code does not seem to work very well, I just do not understand what I'm doing wrong.
You need to set the Array series direction to true.
...just a friendly tip... the MQL standard library is what you should first look to for some pretty cool and time saving code. Here is an example of what you need using the CiMA class.
#property indicator_chart_window #include <Indicators\Trend.mqh> CiMA g_ma55; int OnInit() { if(!g_ma55.Create(_Symbol,_Period,55,0,MODE_SMA,PRICE_CLOSE)) return INIT_FAILED; g_ma55.Redrawer(true); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { g_ma55.Refresh(); printf("Current = %f, Previous = %f",g_ma55.Main(0),g_ma55.Main(1)); return(rates_total); }
You need to set the Array series direction to true.
...just a friendly tip... the MQL standard library is what you should first look to for some pretty cool and time saving code. Here is an example of what you need using the CiMA class.
Ok very, very, thanks Nicholishen.
Your post is very intersting.
For the use OOP I'm reading this:
https://www.mql5.com/en/articles/100
https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpert
In fact, after these tests I thought I would better study the standard library and the CExpert base class.
I understand that CExpert can be derived by creating a new class in which, by implementing virtual methods, you get an EA complete with indicators, money manager and methods for order execution according to the logic that we can implement.
Are there any suggestions or articles to follow for those who start?
The official documentation, albeit good, is lacking in my opinion, not have more/sufficient examples.
Fortunately there are you guys: D: D

- www.mql5.com
You need to set the Array series direction to true.
...just a friendly tip... the MQL standard library is what you should first look to for some pretty cool and time saving code. Here is an example of what you need using the CiMA class.
Where is the MQL5 code?
I tried this but i am not getting exact moving average values of any timeframe it displays some random values near to moving average values but not the same moving average value. Can you please tell me how can i get the exact moving average values in specific time frame. Thank you in advance.
Show the code that you are using or nobody can help you.

- 2020.03.05
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use