Description
This is a band indicator based on various moving averages with its upper and lower band placed at a fixed distance expressed in pips.
It does not compensate for trend strength or volatility.
It works best on the temporary fair value as underlying data source.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true)]
public class FixedOffsetBands : Indicator
{
private MovingAverage _ma;
[Parameter()]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 12)]
public int MaPeriod { get; set; }
[Parameter(DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MAType { get; set; }
[Parameter(DefaultValue = 23)]
public double PipDistance { get; set; }
[Output("Center", PlotType = PlotType.Line, Color = Colors.Yellow)]
public IndicatorDataSeries Center { get; set; }
[Output("Upper", PlotType = PlotType.Line, Color = Colors.Yellow)]
public IndicatorDataSeries Upper { get; set; }
[Output("Lower", PlotType = PlotType.Line, Color = Colors.Yellow)]
public IndicatorDataSeries Lower { get; set; }
protected override void Initialize()
{
_ma = Indicators.MovingAverage(Source, MaPeriod, MAType);
}
public override void Calculate(int index)
{
if (index > MaPeriod)
{
Center[index] = _ma.Result[index];
Upper[index] = _ma.Result[index] + (PipDistance * Symbol.PipSize);
Lower[index] = _ma.Result[index] - (PipDistance * Symbol.PipSize);
}
}
}
}
96
9600302
Joined on 19.03.2015
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Fixed Offset Bands.algo
- Rating: 0
- Installs: 2718
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.