Description
Add 5 Moving Average in one indicator
I think it may save time for 1 indicator with parameter
price , MA type , Line type , Line color.
or you can edit more MA line with same concept of Ribbon moving average.
Hope you will like this and can edit source code that you can apply or change by yourself.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
public class MAmulti : Indicator
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 5)]
public int MAPeriod1 { get; set; }
[Parameter(DefaultValue = 13)]
public int MAPeriod2 { get; set; }
[Parameter(DefaultValue = 50)]
public int MAPeriod3 { get; set; }
[Parameter(DefaultValue = 100)]
public int MAPeriod4 { get; set; }
[Parameter(DefaultValue = 800)]
public int MAPeriod5 { get; set; }
[Output("MA1", Color = Colors.Yellow)]
public IndicatorDataSeries MA1 { get; set; }
[Parameter("MA1 Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType1 { get; set; }
[Output("MA2", Color = Colors.Orange)]
public IndicatorDataSeries MA2 { get; set; }
[Parameter("MA2 Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType2 { get; set; }
[Output("MA3", Color = Colors.GreenYellow)]
public IndicatorDataSeries MA3 { get; set; }
[Parameter("MA3 Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType3 { get; set; }
[Output("MA4", Color = Colors.Tomato)]
public IndicatorDataSeries MA4 { get; set; }
[Parameter("MA4 Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType4 { get; set; }
[Output("MA5", Color = Colors.BlueViolet)]
public IndicatorDataSeries MA5 { get; set; }
[Parameter("MA5 Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType5 { get; set; }
private MovingAverage ma1;
private MovingAverage ma2;
private MovingAverage ma3;
private MovingAverage ma4;
private MovingAverage ma5;
protected override void Initialize()
{
ma1 = Indicators.MovingAverage(Source, MAPeriod1, MAType1);
ma2 = Indicators.MovingAverage(Source, MAPeriod2, MAType2);
ma3 = Indicators.MovingAverage(Source, MAPeriod3, MAType3);
ma4 = Indicators.MovingAverage(Source, MAPeriod4, MAType4);
ma5 = Indicators.MovingAverage(Source, MAPeriod5, MAType5);
}
public override void Calculate(int index)
{
MA1[index] = ma1.Result[index];
MA2[index] = ma2.Result[index];
MA3[index] = ma3.Result[index];
MA4[index] = ma4.Result[index];
MA5[index] = ma5.Result[index];
}
}
}
GO
goldclay
Joined on 27.05.2017
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Multi-MA.algo
- Rating: 0
- Installs: 8
Not found
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.