dustovshio:
How would one modify the tutorial to make an ema with a constant .1 instead of the average between high and low? For some strange reason the ema goes straight down 3-4 bars before the last bar. Any idea why?
How would one modify the tutorial to make an ema with a constant .1 instead of the average between high and low? For some strange reason the ema goes straight down 3-4 bars before the last bar. Any idea why?
Update: Ok I think it's because the if the current bar - last bar returns a negative value the while loop continues to average it it to the ema. So I guess the fix is to simply not calculate the last bar until it closes.
DI think that the double ema must be declared outsite of the start() function : when you attach your indic on a chart, it's ok because the previous value of ema is keeped in the loop, but when it's running live, start() is called at each new tick to update only the last bar value, and thus you have to remember the previous value of ema between two start() calls.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
How would one modify the tutorial to make an ema with a constant .1 instead of the average between high and low? For some strange reason the ema goes straight down 3-4 bars before the last bar. Any idea why?
Update: Ok I think it's because the if the current bar - last bar returns a negative value the while loop continues to average it it to the ema. So I guess the fix is to simply not calculate the last bar until it closes.
D