#include <MovingAverages.mqh> //--- input parameters input int UMAPeriod = 9; // UMA period //--- indicator buffers double UMAX_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0, UMAX_Buffer, INDICATOR_DATA); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- ExponentialMAOnBuffer(rates_total, prev_calculated, UMAPeriod, UMAPeriod, UMA_Buffer, UMAX_Buffer); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
I don't know how to get data on UMA_Buffer. Add it by yourself.
Hey, I have only just seen your reply.
Thanks allot!
But the question I have is:
The result of the “ExponentialMAOnBuffer” is placed in "
UMAX_Buffer
But how would I do calculations with the most recent value in this buffer.
So for example:
the most recent calculations of “ExponentialMAOnBuffer” is 20.
How could I then do this,
A = 20 /*UMAX_Buffer*/ + 10
Could I do this?:
input int UMAPeriod = 9; // UMA period
double UMAX_Buffer[], UMA_Buffer[];
ExponentialMAOnBuffer(rates_total,prev_calculated,0,UMAPeriod,UMA_Buffer,UMAX_Bufer);
A = UMAX_Buffer[UMAPeriod-1] +10;
Thanks in advance,
It is very difficult to understand what information you are still trying to get since it seems you have understood how ExponentialMAOnBuffer works. There is a source array and a destination array.
Hey thanks for your reply!
I kind of fell into coding not so long ago, so some parts I understand and some simple parts I still don't know allot about, buffers/ arrays for example.
I think my main question would be:
How can I do calculations with the newest value that is put into "UMAX_Buffer" in this case?
The particular operation I want to do is this:
input int RCRBopenP = 100;ExponentialMAOnBuffer(rates_total, prev_calculated, 0, RCRBopenP, _1Buffer, EMA_1); ExponentialMAOnBuffer(rates_total, prev_calculated, 0, RCRBopenP, _2Buffer, EMA_2);double dif_EMA = EMA_1[(RCRBopenP-1)] - EMA_2[(RCRBopenP-1)]; double RCwd = dif_EMA + UMAX_Buffer[(UMAPeriod-1)];
And EMA_1 / EMA_2 are also buffer outcomes from "ExponentialMAOnBuffer".
But I don't know if my logic is adding up.
But let's say the most recent calculations from EMA_1 are 10, EMA_2 are 5 and UMAX_Buffer is 5
I want it to do:
double dif_EMA = 10 - 5; double RCwd = dif_EMA /*5*/ +5; RCwd -> 10
This is oversimplified, but I hope you get the idea.
Thanks in advance!
ExponentialMAOnBuffer(rates_total, prev_calculated, RCRBopenP, RCRBopenP, _1Buffer, EMA_1);
"Begin" is the bar number at which the calculation begins.
double dif_EMA = EMA_1[rates_total - 1] - EMA_2[rates_total - 1];
The bar number of the latest value is "rates_total - 1"
"Begin" is the bar number at which the calculation begins.
The bar number of the latest value is "rates_total - 1"
Thanks incredibly much, this was such a simple thing I was looking to get an answer to!
Another question, why can't Begin be 0? Wouldn't this mean it would start immediately instead of at bar 100? Or is this done because period should be "= begin" to make sure there are enough bars to begin with?
Again thanks allot,
Alright, you can subtract two buffer values I think MACD is based on that any many more indicators. But they are automated with loops.
Thanks again for your response!
Does the above mentioned response also work?:
[rates_total -1]
Also when looking at:
for(int i=0; i<total; i++) // (runs from 0 to 999) { c[i]=(i * 2) + (i * 3); //This loop adds two values which depend on the running index i and stores them in c[] array. }
Could you please elaborate on why exactly it adds two values? The for() is one of the operators I have been meaning to look into further.
I also have a completely different question I hope you can answer..
We talked about the "ExponentialMAOnBuffer" and the EMA values I am calculating to eventually calculate the values with which will be plotted.
The problem I have now, is that "ExponentialMAOnBuffer" uses rates_total and prev_calculated. But I am calculating these values in an EA which means I don't have OnCalculate() and thus don't have
rates_total and prev_calculated.
I thought about using iCustom() and creating indicators for all the "ExponentialMAOnBuffer" above, but I don't actually have to plot these values I just need their EMA value.
What can I do to get around this problem? I simply need to calculate their EMA's in the EA source code, but this could also be by including a file an calculating them here.
Do you have any workarounds for my problem?
Again thanks allot for all of your help so far, I appreciate it a lot.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey! Thanks for taking some time out of your day to read my question.
So in my script I am calculating a few EMA's. With these EMA values I have to do some further calculations, but how would I do calculations with these values that are stored inside this array (buffer)?
These are the lines code for the UMA -> UMAX_Buffer.
UMA is defined in a different script, but it does have variables. So the Array is Filled it just doesn't show that here.
But how would I do calculations with the latest value from this buffer? Could I do something like this?:
But I think it still isn't possible to do something like this for example:
These might be dumb questions, but I can't figure them out.
Thanks in advance!
Have a great rest of your day