OHLC4 as Hull MA source

Created at 27 Sep 2019, 15: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!
AL

alex_mihail

Joined 09.08.2018

OHLC4 as Hull MA source
27 Sep 2019, 15:29


Could someone talk me through if this is possible or not? I have a Hull MA & OHLC4 source indicator here but not sure how to get both of them working together.


@alex_mihail
Replies

PanagiotisCharalampous
27 Sep 2019, 15:30

Hi alex_mihail,

Can you explain what do you mean when you say "get both of them working together"?

Best Regards,

Panagiotis


@PanagiotisCharalampous

alex_mihail
27 Sep 2019, 16:09

RE:

Panagiotis Charalampous said:

Hi alex_mihail,

Can you explain what do you mean when you say "get both of them working together"?

Best Regards,

Panagiotis

Yes - on TradingView I can choose OHLC4 as the source of my Hull Moving Average - I'm not seeing this option on cTrader.


@alex_mihail

PanagiotisCharalampous
27 Sep 2019, 16:17

Hi alex_mihail,

Do you have an OHLC indicator for cTrader? If yes, does it have an output series for the results? If yes, then you can feed the results to a Hull MA.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alex_mihail
27 Sep 2019, 22:37

RE:

Panagiotis Charalampous said:

Hi alex_mihail,

Do you have an OHLC indicator for cTrader? If yes, does it have an output series for the results? If yes, then you can feed the results to a Hull MA.

Best Regards,

Panagiotis

 

Thanks I've found it! Is there any way to change the color of the Hull MA line to Green when it's moving up and Red when it's moving down?


@alex_mihail

PanagiotisCharalampous
30 Sep 2019, 08:23

Hi alex_mihail,

To achieve this you need to have two output series with DiscontinuousLine type, one for uptrending values and one for downtrending values. When the MA is on a downtrend put the value in the downtrend output series and vice versa for the uptrend. See an example below for a simple moving average

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

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

        [Parameter(DefaultValue = 50)]
        public double Level { get; set; }

        [Output("Up", PlotType = PlotType.DiscontinuousLine, LineColor = "Green")]
        public IndicatorDataSeries Up { get; set; }

        [Output("Down", PlotType = PlotType.DiscontinuousLine, LineColor = "Red")]
        public IndicatorDataSeries Down { get; set; }


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

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            if (_sma.Result.IsRising())
            {
                Up[index - 1] = _sma.Result[index - 1];
                Up[index] = _sma.Result[index];
            }
            else
            {
                Down[index - 1] = _sma.Result[index - 1];
                Down[index] = _sma.Result[index];
            }
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

alex_mihail
30 Sep 2019, 16:55

RE:

Thanks Panagiotis! Does this work differently for indicators like ADX line?


@alex_mihail

PanagiotisCharalampous
30 Sep 2019, 16:57

Hi alex_mihail,

No it should be the same principle everywhere.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alex_mihail
30 Sep 2019, 17:19

RE:

Panagiotis Charalampous said:

Hi alex_mihail,

No it should be the same principle everywhere.

Best Regards,

Panagiotis

Thanks for your help, got it working.

Is there no option to move indicators above the chart in cTrader?


@alex_mihail