Change line color once it reaches above/below a value

Created at 18 Dec 2020, 06:57
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!
PA

pancakeman

Joined 18.12.2020

Change line color once it reaches above/below a value
18 Dec 2020, 06:57


Hi guys, how do I change the color of the Aroon line once it reaches above 50 and below -50?  I want to create an indicator like the picture shown below.

Please note that I'm not a coder and have no experience in programming language but here's the code I've done so far. Any advice will be much appreciated, thanks!

 

namespace cAlgo.Indicators
{
    [Levels(100, -100)]
    [Indicator(AccessRights = AccessRights.None)]
    public class AroonCombined : Indicator
    {
        private Aroon _aroon;

        [Parameter(DefaultValue = 25)]
        public int Period { get; set; }

        [Output("Combined", PlotType = PlotType.Line)]
        public IndicatorDataSeries Combined { get; set; }



        protected override void Initialize()
        {
            _aroon = Indicators.Aroon(Period);
        }


        public override void Calculate(int index)
        {
            double val = (_aroon.Up[index] + -_aroon.Down[index]);
            Combined[index] = val;

        }

    }


}

 


@pancakeman
Replies

PanagiotisCharalampous
18 Dec 2020, 08:04

Hi pancakeman,

To achieve this you need to use different IndicatorDataSeries outputs for each color and use the DiscontinuousLine plot type. You can find an example here.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

pancakeman
18 Dec 2020, 08:55

RE:

PanagiotisCharalampous said:

Hi pancakeman,

To achieve this you need to use different IndicatorDataSeries outputs for each color and use the DiscontinuousLine plot type. You can find an example here.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis, 

Thank you so much! That solved my problem!

Have a great day sir!

With Appreciation, 

pancakeman


@pancakeman