Moving Average changing color as candle change ?

Created at 04 Mar 2019
fernandopaivabr's avatar

fernandopaivabr

Joined 04.03.2019

Status

Open


Budget

10.00 USD


Payment Method

Direct Payment

Job Description

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

        [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


        }



    }


}

 

Comments
Log in to add a comment.
dolandjosama34's avatar
dolandjosama34 · 1 year ago

РАЗРАБОТКА ТОРГОВОГО ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ
Здравствуйте, мне будет приятно с вами работать, я разработчик платформ MT5/MT4, cTrade, Trading View. давайте обсудим ваш проект.

2bnnp's avatar
2bnnp · 5 years ago

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

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

Both are working.

2bnnp's avatar
2bnnp · 5 years 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.