QuantStudio Financial Data Analysis and Trading Framework

PDI Class

Plus Directional Indicator (PDI)

For a list of all members of this type, see PDI Members.

System.Object
   RQuant.Indicator.TTimeArray
      RQuant.Indicator.TDoubleArray
         RQuant.Indicator.TIndicator
            RQuant.Indicator.PDI

[Visual Basic]
Public Class PDI
    Inherits TIndicator
[C#]
public class PDI : TIndicator

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The concept of Directional Movement is based on the assumption that in an upward trend today?s highest price is higher than yesterday?s highest price and in a downward trend today?s lowest price is lower than yesterday?s lowest price. If this is the case, it is a matter of the so-called Outside Days. The difference between today?s high and yesterday?s high divided to True Range corresponds to the Plus Directional Indicator (PDI). The difference between today?s low and yesterday?s low divided to True Range is the Minus Directional Indicator (MDI). These Outside Days consist of a MDI as well as an PDI.

To calculate the Directional Indicators (PDI and MDI), further calculation of the True Range is necessary. The true range is always positive and is defined as the current highest value of the difference among today?s highest price minus today?s lowest price; today?s highest price minus yesterday?s closing price; and today?s lowest price minus yesterday?s closing price.

Note, that there are two styles of indicator PDI. Some trading systems use the formula (which is a little bit distinguished from classical) for calculation of this indicator. Therefore Quant Studio gives an opportunity to use two styles PDI - classical (QuantStudio style) and little bit changed (MetaStock style.)

PDI has QuantStudio style by Default.

Formula for Quant Studio (classical) style:

TDataManager.cd("demo");

TInstrument Instrument = TDataManager.GetInstrument("YHOO");

DateTime Date1 = DateTime.Parse("2000/01/04"); 
DateTime Date2 = DateTime.Parse("2000/12/29"); 

TDailyArray Array = Instrument.DailyArray.Clone(Date1, Date2);

TCanvas Canvas = new TCanvas("Canvas", 600, 800);

Canvas.Divide(1, 4);

Canvas.cd(1);

Array.Draw("C");
Array.SMA(14).Draw("S", Color.Red);

Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);

Canvas.cd(2);

Array.DX (14).Draw(Color.Violet);
Array.PDI(14).Draw(Color.Red);
Array.MDI(14).Draw(Color.Blue);

Canvas.Pad.Title.Text = "+/- DI, DX";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRange(Date1, Date2, 0, 100);

Canvas.cd(3);

Array.ADX (14).Draw(Color.Red);
Array.ADXR(14).Draw(Color.Blue);

Canvas.Pad.Title.Text = "ADX, ADXR";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);

Canvas.cd(4);

Array.PDM().Draw(Color.Purple);
Array.MDM().Draw(Color.Green);

Canvas.Pad.Title.Text = "+/- DM";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);



Formula for MetaStock style:
TDataManager.cd("demo");

TInstrument Instrument = TDataManager.GetInstrument("YHOO");

DateTime Date1 = DateTime.Parse("2000/01/04"); 
DateTime Date2 = DateTime.Parse("2000/12/29"); 

TDailyArray Array = Instrument.DailyArray.Clone(Date1, Date2);

EIndicatorStyle Style = EIndicatorStyle.MetaStock;

TCanvas Canvas = new TCanvas("Canvas", 600, 800);

Canvas.Divide(1, 4);

Canvas.cd(1);

Array.Draw("C");
Array.SMA(14).Draw("S", Color.Red);

Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);

Canvas.cd(2);

Array.DX (14, Style).Draw(Color.Violet);
Array.PDI(14, Style).Draw(Color.Red);
Array.MDI(14, Style).Draw(Color.Blue);

Canvas.Pad.Title.Text = "+/- DI, DX";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRange(Date1, Date2, 0, 100);

Canvas.cd(3);

Array.ADX (14, Style).Draw(Color.Red);
Array.ADXR(14, Style).Draw(Color.Blue);

Canvas.Pad.Title.Text = "ADX, ADXR";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);

Canvas.cd(4);

Array.PDM().Draw(Color.Purple);
Array.MDM().Draw(Color.Green);

Canvas.Pad.Title.Text = "+/- DM";
Canvas.Pad.LegendEnabled = true;
Canvas.Pad.SetRangeX(Date1, Date2);

Requirements

Namespace: RQuant.Indicator

Assembly: RQuant.Indicator (in RQuant.Indicator.dll)

See Also

PDI Members | RQuant.Indicator Namespace