-
Notifications
You must be signed in to change notification settings - Fork 6
/
Chaikin_Osc.Indicator.CS
111 lines (93 loc) · 3.53 KB
/
Chaikin_Osc.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Drawing;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
public class Chaikin_Osc : IndicatorObject
{
private ChaikinOsc m_chaikinosc1;
private NormGradientColor m_normgradientcolor1;
private Int32 m_applicationtype;
private VariableSeries<Double> m_chaikinoscval;
private IPlotObject Plot1;
private IPlotObject Plot2;
public Chaikin_Osc(object ctx) :
base(ctx){
gridforegroundcolor = Color.Black;
dncolor = Color.Red;
upcolor = Color.Yellow;
colornormlength = 14;
alertlength = 14;
slowlength = 10;
fastlength = 3;
}
[Input]
public int fastlength { get; set; }
[Input]
public int slowlength { get; set; }
[Input]
public int alertlength { get; set; }
[Input]
public int colornormlength { get; set; }
[Input]
public Color upcolor { get; set; }
[Input]
public Color dncolor { get; set; }
[Input]
public Color gridforegroundcolor { get; set; }
protected override void Create(){
m_chaikinosc1 = new ChaikinOsc(this);
m_normgradientcolor1 = new NormGradientColor(this);
m_applicationtype = 0;
m_chaikinoscval = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("ChaikinOsc", 0, Color.Cyan,
Color.Empty, 0, 0, true));
Plot2 =
AddPlot(new PlotAttributes("ZeroLine", 0, Color.Green,
Color.Empty, 0, 0, true));
}
protected override void StartCalc(){
m_chaikinosc1.anyvol = Bars.TrueVolume();
m_chaikinosc1.shortlength = fastlength;
m_chaikinosc1.longlength = slowlength;
m_normgradientcolor1.dataseriesvalue = m_chaikinoscval;
m_normgradientcolor1.crosseszero = true;
m_normgradientcolor1.colornormlength = colornormlength;
m_normgradientcolor1.upcolor = upcolor;
m_normgradientcolor1.dncolor = dncolor;
m_applicationtype = (Int32) Environment.ApplicationCode;
}
protected override void CalcBar()
{
m_chaikinoscval.Value = m_chaikinosc1[0];
Plot1.Set(0, m_chaikinoscval.Value);
Plot2.Set(0, 0);
if ((Color.Empty != upcolor && Color.Empty != dncolor))
{
var m_colorlevel = m_normgradientcolor1[0];
if ((m_applicationtype == 1)){
Plot1.Colors[0] = m_colorlevel;
}
else{
if (m_applicationtype > 1){
Plot1.Colors[0] = gridforegroundcolor;
Plot1.BGColor = m_colorlevel;
}
}
}
if (((Bars.Close.LowestBar(alertlength) == 0)
&& PublicFunctions.DoubleGreater(m_chaikinoscval.LowestBar(alertlength), 0)))
{
Alerts.Alert("Bullish divergence - new low not confirmed");
}
else{
if (((Bars.Close.HighestBar(alertlength) == 0)
&& PublicFunctions.DoubleGreater(m_chaikinoscval.HighestBar(alertlength), 0)))
{
Alerts.Alert("Bearish divergence - new high not confirmed");
}
}
}
}
}