Hull MA script color change

10 Feb 2019, 21:22Hull MA script color change#1
alex_mihailposts: 24since: 09 Aug 2018

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];

        }


    }
}

11 Feb 2019, 10:45#2
Panagiotis Charalampousposts: 2610since: 13 Jan 2017

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


Head of Community Management at cTrader