Wrong EMA Values

Created at 19 Nov 2015, 19:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TZ

tzoleto8

Joined 24.10.2015

Wrong EMA Values
19 Nov 2015, 19:13


Hey, I am trying to create a function which will be comparing the three last EMA values of 30min diagram and the three last EMA values of 5min diagram

However, in my code when I try to retrieve these values from diagram they are not actually correct and the results I take from the comparison are false.

Any Idea???

private bool LongUpShortDown()
        {
            var slowEMACounter = 0;
            var fastEMACounter = 0;

            var Index30 = series30.Close.Count;

            for (int i = Index30; i > Index30 - 2; i--)
            {
                if (slowEma.Result[i - 1] - slowEma.Result[i] > 0)
                    slowEMACounter++;
            }

            var Index5 = series5.Close.Count;

            for (int i = Index5; i > Index5 - 2; i--)
            {
                if (fastEma.Result[i] - fastEma.Result[i - 1] >= 8E-05)
                    fastEMACounter++;
            }

            return ((fastEMACounter == 2) && (slowEMACounter == 2));
        }

 


@tzoleto8
Replies

Spotware
23 Nov 2015, 02:42

Dear Trader,

We do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You can contact one of our Partners or post a job in Development Jobs section for further coding assistance.


@Spotware