Topics
13 Apr 2022, 01:04
 8
 2192
 4
Replies

ctid4945876
30 Mar 2022, 23:03

RE:

Good day,

I was wondering if there is something I can change in the code so I only get the lines of the bands and not the color background? It is discoloring my candles and making it hard to analyze.

 

 

amusleh said:

Hi,

You can use this:

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), Cloud("Top", "Bottom")]
    public class Bands : Indicator
    {
        [Parameter("Distance (Pips)", DefaultValue = 10)]
        public double Distance { get; set; }

        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

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

        protected override void Initialize()
        {
            Distance *= Symbol.PipSize;
        }

        public override void Calculate(int index)
        {
            Top[index] = Source[index] + Distance;
            Bottom[index] = Source[index] - Distance;
        }
    }
}

First attach the EMA indicator or any indicator you want to use as source/input, then attach the Bands indicator and set the source to your indicator (EMA).

 


@ctid4945876

ctid4945876
28 Mar 2022, 22:40

RE:

Thank you very much! :)

 

amusleh said:

Hi,

You can use this:

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), Cloud("Top", "Bottom")]
    public class Bands : Indicator
    {
        [Parameter("Distance (Pips)", DefaultValue = 10)]
        public double Distance { get; set; }

        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

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

        protected override void Initialize()
        {
            Distance *= Symbol.PipSize;
        }

        public override void Calculate(int index)
        {
            Top[index] = Source[index] + Distance;
            Bottom[index] = Source[index] - Distance;
        }
    }
}

First attach the EMA indicator or any indicator you want to use as source/input, then attach the Bands indicator and set the source to your indicator (EMA).

 


@ctid4945876