EMA Period: only whole-number possible?

Created at 13 Sep 2015, 13:41
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!
MaVe's avatar

MaVe

Joined 24.08.2015

EMA Period: only whole-number possible?
13 Sep 2015, 13:41


Is there a method to code the value of the EMA with digits after the decimal point?
Example: EMA 123.456 ?


@MaVe
Replies

Spotware
14 Sep 2015, 08:26

Dear Trader,

We are not sure we understand what you are trying to do.

You cannot change the values calculated in the EMA indicator. However you could add them to an IndicatorDataSeries and add/subtract/roundup the values you like.

The following code snippet illustrates it:

        private ExponentialMovingAverage ema;
        protected override void Initialize()
        {
            ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, 50);
        }
        public override void Calculate(int index)
        {
            // Display the ema result on the chart
            Result[index] = ema.Result[index] + 1;
        }

We hope this helps you.


@Spotware

MaVe
14 Sep 2015, 21:13

RE:

Spotware said:

Dear Trader,

We are not sure we understand what you are trying to do.

You cannot change the values calculated in the EMA indicator. However you could add them to an IndicatorDataSeries and add/subtract/roundup the values you like.

The following code snippet illustrates it:

        private ExponentialMovingAverage ema;
        protected override void Initialize()
        {
            ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, 50);
        }
        public override void Calculate(int index)
        {
            // Display the ema result on the chart
            Result[index] = ema.Result[index] + 1;
        }

We hope this helps you.

Dear Spotware,

I meant the EMA Period as a number with digits after the decimal point.

Example beneath with EMA(20) indicator, how to adapt to EMA(20.123)?

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MaVe2015 : Indicator
    {
        [Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MaType { get; set; }
// -----              
        [Output("EMA(20)", Color = Colors.White)]
        public IndicatorDataSeries MA20Result { get; set; }
// -----        
        MovingAverage MA20;
// ------------------------------------------------------         
        protected override void Initialize()
        {
            MA20 = Indicators.MovingAverage(MarketSeries.Close, 20, MaType);
        }
// ------------------------------------------------------ 
        public override void Calculate(int index)
        {
            MA20Result[index] = MA20.Result[index];
        }
    }
}

 


@MaVe

Rod_Sands
15 Sep 2015, 05:32

LOL   why not go to 10 decimal places, say an EMA of 20.0000000003.

Decimal places on an EMA would be about as useful as a hip pocket on a singlet.

Brings a new meaning to useless scope creep.

 


@Rod_Sands

Spotware
15 Sep 2015, 06:27

Dear MaVe,

The periods parameter of the EMA indicator is an integer. You cannot use decimals. 


@Spotware

MaVe
15 Sep 2015, 09:03

Dear Spotware,

Thank you for the objective response.

MaVe

(Under certain circumstances, for visual testing reasons, decimals on an EMA would be usefull)


@MaVe