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.
Previous DMI+ / DMI - value
- Kate MultiCharts
- Posts: 593
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 148 times
Re: Previous DMI+ / DMI - value
Hello lewisthegood,
Here's an example you can refer to:
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");
}
}
}
}
}
}