Colors Indicators

Created at 23 Jan 2016, 22:47
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!
atomrus1993@gmail.com's avatar

atomrus1993@gmail.com

Joined 22.01.2016

Colors Indicators
23 Jan 2016, 22:47


Hello, I am writing an indicator, and there is a need to change the color of the text using the pop-up menu (e-num), but I can not, can you help me? Or suggest another solution, you have to set the color in words.

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{

    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class DrawSpread : Indicator
    {
        Colors spread_c;
        [Parameter("Spread Color", DefaultValue = "White")]
        public string Spread_Color { get; set; }
        public override void Calculate(int index)
        {
            if (IsLastBar)
                DisplaySpreadOnChart();
            Enum.TryParse(Spread_Color, out spread_c);
        }

        private void DisplaySpreadOnChart()
        {
            var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
            string text = string.Format("{0}", spread);
            ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, spread_c);
            ChartObjects.DrawText("spread", "\t" + text, StaticPosition.TopLeft, spread_c);
        }
    }
}

 


@atomrus1993@gmail.com
Replies

Jiri
24 Jan 2016, 02:31

Hi, try this. ;)

Enum.TryParse<Colors>(Spread_Color, out spread_c);

 


@Jiri

atomrus1993@gmail.com
24 Jan 2016, 13:31

RE:

tmc. said:

Hi, try this. ;)

Enum.TryParse(Spread_Color, out spread_c);

 

thx man!

I try this.

Which type of variable should be? I tried IndicatorDataSeries but it was impossible to compile. Could you help me?

        [Parameter("Spread Color", DefaultValue = "White")]
        public string Spread_Color { get; set; }

 


@atomrus1993@gmail.com

Jiri
24 Jan 2016, 13:39

Change line 12 to this:

private Colors spread_c;

 


@Jiri

atomrus1993@gmail.com
24 Jan 2016, 13:48

RE:

tmc. said:

Change line 12 to this:

private Colors spread_c;

 

(( sry man....

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{

    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class DrawSpread : Indicator
    {
        private Colors spread_c;
        [Parameter("Spread Color", DefaultValue = "White")]
        public string Spread_Color { get; set; }
        public override void Calculate(int index)
        {
            if (IsLastBar)
                DisplaySpreadOnChart();
            Enum.TryParse<Colors>(Spread_Color, out spread_c);
        }

        private void DisplaySpreadOnChart()
        {
            var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
            string text = string.Format("{0}", spread);
            ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, spread_c);
            ChartObjects.DrawText("spread", "\t" + text, StaticPosition.TopLeft, spread_c);
        }
    }
}

No change is not present, I still think it is necessary to change the line 14 the variable type. You see, I want to make here is that when you open the property would be an indicator, I can choose the color, for example, in MA, have any ideas? For the second day I fight ...


@atomrus1993@gmail.com

Jiri
24 Jan 2016, 14:07

I don't know what else could be causing problem. Your cAlgo is working for me without any issue. Make sure you are inserting valid colors name. Try to change to "Yellow" for example.


@Jiri

atomrus1993@gmail.com
24 Jan 2016, 14:11 ( Updated at: 21 Dec 2023, 09:20 )

RE:

tmc. said:

I don't know what else could be causing problem. Your cAlgo is working for me without any issue. Make sure you are inserting valid colors name. Try to change to "Yellow" for example.

 

Now he works as a line, that is, in words I am writing color, and whether it is possible to do when selecting I could choose the color?)) As there


@atomrus1993@gmail.com

atomrus1993@gmail.com
24 Jan 2016, 14:12

RE:

tmc. said:

I don't know what else could be causing problem. Your cAlgo is working for me without any issue. Make sure you are inserting valid colors name. Try to change to "Yellow" for example.

Okay, thank you man, I will not touch you and distract, may eventually find a solution.


@atomrus1993@gmail.com

Jiri
24 Jan 2016, 14:25

That works only on outputs. Sample:

[Output("Result", Color = Colors.Green)]
public IndicatorDataSeries Result { get; set; }

 


@Jiri

MaVe
24 Jan 2016, 19:12 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Your original code is just fine:

 


@MaVe

MaVe
24 Jan 2016, 19:22 ( Updated at: 21 Dec 2023, 09:20 )

RE:

You can find the spread on the watchlist too...


@MaVe