Description
DonChain Percentage oscillator displays a relative price position inside the Donchian channel as oscillator.
Remark, indicator above or below level 50 for sentiment zone.
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Levels(0, 50, 100)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mDonChainProcent : Indicator
{
[Parameter("Periods (20)", DefaultValue = 20)]
public int inpPeriods { get; set; }
[Output("DonChain Procent", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outDonChainProcent { get; set; }
private DonchianChannel _donchainchannel;
private IndicatorDataSeries _top, _bottom, _dcprocent;
protected override void Initialize()
{
_donchainchannel = Indicators.DonchianChannel(inpPeriods);
_top = CreateDataSeries();
_bottom = CreateDataSeries();
_dcprocent = CreateDataSeries();
}
public override void Calculate(int i)
{
_top[i] = i>inpPeriods ? _donchainchannel.Top.Maximum(inpPeriods) : _donchainchannel.Top[i];
_bottom[i] = i>inpPeriods ? _donchainchannel.Bottom.Minimum(inpPeriods) : _donchainchannel.Bottom[i];
_dcprocent[i] = ((Bars.ClosePrices[i] - _bottom[i]) / (_top[i] - _bottom[i])) * 100.0;
outDonChainProcent[i] = _dcprocent[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mDonChainProcent.algo
- Rating: 5
- Installs: 676
- Modified: 16/01/2023 23:56
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.
Re: pizza tower
I'm learning about DonChian