Previous DMI+ / DMI - value

Questions about MultiCharts .NET and user contributed studies.
lewisthegood
Posts: 21
Joined: 08 Mar 2021
Been thanked: 1 time

Previous DMI+ / DMI - value

Postby lewisthegood » 13 Jun 2021

I am developing a new strategy that require the previous value of DMI+ / DMI- (previous available value). I am using IOG mode in my strategy.

I can only locate simian topic below:
viewtopic.php?t=45332

However, the material mentioned that :
m_dirmovement1 = new DirMovement(this);
previous DMI = dirmovement1.DMIPlus.Value

But this is the current DMI value from my understanding, please kindly advise how to get the previous DMI value from the indicator.

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Previous DMI+ / DMI - value

Postby Kate MultiCharts » 23 Jun 2021

Hello lewisthegood,

Here's an example you can refer to:

Code: Select all

using System.Drawing; using PowerLanguage.Function; namespace PowerLanguage.Indicator { public class DMI : IndicatorObject { private DirMovement m_dirmovement1; private IPlotObject Plot1; private IPlotObject Plot2; private IPlotObject Plot3; private IPlotObject Plot4; private IPlotObject Plot5; public DMI(object ctx): base(ctx) { adxtrend = 25; length = 14; } [Input] public int length { get; set; } [Input] public double adxtrend { get; set; } protected override void Create() { m_dirmovement1 = new DirMovement(this); Plot1 = AddPlot(new PlotAttributes("DMI+", 0, Color.Yellow, Color.Empty, 0, 0, true)); Plot2 = AddPlot(new PlotAttributes("DMI-", 0, Color.Blue, Color.Empty, 0, 0, true)); Plot3 = AddPlot(new PlotAttributes("ADX", 0, Color.Cyan, Color.Empty, 0, 0, true)); Plot4 = AddPlot(new PlotAttributes("prev_minus", 0, Color.Aqua, Color.Empty, 0, 0, true)); Plot5 = AddPlot(new PlotAttributes("prev_pluse", 0, Color.Aquamarine, Color.Empty, 0, 0, true)); } protected override void StartCalc() { m_dirmovement1.PriceH = Bars.High; m_dirmovement1.PriceL = Bars.Low; m_dirmovement1.PriceC = Bars.Close; m_dirmovement1.Length = length; } protected override void CalcBar() { m_dirmovement1.Call(); Plot1.Set(0, m_dirmovement1.DMIPlus.Value); Plot2.Set(0, m_dirmovement1.DMIMinus.Value); //Plot3.Set(0, m_dirmovement1.ADX.Value); double Prev_D_Minus = m_dirmovement1.DMIMinus[1]; double Prev_D_Plus = m_dirmovement1.DMIPlus[1]; Plot4.Set(0, Prev_D_Minus); Plot5.Set(0, Prev_D_Plus); if (PublicFunctions.DoubleGreater(m_dirmovement1.ADX.Value, adxtrend)) { if (this.CrossesOver(m_dirmovement1.DMIPlus, m_dirmovement1.DMIMinus)) { Alerts.Alert("Bullish alert"); } else { if (this.CrossesUnder(m_dirmovement1.DMIPlus, m_dirmovement1.DMIMinus)) { Alerts.Alert("Bearish alert"); } } } } } }


Return to “MultiCharts .NET”