Description
Responding to forum request: https://ctrader.com/forum/indicator-support/24951
This shows only a certain number of bars of the moving average.
Let us know if you find any bugs.
If you need some dev work, you can contact us via development@fxtradersystems.com or via fxtradersystems.com/support/
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 MovingAverageRemove : Indicator
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("Periods for MA", DefaultValue = 10, MinValue = 1)]
public int Periods { get; set; }
[Parameter("Periods Shown", DefaultValue = 55, MinValue = 1)]
public int PeriodsShown { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MAType { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
private MovingAverage movingAverage;
protected override void Initialize()
{
movingAverage = Indicators.MovingAverage(Source, Periods, MAType);
}
public override void Calculate(int index)
{
if (index <= PeriodsShown)
{
Result[index] = movingAverage.Result[index];
return;
}
else
{
Result[index] = movingAverage.Result[index];
Result[0] = double.NaN;
Result[index - PeriodsShown] = double.NaN;
}
}
}
}
fxtradersystems
Joined on 10.09.2020
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: MovingAverageRemove.algo
- Rating: 0
- Installs: 1172
- 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.