Please read the MQL5 documentation on the iMA() function (there is an example) — Documentation on MQL5: Technical Indicators / iMA
There are also examples in the CodeBase. Here is one — Moving average code for beginners by William210
Simply put, you obtain the Indicator's handle in the OnInit() event handler, and then later in the event handlers, you use CopyBuffer to obtain the values.
Hi, this is something i was also stuck on i appreciate your difficulty. This is a simple step by step process i use when creating indicators. This has been applied to iMA() indicator.
Try the following these steps :
1) Create an array
2) Set array as series
3) Define the moving average
4) Copy price info into arrays
5) Return the moving average
double maArray[]; // 1) Create an array
ArraySetAsSeries(maArray,true); // 2) Set array as series
int ma = iMA(_Symbol,_Period,20,0,MODE_SMA,PRICE_CLOSE); // 3) Define the moving average
CopyBuffer(ma,0,0,1,maArray); // 4) Copy price info into arrays
double maValue = maArray[0]; // 5) Return the moving average
We can now use maValue to return our moving average
Also the following articles can help mql4 to mql5 conversions
and
Hope this helps!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I understand that the previous syntax was this
and assuming i want values like this:
how do i exactly key in into the sql5 syntax?
thank you.