Hello,
how is the first value of the EMA indicator calculated? I am asking because I copied the price data with an EMA plot from the charting to an excel sheet and tried to recalculate the EMA on my own. There are some nulls for the EMA (sure the EMA needs these price data for the initial value) and then the EMA starts with an initial value. After that initial value the EMA calculation works like explained in the wiki.
In addition I use the AdaptiveLookback to calculate dynamic periods for the EMA. Every time the period changed the EMA starts with the initial value again (what I want, but therefore I would like to know the initial calculation).
Thanks.
Size:
Color:
Make sure you read this:
WealthScript Programming Guide > Indicators > Stability of Indicators
Size:
Color:
Hello Eugene.
Thanks for the hint but the initial (first) value can t be a random number!? I know that the indicator needs some time to produce stable values but with the initial (first) value the start-point is set and the calculation can carry on. In the attachment (see Sample) I visualize the issue, too. For me it is just import to know how WL calculates the initial value (or first stable value) of the EMA indicator?
After this initial value (first value) I can recalculate the values with the WL wiki formula of the EMA.
Size:
Color:
It's not a random number: as you could read in
the online manual, a SMA is used for the first period's calculation.
Size:
Color:
Hello Eugene.
Thanks, you are right when I use the standard calculation of the EMA the first value is the SMA value. And after that the EMA calculation form the Wealth-Lab wiki takes place. Now I am using the AdaptiveLookback with the EMA calculation together and that seems to change the first initial value every time the AdaptiveLookback change the parameter (what is supposed to be like that). But even the very first (initial) value is not the standard SMA value. In the attachment you can see the copied price values from WL in Excel (columns A-H) and I can not recalculate the red values in Excel because these red values are not the standard SMA values (columns L-M). After the red values (initial values) the usual EMA calculation takes place again (I already recalculate these values with the Wealth-Lab wiki formula). At the moment for me it is a miracle how the red values could be calculated in the Excel sheet and how Wealth-Lab calculates these values? Maybe the EMA does calculate the initial values differently when it is used with the AdaptiveLookback Indicator in Wealth-Lab but I can’t figure it out – please help!
Here is my code for the EMA calculation with the AdaptiveLookback:
CODE:
Please log in to see this code.
Size:
Color:
Hi Andreas,
By design, the AdaptiveLookback indicator can not have a "fixed initial value". Its FirstValidValue always varies from symbol to symbol, depending on chosen data loading range and indicator's settings.
Make sure you have carefully reread and understood the chapter on Stability of Indicators. You're still focusing on what I believe is insignificant. You can not use EMA or other unstable indicator reliably before 3-4 times its period. The values before that are unstable and should not be considered.
Size:
Color:
Hello Eugene.
Ok, the first values of an EMA can be unstable and it needs some data points until the EMA is stable - I understand this point. But when I calculate/plot just the standard EMA (without the AdaptiveLookback) with Wealth-Lab and have some data points before the first EMA value this first value is the SMA and after that the usual EMA calculation takes place - I could even recalculate this in Excel. Now I have the EMA and the AdaptiveLookback together and I understand that the initial value can be more or less unstable when there is a parameter change in the AdaptiveLookback. But still in this case the first (initial) value of the EMA with the AdaptiveLookback can not be random and have to follow a calculation logic but I can't figure out what Wealth-Lab is calculating at these points (it is not the SMA value and this is confusing for me!)? I attached a jpeg file to make these points clear (yellow circle around these data points). The parameter of the AdaptiveLookback gets higher and the first value of the EMA calculation jumps back (I actually want this behavior but I want to understand the calculation behind this as well). Thanks and I really appreciate your help!
CODE:
Please log in to see this code.
Size:
Color:
Your "adaptive EMA" period is variable (but can not be less than 1), so it's pointless to calculate it in Excel.
Think of it as a continuously variable transmission with a big number of gears. Because it's really similar. When the variable lookback period grows in trending markets (like on your screenshot), the composite indicator "switches gears" in your "transmission" from one precalculated EMA to another precalculated EMA with a different period. There's no "neutral gear", though.
The SMA is used only on for the first period's calculation of an EMA. And EMAs are not re-calculated whenever the AdaptiveLookback changes - just a different precalculated EMA is picked at that moment. Hope this helps.
Size:
Color:
I don't like it, but it's clear that Wealth-Lab's EMA formulation is initialized with the SMA value at the period bar and bars prior to that first value are zero. As you can see by what I think is a proper formulation, allowing the seed bars to remain zero is unnecessary (even if you should ignore them).
CODE:
Please log in to see this code.
Size:
Color: