-
Notifications
You must be signed in to change notification settings - Fork 6
/
Floor_Trader_Pivots.Indicator.CS
149 lines (127 loc) · 5.35 KB
/
Floor_Trader_Pivots.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Drawing;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Floor_Trader_Pivots : IndicatorObject
{
private VariableObject<Double> m_s1;
private VariableObject<Double> m_s2;
private VariableObject<Double> m_s3;
private VariableObject<Double> m_r1;
private VariableObject<Double> m_r2;
private VariableObject<Double> m_r3;
private VariableObject<Double> m_pp;
private VariableObject<Double> m_todayshigh;
private VariableObject<Double> m_todayslow;
private VariableObject<Int32> m_counter;
private IPlotObject Plot1;
private IPlotObject Plot2;
private IPlotObject Plot3;
private IPlotObject Plot4;
private IPlotObject Plot5;
private IPlotObject Plot6;
private IPlotObject Plot7;
public Floor_Trader_Pivots(object ctx) :
base(ctx){
plot_5or7 = 5;
}
[Input]
public int plot_5or7 { get; set; }
protected override void Create(){
m_s1 = new VariableObject<Double>(this);
m_s2 = new VariableObject<Double>(this);
m_s3 = new VariableObject<Double>(this);
m_r1 = new VariableObject<Double>(this);
m_r2 = new VariableObject<Double>(this);
m_r3 = new VariableObject<Double>(this);
m_pp = new VariableObject<Double>(this);
m_todayshigh = new VariableObject<Double>(this);
m_todayslow = new VariableObject<Double>(this);
m_counter = new VariableObject<Int32>(this);
Plot1 =
AddPlot(new PlotAttributes("R3", EPlotShapes.LeftTick,
Color.Magenta, Color.Empty, 2,
0,
true));
Plot2 =
AddPlot(new PlotAttributes("R2", EPlotShapes.LeftTick, Color.Blue,
Color.Empty, 2, 0, true));
Plot3 =
AddPlot(new PlotAttributes("R1", EPlotShapes.LeftTick,
Color.Yellow, Color.Empty, 2,
0,
true));
Plot4 =
AddPlot(new PlotAttributes("PP", EPlotShapes.LeftTick, Color.Cyan,
Color.Empty, 2, 0, true));
Plot5 =
AddPlot(new PlotAttributes("S1", EPlotShapes.LeftTick,
Color.Yellow, Color.Empty, 2,
0,
true));
Plot6 =
AddPlot(new PlotAttributes("S2", EPlotShapes.LeftTick, Color.Blue,
Color.Empty, 2, 0, true));
Plot7 =
AddPlot(new PlotAttributes("S3", EPlotShapes.LeftTick,
Color.Magenta, Color.Empty, 2,
0,
true));
}
protected override void CalcBar()
{
EResolution resolution = Bars.Info.Resolution.Type;
if (resolution == EResolution.Quarter ||
EResolution.Week <= resolution && resolution <= EResolution.Year) return;
if (Bars.Time[0].Date != Bars.Time[1].Date)
{
m_counter.Value = (m_counter.Value + 1);
var m_yesthigh = m_todayshigh.Value;
var m_yestlow = m_todayslow.Value;
var m_yestclose = Bars.Close[1];
m_todayshigh.Value = Bars.High[0];
m_todayslow.Value = Bars.Low[0];
m_pp.Value = (((m_yesthigh + m_yestlow)
+ m_yestclose)
/((3)));
m_r1.Value = ((m_pp.Value*2)
- m_yestlow);
m_r2.Value = ((m_pp.Value + m_yesthigh)
- m_yestlow);
m_r3.Value = ((m_r2.Value + m_yesthigh)
- m_yestlow);
m_s1.Value = ((m_pp.Value*2)
- m_yesthigh);
m_s2.Value = ((m_pp.Value - m_yesthigh)
+ m_yestlow);
m_s3.Value = ((m_s2.Value - m_yesthigh)
+ m_yestlow);
}
else{
if (PublicFunctions.DoubleGreater(Bars.High[0], m_todayshigh.Value)){
m_todayshigh.Value = Bars.High[0];
}
if (PublicFunctions.DoubleLess(Bars.Low[0], m_todayslow.Value)){
m_todayslow.Value = Bars.Low[0];
}
}
if (m_counter.Value >= 2)
{
if ((plot_5or7 == 7))
{
Plot1.Set(0, m_r3.Value);
}
Plot2.Set(0, m_r2.Value);
Plot3.Set(0, m_r1.Value);
Plot4.Set(0, m_pp.Value);
Plot5.Set(0, m_s1.Value);
Plot6.Set(0, m_s2.Value);
if ((plot_5or7 == 7))
{
Plot7.Set(0, m_s3.Value);
}
}
}
}
}