Moving Average changing color as candle change ?

Created at 04 Mar 2019, 22:02
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!
fernandopaivabr's avatar

fernandopaivabr

Joined 04.03.2019

Moving Average changing color as candle change ?
04 Mar 2019, 22:02


I am trying to create an indicator using Moving Average(MA) where it will change color as candle change showing a possible tendance. 

Example: If candle is green(buy) it will change color to green and if candle is red it will change for red. 

Note, in the picture below I am using a MA that change color as the candle changes. In the picture the MA is Blue for Buy and Red for Sell.

I don't know how to Calculate to change colors of MA. How could I to create it, any help ?

 

My code as far

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 Tabajara : Indicator
    {

        private MovingAverage MA { get; set; }

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

        [Parameter("MA Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Default", LineColor = "#6E6E6E")]//default
        public IndicatorDataSeries Result { get; set; }

        [Output("Buy", LineColor = "#3ADF00")]//green
        public IndicatorDataSeries ResultBuy { get; set; }

        [Output("Sell", LineColor = "#FF0000")]//red
        public IndicatorDataSeries ResultSell { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MaType { get; set; }

        
        protected override void Initialize()
        {
            MA = Indicators.MovingAverage(Source, Periods, MaType);

        }

        public override void Calculate(int index)
        {
            //MA default
            Result[index] = MA.Result[index];


            //MA buy green


            //MA sell red


        }



    }


}

 


@fernandopaivabr
Replies

jumpycalm
28 Mar 2019, 23:14

[Output("Sell", LineColor = "#FF0000")]//red

Can be replaced with:

[Output("Sell", LineColor = "Red")]


@jumpycalm