Last close less SMA

Created at 20 Jul 2013, 17:44
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!
CH

Chris

Joined 22.12.2011

Last close less SMA
20 Jul 2013, 17:44


Dear all,

I'm trying to create a Indicator that show the difference between the last close and the moving average.

CLOSE-SMA

Can someone help me thru this ?

 

Thank you in avance.

Chris


@Chris
Replies

Kate
21 Jul 2013, 10:45

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false)]
    public class CloseLessSma : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }
        
         private MovingAverage sma;

        protected override void Initialize()
        {
            sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Period);
        }

        public override void Calculate(int index)
        {
            Result[index] = MarketSeries.Close[index] - sma.Result[index];
        }
    }
}

 


@Kate

Chris
21 Jul 2013, 23:17

Merci beaucoup Kate c'est super sympa !!!

Bonne soirée.


@Chris

Chris
21 Jul 2013, 23:20

RE:

Sorry, I wrote in french. 

Thank you very much Kate !!!


@Chris