Is there a MA with range band indicator?
Is there a MA with range band indicator?
26 Mar 2022, 11:51
I use an indicator on trading view that allows you to input an exponential moving average and specify the number of pipettes that you want the bands to show. It looks similar to a bollinger band except the bands are a fixed distance.
Does anyone know if something like this exists for cTrader?
Example: 1 sec chart, 5 EMA, bands set to 10 pipettes (1 pip)
Replies
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
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
amusleh
31 Mar 2022, 09:49
Hi,
You can remove the cloud attribute:
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)]
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;
}
}
}
@amusleh
amusleh
28 Mar 2022, 10:25
Hi,
You can use this:
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).
@amusleh