-
Notifications
You must be signed in to change notification settings - Fork 6
/
Chaos_AC_Oscillator.Indicator.CS
48 lines (40 loc) · 1.51 KB
/
Chaos_AC_Oscillator.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
using System;
using System.Drawing;
namespace PowerLanguage.Indicator
{
public class Chaos_AC_Oscillator : IndicatorObject
{
private VariableSeries<Double> m_ao;
private VariableSeries<Double> m_ac;
private IPlotObject Plot1;
private IPlotObject Plot2;
public Chaos_AC_Oscillator(object ctx) :
base(ctx) {}
protected override void Create(){
m_ao = new VariableSeries<Double>(this);
m_ac = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("+AC", EPlotShapes.Histogram, Color.Lime,
Color.Empty, 0, 0, true));
Plot2 =
AddPlot(new PlotAttributes("-AC", EPlotShapes.Histogram, Color.Blue,
Color.Empty, 0, 0, true));
}
private ISeries<double> m_avg_price;
protected override void StartCalc(){
m_avg_price = new Lambda<Double>(_bb => ((Bars.High[_bb] + Bars.Low[_bb])/2));
}
protected override void CalcBar(){
m_ao.Value = m_avg_price.Average(5) - m_avg_price.Average(34);
m_ac.Value = m_ao.Value - m_ao.Average(5);
if (Bars.CurrentBar >= 5){
if (PublicFunctions.DoubleGreater(m_ac.Value, m_ac[1])){
Plot1.Set(0, m_ac.Value);
}
else{
Plot2.Set(0, m_ac.Value);
}
}
}
}
}