-
Notifications
You must be signed in to change notification settings - Fork 6
/
Avg_Close_Less_Avg_Open.Indicator.CS
60 lines (50 loc) · 1.71 KB
/
Avg_Close_Less_Avg_Open.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
using System;
using System.Drawing;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Avg_Close_Less_Avg_Open : IndicatorObject
{
private AverageFC m_averagefc1;
private AverageFC m_averagefc2;
private IPlotObject Plot1;
private IPlotObject Plot2;
public Avg_Close_Less_Avg_Open(object ctx) :
base(ctx){
length = 14;
}
[Input]
public int length { get; set; }
protected override void Create(){
m_averagefc1 = new AverageFC(this);
m_averagefc2 = new AverageFC(this);
Plot1 =
AddPlot(new PlotAttributes("Plot1", EPlotShapes.BarHigh,
Color.Red, Color.Empty, 0,
0,
true));
Plot2 =
AddPlot(new PlotAttributes("Plot2", EPlotShapes.BarLow,
Color.Red, Color.Empty, 0,
0,
true));
}
protected override void StartCalc(){
m_averagefc1.price = Bars.Close;
m_averagefc1.length = length;
m_averagefc2.price = Bars.Open;
m_averagefc2.length = length;
}
protected override void CalcBar(){
if (PublicFunctions.DoubleLess(m_averagefc1[0], m_averagefc2[0])){
Plot1.Set(0, Bars.High[0]);
Plot2.Set(0, Bars.Low[0]);
Alerts.Alert();
}
else{
Plot1.Reset();
}
}
}
}