How to use DEMA

Created at 19 Mar 2018, 18:29
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!
_I

_internet

Joined 19.03.2018

How to use DEMA
19 Mar 2018, 18:29


Hi, 

Can anyone how I can integrate the DEMA indicator (code shown below taken from cAlgo indicator examples) seamlessly into my strategy rules? I've just tried to paste it as it is into the current strategy rules and it comes up with the error "{ expected", or "A namespace cannot directly contain members such as fields or methods". Help much appreciated.

Regards

 

using System;

using cAlgo.API;

using cAlgo.API.Indicators;

 

namespace cAlgo.Indicators

{

[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]

public class DEMA : Indicator

{

[Parameter()]

public DataSeries DataSource { get; set; }

 

[Output("DEMA", Color = Colors.Yellow)]

public IndicatorDataSeries dema { get; set; }

 

[Parameter(DefaultValue = 14)]

public int Period { get; set; }

 

private ExponentialMovingAverage ema;

private ExponentialMovingAverage ema2;

 

protected override void Initialize()

{

ema = Indicators.ExponentialMovingAverage(DataSource, Period);

//i need the correct DataSeries

ema2 = Indicators.ExponentialMovingAverage(ema.Result, Period);

}

 

public override void Calculate(int index)

{

dema[index] = (2 * ema.Result[index] - ema2.Result[index]);

}

}

}


@_internet
Replies

PanagiotisCharalampous
20 Mar 2018, 09:29

Hi cianwyinne,

Thamks for posting in our forum. Here is a guide on how to use custom indicators in your cBots. Let me know if it is helpful.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous