Hull MA script color change

Created at 10 Feb 2019, 21:22
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

Hull MA script color change
10 Feb 2019, 21:22


Could someone help me edit this script to plot green when its curved up and red when its curved down?

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class HullMovingAverage:Indicator
    {
        private WeightedMovingAverage _wma;
        private WeightedMovingAverage _wma2;
        private WeightedMovingAverage _wma3;
        private IndicatorDataSeries _iSeries;

        [Parameter]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 20, MinValue = 1)]
        public int Period { get; set; }


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

        protected override void Initialize()
        {
            //wma(2*wma(close,period/2)-wma(close,period), sqrt(Period))
            _iSeries = CreateDataSeries();

            _wma = Indicators.WeightedMovingAverage(Source, Period / 2);
            _wma2 = Indicators.WeightedMovingAverage(Source, Period);
            _wma3 = Indicators.WeightedMovingAverage(_iSeries, (int) Math.Sqrt(Period));
        }
        public override void Calculate(int index)
        {
            double price = Source[index];

            if (index < Period)
            {
                Result[index] = price;
                return;
            }

            _iSeries[index] = 2 * _wma.Result[index] - _wma2.Result[index];
            Result[index] = _wma3.Result[index];

        }


    }
}


@alex_mihail
Replies

PanagiotisCharalampous
11 Feb 2019, 10:45

Hi Alex,

If you mean that the indicator line should change color based on direction, then this is not possible at the moment.

Best Regards,

Panagiotis


@PanagiotisCharalampous

Anka Software
03 Jun 2020, 00:34

RE:

PanagiotisCharalampous said:

Hi Alex,

If you mean that the indicator line should change color based on direction, then this is not possible at the moment.

Best Regards,

Panagiotis

Hi Panagiotis,

     Any update on this in version 3.7??

Regards

Vivek


@Anka Software

PanagiotisCharalampous
03 Jun 2020, 08:41

Hi Vivek,

You can check this thread, it might be helpful for you.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

... Deleted by UFO ...