Description
Simple indicator which identifies trends based on a comparison of the MA value of close - MA value of high and the MA value of low - MA value of close.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class HLCTrend : Indicator
{
[Parameter("Close Period", DefaultValue = 5, MinValue = 1)]
public int ClosePeriod { get; set; }
[Parameter("High Period", DefaultValue = 30, MinValue = 1)]
public int HighPeriod { get; set; }
[Parameter("Low Period", DefaultValue = 13, MinValue = 1)]
public int LowPeriod { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MaType { get; set; }
[Output("Close High MA", LineColor = "Green", Thickness = 2)]
public IndicatorDataSeries CH { get; set; }
[Output("Low Close MA", LineColor = "Red", Thickness = 2)]
public IndicatorDataSeries LC { get; set; }
private MovingAverage maClose, maHigh, maLow;
protected override void Initialize()
{
maClose = Indicators.MovingAverage(Bars.ClosePrices, ClosePeriod, MaType);
maHigh = Indicators.MovingAverage(Bars.HighPrices, HighPeriod, MaType);
maLow = Indicators.MovingAverage(Bars.LowPrices, LowPeriod, MaType);
}
public override void Calculate(int index)
{
CH[index] = maClose.Result[index] - maHigh.Result[index];
LC[index] = maLow.Result[index] - maClose.Result[index];
}
}
}
CW
cW22Trader
Joined on 16.03.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: HLC Trend.algo
- Rating: 0
- Installs: 1337
- 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.