-
Notifications
You must be signed in to change notification settings - Fork 6
/
Chaos_Gator.Indicator.CS
93 lines (72 loc) · 2.7 KB
/
Chaos_Gator.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Drawing;
namespace PowerLanguage.Indicator
{
public class Chaos_Gator : IndicatorObject
{
private ISeries<Double> m_value;
private VariableSeries<Double> m_value11;
private VariableSeries<Double> m_value12;
private IPlotObject Plot1;
private IPlotObject Plot2;
public Chaos_Gator(object ctx) :
base(ctx){
valuedown = Color.Red;
valueup = Color.Green;
lipoffset = 3;
lip = 5;
teethoffset = 5;
teeth = 8;
jawoffset = 8;
jaw = 13;
}
[Input]
public int jaw { get; set; }
[Input]
public int jawoffset { get; set; }
[Input]
public int teeth { get; set; }
[Input]
public int teethoffset { get; set; }
[Input]
public int lip { get; set; }
[Input]
public int lipoffset { get; set; }
private ISeries<Double> value{
get { return m_value; }
}
[Input]
public Color valueup { get; set; }
[Input]
public Color valuedown { get; set; }
protected override void Create(){
m_value11 = new VariableSeries<Double>(this);
m_value12 = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("BLblue", EPlotShapes.Histogram,
Color.Blue, Color.Empty, 0, 0,
true));
Plot2 =
AddPlot(new PlotAttributes("BLred", EPlotShapes.Histogram,
Color.Red, Color.Empty, 0,
0,
true));
}
protected override void StartCalc(){
m_value = new Lambda<Double>(_bb => (Bars.High[_bb] + Bars.Low[_bb])/2);
}
protected override void CalcBar(){
var m_value1 = value.Average(jaw, jawoffset);
var m_value2 = value.Average(teeth, teethoffset);
var m_value3 = value.Average(lip, lipoffset);
if (Bars.CurrentBar >= 21){
m_value11.Value = Math.Abs((m_value1 - m_value2));
Plot1.Set(0, m_value11.Value,
PublicFunctions.DoubleGreater(m_value11.Value, m_value11[1]) ? valueup : valuedown);
m_value12.Value = -1*Math.Abs((m_value2 - m_value3));
Plot2.Set(0, m_value12.Value,
PublicFunctions.DoubleGreater(m_value12.Value, m_value12[1]) ? valueup : valuedown);
}
}
}
}