New cloud function

Created at 12 Feb 2020, 18:52
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!
RO

royj1995

Joined 12.02.2020

New cloud function
12 Feb 2020, 18:52


Hello traders,

One of the new features of the last update is ‘Clouds Between Indicator Lines’.

I’ve been trying to figure out how I could add this function to an indicator, but without any succes (I have no programming skils...).

Is there anyone who already added this function to the Bollinger Bands or Keltner Channels indicator?

If someone is willing to share a code example of how I could add this cloud function to a band indicator that would be really helpful.

Thanks!


@royj1995
Replies

PanagiotisCharalampous
13 Feb 2020, 08:30

Hi royj1995,

See an example using two SMAs 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

royj1995
13 Feb 2020, 10:09

RE:

Thank you! It works!


@royj1995

bewell
11 Apr 2020, 22:05

z index

This is great Panagiotis - thank you.

Can anyone tell me how I can get the cloud behind the candlesticks?

I see a Z index ChartObject but do not know how to insert it into the code above. Basically I just want the candlesticks to be completely in view and thus on top of the cloud indicator.

Thanks in advance, Bewell.


@bewell

PanagiotisCharalampous
13 Apr 2020, 08:53

Hi bewell,

There is no such option at the moment. We will add it in a future release.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

bewell
13 Apr 2020, 20:50

Thanks Panagiotis

I am not a programmer but I thought the Z index would solve this problem by applying it to the 'Cloud' and then tucking it behind the candles. Maybe it can only be used with other 'ChartObjects' and candles do not fall into that category?

 

Anyway, looking forward to the new functionality when it is built. It will be a big improvement to have the candles on top.

 

Cheers, Bewell


@bewell