How to get "typical" marketseries price from MA?

Created at 13 May 2016, 00:09
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!
GD

GDPR-24_203122

Joined 02.10.2015 Blocked

How to get "typical" marketseries price from MA?
13 May 2016, 00:09


Heya :)

 

I have a Moving Average problem:

I would like to get the "close" -marketseries price for the slowMA and "typical" -marketseries price for the fastMA. 

Typical price is calculated: (High + Low + Close)/3

 

How to go about doing that? Do I need two different MA indicators? If so, how to link the typical-MA to the bot?

Thaks for your help!!


Replies

galafrin
13 May 2016, 21:44

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class SampleSMA : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Turquoise)]
        public IndicatorDataSeries Result { get; set; }

        double sum = 0 ;
        

public override void Calculate(int index)
        {

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i]  ) / 3.0 ;
            }
            Result[index] = sum / Periods;
        }
    }
}


@galafrin

galafrin
13 May 2016, 21:44

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class SampleSMA : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Turquoise)]
        public IndicatorDataSeries Result { get; set; }

        double sum = 0 ;
        

public override void Calculate(int index)
        {

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i]  ) / 3.0 ;
            }
            Result[index] = sum / Periods;
        }
    }
}


@galafrin

GDPR-24_203122
14 May 2016, 11:54

RE:

galafrin said:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class SampleSMA : Indicator
    {
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Turquoise)]
        public IndicatorDataSeries Result { get; set; }

        double sum = 0 ;
        

public override void Calculate(int index)
        {

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i]  ) / 3.0 ;
            }
            Result[index] = sum / Periods;
        }
    }
}

Hello there and thak's a lot for the answer :)