-
Notifications
You must be signed in to change notification settings - Fork 6
/
DMI.Indicator.CS
71 lines (59 loc) · 2.11 KB
/
DMI.Indicator.CS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
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));
}
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);
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");
}
}
}
}
}
}