double EMAl(double aPrevEMA, double aValue, double anLength){ return EMAa( aPrevEMA, aValue, 2.0 / (anLength + 1.0) ); } double EMAa(double aPrevEMA, double aValue, double aAlpha){ return aPrevEMA + aAlpha * (aValue - aPrevEMA); }Remember it take 3.45 × Length values before you have a valid EMA
You can't do it with a variable. You need to calculate all differences for all bars so you can compute the EMA(i) from EMA(i+1) and the difference(i)
Remember it take 3.45 × Length values before you have a valid EMA
@William Roeder
What do the variables mean?
For the calculation of EMA1:
- aPrevEMA (is this for the first calculation 0?)
- aValue(is this the MACDline?)
- anLength(is this the length of the EMA? so in case for a standard macdsignal line it should be a 9?)
For the calculation of the EMAa:
- aPrevEMA (is this for the first calculation 0?)
- aValue (is this the MACDline?)
- aAlpha(is this the weighted multiplier?)
For as far I understand, I do not need any extra code except for the MACDline calulation to let this work?
I hope that you can help me with these questions, thanks in advance!
Do not double post!
I have deleted your duplicated topic.
Do not double post!
I have deleted your duplicated topic.
Why? Thats a whole other topic on how to calculate an ema...
It was not a whole other topic.
It was a development of the same code.

- 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 a EA that needs a standard MACD, not the one that is available with the iMACD function.
I know that the MACD line is made by subtracting the 26EMA from the 12EMA, this can be easily done with the iMA function. But after that there needs to be a EMA made out of the MACD line. But to get there I simply get lost...
How do I code the MACD signal line out of the MACD line?
Calculation for the MACD and a standard EMA are in the attached files.
My code so far (I know it is basicaly nothing for the MACD signal line...):