Topics
Forum Topics not found
Replies
sktradingfx
15 Dec 2016, 00:03
RE:
tmc. said:
What you mean by the smoothing method? If I am not mistaken ADXR is equal to the last ADX value plus the value N bars ago devided by 2, there isn't used the regular smoothing method known as Moving Average.
Hi tmc.
thanks a lot for your swift reply.
You are right! ADXR is not calculated by applying a MA to the ADX but by smoothing as you said: current ADX + ADX n bars ago / 2.
Could you implement that?
Best
sk
@sktradingfx
sktradingfx
14 Dec 2016, 21:44
RE:
tmc. said:
Hi, Directional Movement System in cTrader platform is using Wilder Smoothing that can't be changed. I have re-built the indicator with an option to choose different smoothing methods. Build the indicator and change MA Type to Exponential, it should match the MT4 results.
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo { [Indicator("DMS", IsOverlay = false, ScalePrecision = 0, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class DirectionalMovementSystem : Indicator { [Parameter("Period", DefaultValue = 14, MinValue = 1)] public int Period { get; set; } [Parameter("MA Type", DefaultValue = MovingAverageType.WilderSmoothing)] public MovingAverageType MaType { get; set; } [Output("ADX", Color = Colors.Cyan)] public IndicatorDataSeries ADX { get; set; } [Output("DI+", Color = Colors.Green)] public IndicatorDataSeries DiPlus { get; set; } [Output("Di-", Color = Colors.Red)] public IndicatorDataSeries DiMinus { get; set; } private DataSeries high, low, close; private IndicatorDataSeries tr, dmPlus, dmMinus, adx; private MovingAverage maTr, maDmPlus, maDmMinus, maAdx; protected override void Initialize() { high = MarketSeries.High; low = MarketSeries.Low; close = MarketSeries.Close; tr = CreateDataSeries(); dmPlus = CreateDataSeries(); dmMinus = CreateDataSeries(); adx = CreateDataSeries(); maTr = Indicators.MovingAverage(tr, Period, MaType); maDmPlus = Indicators.MovingAverage(dmPlus, Period, MaType); maDmMinus = Indicators.MovingAverage(dmMinus, Period, MaType); maAdx = Indicators.MovingAverage(adx, Period, MaType); } public override void Calculate(int index) { if (index == 0) { tr[0] = high[0] - low[0]; dmPlus[0] = 0; dmMinus[0] = 0; } else { tr[index] = Math.Max(Math.Abs(low[index] - close[index - 1]), Math.Max(Math.Abs(high[index] - close[index - 1]), high[index] - low[index])); dmPlus[index] = high[index] - high[index - 1] > low[index - 1] - low[index] ? Math.Max(high[index] - high[index - 1], 0) : 0; dmMinus[index] = low[index - 1] - low[index] > high[index] - high[index - 1] ? Math.Max(low[index - 1] - low[index], 0) : 0; DiPlus[index] = 100 * (maTr.Result[index] == 0 ? 0 : maDmPlus.Result[index] / maTr.Result[index]); DiMinus[index] = 100 * (maTr.Result[index] == 0 ? 0 : maDmMinus.Result[index] / maTr.Result[index]); adx[index] = Math.Abs((DiPlus[index] - DiMinus[index]) / (DiPlus[index] + DiMinus[index])); ADX[index] = adx[index] == 0 ? 50 : 100 * maAdx.Result[index]; } } } }
Hi tmc.
great indicator, highly appreciated!!
Would it be possible to add ADXR (Average Directional Movement Index Rating = smoothed version of ADX) to the indicator and have everything in one window?
If you could code that with the option to choose the smoothing method of the ADXR as well, this would be the deluxe version of the directional movement system.
Many thanks in advance!
sk
@sktradingfx
sktradingfx
15 Dec 2016, 20:59
RE:
tmc.,
you are awesome!!! The indy works perfectly.
Thank you very much!!
I wish you a lot of green pips!
Best
sk
tmc. said:
@sktradingfx