forked from dnickless/multicharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mov_Avg_Exponential.Indicator.CS
66 lines (55 loc) · 2.1 KB
/
Mov_Avg_Exponential.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
using System;
using System.Drawing;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Mov_Avg_Exponential : IndicatorObject
{
private XAverage m_xaverage1;
private VariableSeries<Double> m_avgexp;
private IPlotObject Plot1;
public Mov_Avg_Exponential(object ctx) :
base(ctx){
length = 9;
}
private ISeries<double> price { get; set; }
[Input]
public int length { get; set; }
[Input]
public int displace { get; set; }
protected override void Create(){
m_xaverage1 = new XAverage(this);
m_avgexp = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("AvgExp", 0, Color.Blue,
Color.Empty, 0, 0, true));
}
protected override void StartCalc(){
price = Bars.Close;
m_xaverage1.Price = price;
m_xaverage1.Length = length;
}
protected override void CalcBar(){
m_avgexp.Value = m_xaverage1[0];
if (((displace >= 0)
|| Bars.CurrentBar > Math.Abs(displace))){
Plot1.Set(displace, m_avgexp.Value);
if ((displace <= 0)){
if (((PublicFunctions.DoubleGreater(price[0], m_avgexp.Value) &&
PublicFunctions.DoubleGreater(m_avgexp.Value, m_avgexp[1]))
&& PublicFunctions.DoubleLessEquals(m_avgexp[1], m_avgexp[2]))){
Alerts.Alert("Indicator turning up");
}
else{
if (((PublicFunctions.DoubleLess(price[0], m_avgexp.Value) &&
PublicFunctions.DoubleLess(m_avgexp.Value, m_avgexp[1]))
&& PublicFunctions.DoubleGreaterEquals(m_avgexp[1], m_avgexp[2]))){
Alerts.Alert("Indicator turning down");
}
}
}
}
}
}
}