10 USD

Moving Average changing color as candle change ?

Payment method:  Direct Payment Job posted on 04 Mar 2019, 16:54
fernandopaivabrsince: 04 Mar 2019

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.

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

        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





2bnnpsince: 04 Mar 2019
70 days ago

Cant insert code here, so take this pastebin: https://pastebin.com/1wAHWu7q

This should get you an overall idea of how you can solve this, i could not test this since i'm currently on mobile.

2bnnpsince: 04 Mar 2019
70 days ago

MA Rising = Green, Falling = Red: https://pastebin.com/PQUrVWnQ

Candle Up = Green, Down = Red: https://pastebin.com/VysPPzXj

Both are working.