Description
This is a moving average ribbon which only shows the average, the max and the min value. This way any number of moving averages can be shown without recompiling the code.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Cloud("Max", "Mean", FirstColor = "Lime")]
[Cloud("Mean", "Min", FirstColor = "Crimson")]
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MovingAverageRibbon : Indicator
{
[Parameter("MA Period Start", DefaultValue = 50)]
public int MAPeriodStart { get; set; }
[Parameter("MA Period Step", DefaultValue = 10)]
public int MAPeriodStep { get; set; }
[Parameter("# of MA", DefaultValue = 16, MaxValue = 200)]
public int NumMA { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MaType { get; set; }
[Output("Mean", LineColor = "Gray", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries Mean { get; set; }
[Output("Max", LineColor = "Lime", PlotType = PlotType.Line, LineStyle = LineStyle.DotsRare, Thickness = 1)]
public IndicatorDataSeries Max { get; set; }
[Output("Min", LineColor = "Crimson", PlotType = PlotType.Line, LineStyle = LineStyle.DotsRare, Thickness = 1)]
public IndicatorDataSeries Min { get; set; }
private MovingAverage[] ma;
protected override void Initialize()
{
ma = new MovingAverage[NumMA];
for (int i = 0; i < NumMA; i++)
{
ma[i] = Indicators.MovingAverage(Bars.ClosePrices, MAPeriodStart + i * MAPeriodStep, MaType);
}
}
public override void Calculate(int index)
{
Mean[index] = ma.Average(x => x.Result[index]);
Max[index] = ma.Max(x => x.Result[index]);
Min[index] = ma.Min(x => x.Result[index]);
}
}
}
cW22Trader
Joined on 16.03.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Moving Average Ribbon.algo
- Rating: 5
- Installs: 1450
- Modified: 05/06/2022 14:03
Comments
Proficient web based writing paper for money services ought to ensure the fulfillment of their clients and ought to give free modifications or discounts to inadmissible work. This is an indication that the organization values consumer loyalty and is sure about its capacity to convey quality work.
the most interesting post i read this day! mold removal miami
Utilize an article writer with best professional proofreading services can keep in contact with you all the time the paper is being formed to ensure that everything is working out true to form. You can go to instead of basically any writer that is coordinated with you.
Your hard work and dedication are truly admirable.