Description
This indicator showing price average and price intrinsic level without smoothing methods.
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 mDynamicRS : Indicator
{
[Parameter("Periods (200)", DefaultValue = 200)]
public int inpPeriods { get; set; }
[Output("DRS", LineColor = "Black", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outDynamicRS { get; set; }
[Output("DRS Bullish", LineColor = "Green", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries outDynamicRSBullish { get; set; }
[Output("DRS Bearish", LineColor = "Red", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries outDynamicRSBearish { get; set; }
private IndicatorDataSeries _drs;
protected override void Initialize()
{
_drs = CreateDataSeries();
}
public override void Calculate(int i)
{
if (i <= inpPeriods)
{
outDynamicRS[i] = _drs[i] = Bars.TypicalPrices[i];
return;
}
_drs[i] = Bars.TypicalPrices[i];
if (Bars.HighPrices[i] < Bars.HighPrices[i - 1] && Bars.HighPrices[i] < Bars.HighPrices[i - inpPeriods] && Bars.HighPrices[i] < _drs[i - 1])
{
_drs[i] = Bars.HighPrices[i];
outDynamicRSBearish[i] = Bars.HighPrices[i];
}
else if (Bars.LowPrices[i] > Bars.LowPrices[i - 1] && Bars.LowPrices[i] > Bars.LowPrices[i - inpPeriods] && Bars.LowPrices[i] > _drs[i - 1])
{
_drs[i] = Bars.LowPrices[i];
outDynamicRSBullish[i] = Bars.LowPrices[i];
}
else
{
_drs[i] = _drs[i - 1];
if (_drs[i - 1] == outDynamicRSBullish[i - 1])
outDynamicRSBullish[i] = _drs[i - 1];
else if (_drs[i - 1] == outDynamicRSBearish[i - 1])
outDynamicRSBearish[i] = _drs[i - 1];
}
outDynamicRS[i] = _drs[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mDynamicRS.algo
- Rating: 5
- Installs: 959
- Modified: 13/09/2022 19:52
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.
I like it, very interesting project, thanks for sharing.
KAPTV 60 60 ++++ **
% % ++ % ++++