forked from dnickless/multicharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mov_Avg_Exp_Ribbon.Indicator.CS
132 lines (110 loc) · 4.99 KB
/
Mov_Avg_Exp_Ribbon.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Drawing;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Mov_Avg_Exp_Ribbon : IndicatorObject
{
private ArraySimple<Int32> m_length;
private ArraySimple<Double> m_smoothingfactor;
private ArraySeries<Double> m_xma;
private ArraySimple<Color> m_color;
private IPlotObject Plot1;
private IPlotObject Plot2;
private IPlotObject Plot3;
private IPlotObject Plot4;
private IPlotObject Plot5;
private IPlotObject Plot6;
private IPlotObject Plot7;
private IPlotObject Plot8;
public Mov_Avg_Exp_Ribbon(object ctx) :
base(ctx){
slowcolor = Color.Red;
fastcolor = Color.Yellow;
incrementormultiplier = 10;
arithorgeom_1or2 = 1;
baselength = 10;
}
private ISeries<double> price { get; set; }
[Input]
public int baselength { get; set; }
[Input]
public int arithorgeom_1or2 { get; set; }
[Input]
public int incrementormultiplier { get; set; }
[Input]
public Color fastcolor { get; set; }
[Input]
public Color slowcolor { get; set; }
protected override void Create(){
m_length = new ArraySimple<Int32>(this, 9);
m_smoothingfactor = new ArraySimple<Double>(this, 9);
m_xma = new ArraySeries<Double>(this, 9);
m_color = new ArraySimple<Color>(this, 9);
Plot1 =
AddPlot(new PlotAttributes("XMA1", 0, Color.Blue,
Color.Empty,
0, 0, true));
Plot2 =
AddPlot(new PlotAttributes("XMA2", 0, Color.Red,
Color.Empty, 0, 0, true));
Plot3 =
AddPlot(new PlotAttributes("XMA3", 0, Color.Cyan,
Color.Empty, 0, 0, true));
Plot4 =
AddPlot(new PlotAttributes("XMA4", 0, Color.Yellow,
Color.Empty, 0, 0, true));
Plot5 =
AddPlot(new PlotAttributes("XMA5", 0, Color.Blue,
Color.Empty,
0, 0, true));
Plot6 =
AddPlot(new PlotAttributes("XMA6", 0, Color.Red,
Color.Empty, 0, 0, true));
Plot7 =
AddPlot(new PlotAttributes("XMA7", 0, Color.Cyan,
Color.Empty, 0, 0, true));
Plot8 =
AddPlot(new PlotAttributes("XMA8", 0, Color.Yellow,
Color.Empty, 0, 0, true));
}
protected override void StartCalc(){
price = Bars.Close;
}
protected override void CalcBar(){
if ((Bars.CurrentBar == 1)){
m_length[0][((1))] = baselength;
m_smoothingfactor[0][((1))] = (2/((double) ((m_length[0][((1))] + 1))));
m_xma[0][((1))] = price[0];
m_color[0][((1))] = PublicFunctions.GradientColor(1, 1, 8, fastcolor, slowcolor);
for (var m_counter = 1; (m_counter <= 7); m_counter = (m_counter + 1)){
if ((arithorgeom_1or2 == 1)){
m_length[0][(((m_counter + 1)))] = (m_length[0][((m_counter))] + incrementormultiplier);
}
else{
m_length[0][(((m_counter + 1)))] = (m_length[0][((m_counter))]*incrementormultiplier);
}
m_smoothingfactor[0][(((m_counter + 1)))] = (2/((double) ((m_length[0][(((m_counter + 1)))] + 1))));
m_xma[0][(((m_counter + 1)))] = price[0];
m_color[0][(((m_counter + 1)))] = PublicFunctions.GradientColor((m_counter + 1), 1, 8, fastcolor,
slowcolor);
}
}
else{
for (var m_counter = 1; (m_counter <= 8); m_counter = (m_counter + 1)){
m_xma[0][((m_counter))] = (m_xma[1][((m_counter))]
+ (m_smoothingfactor[0][((m_counter))]
*(price[0] - m_xma[1][((m_counter))])));
}
}
Plot1.Set(0, m_xma[0][((1))], m_color[0][((1))]);
Plot2.Set(0, m_xma[0][((2))], m_color[0][((2))]);
Plot3.Set(0, m_xma[0][((3))], m_color[0][((3))]);
Plot4.Set(0, m_xma[0][((4))], m_color[0][((4))]);
Plot5.Set(0, m_xma[0][((5))], m_color[0][((5))]);
Plot6.Set(0, m_xma[0][((6))], m_color[0][((6))]);
Plot7.Set(0, m_xma[0][((7))], m_color[0][((7))]);
Plot8.Set(0, m_xma[0][((8))], m_color[0][((8))]);
}
}
}