what is the syntax for Cloud parameters

Created at 06 Feb 2020, 12:30
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!
HY

Hyperion

Joined 12.09.2013

what is the syntax for Cloud parameters
06 Feb 2020, 12:30


Hi, how to set the custom parameters - Opacity and FirstColor, SecondColor in the new Cloud feature?

[Cloud("Fast MA", "Slow MA")] - I tried putting those parameters inside the parenthesis or outside of it, but it doesn't seem to work, and I don't see any examples in API Reference Explorer panel.


@Hyperion
Replies

PanagiotisCharalampous
06 Feb 2020, 12:35

Hi Tengu,

See an example below

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

namespace cAlgo
{
    [Cloud("Fast MA", "Slow MA", FirstColor = "Aqua", Opacity = 0.5, SecondColor = "Red")]
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CloudExample : Indicator
    {
        [Parameter("Fast MA Period", DefaultValue = 21)]
        public int FastMaPeriod { get; set; }

        [Parameter("Slow MA Period", DefaultValue = 50)]
        public int SlowMaPeriod { get; set; }

        [Output("Fast MA", LineColor = "#FF6666")]
        public IndicatorDataSeries FastMaResult { get; set; }

        [Output("Slow MA", LineColor = "#0071C1")]
        public IndicatorDataSeries SlowMaResult { get; set; }

        SimpleMovingAverage FastMa;
        SimpleMovingAverage SlowMa;


        protected override void Initialize()
        {
            FastMa = Indicators.SimpleMovingAverage(Bars.ClosePrices, FastMaPeriod);
            SlowMa = Indicators.SimpleMovingAverage(Bars.ClosePrices, SlowMaPeriod);
        }

        public override void Calculate(int index)
        {
            FastMaResult[index] = FastMa.Result[index];
            SlowMaResult[index] = SlowMa.Result[index];
        }
    }
}

 

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

Hyperion
06 Feb 2020, 13:50

RE:

Thanks a lot.


@Hyperion

firemyst
23 Feb 2020, 15:31

RE:

PanagiotisCharalampous said:

Hi Tengu,

See an example below

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

namespace cAlgo
{
    [Cloud("Fast MA", "Slow MA", FirstColor = "Aqua", Opacity = 0.5, SecondColor = "Red")]
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CloudExample : Indicator
    {
        [Parameter("Fast MA Period", DefaultValue = 21)]
        public int FastMaPeriod { get; set; }

        [Parameter("Slow MA Period", DefaultValue = 50)]
        public int SlowMaPeriod { get; set; }

        [Output("Fast MA", LineColor = "#FF6666")]
        public IndicatorDataSeries FastMaResult { get; set; }

        [Output("Slow MA", LineColor = "#0071C1")]
        public IndicatorDataSeries SlowMaResult { get; set; }

        SimpleMovingAverage FastMa;
        SimpleMovingAverage SlowMa;


        protected override void Initialize()
        {
            FastMa = Indicators.SimpleMovingAverage(Bars.ClosePrices, FastMaPeriod);
            SlowMa = Indicators.SimpleMovingAverage(Bars.ClosePrices, SlowMaPeriod);
        }

        public override void Calculate(int index)
        {
            FastMaResult[index] = FastMa.Result[index];
            SlowMaResult[index] = SlowMa.Result[index];
        }
    }
}

 

Best Regards,

Panagiotis 

Join us on Telegram

 

HI @Panagiotis:

A few questions from this:

1) how do we draw clouds between multiple lines within an indicator? For example, imagine an indicator on a price chart that draws horizontal lines at 1, 2, 3, and 4. All 4 lines are different colors. I want one cloud drawn between lines 1 & 2; another cloud drawn between lines 2 & 3; a third cloud drawn between lines 3 & 4. Is this possible?

2) If the above is possible, how can we programmatically change the colors of the clouds or give users the ability to select the colors they want the clouds to be?

Thank you.

 


@firemyst

PanagiotisCharalampous
24 Feb 2020, 09:12

Hi firemyst,

1) Just add more Cloud attributes e.g. 

    [Cloud("Fast MA", "Slow MA", FirstColor = "Aqua", Opacity = 0.5, SecondColor = "Red")]
    [Cloud("Slow MA", "Super Slow MA", FirstColor = "Green", Opacity = 0.5, SecondColor = "Blue")]
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

2) There is no such option at the moment.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous