Lean
$LEAN_TAG$
Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
f
h
i
l
m
n
o
p
q
r
s
t
w
Functions
Enumerations
a
b
c
d
f
h
i
l
m
n
o
p
q
r
s
t
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Γ
Δ
Θ
ρ
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Γ
Δ
Θ
ρ
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Events
a
b
c
d
e
f
i
l
m
n
o
q
r
s
t
u
Files
File List
•
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
Properties
Events
Pages
RelativeVigorIndexSignal.cs
1
/*
2
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
namespace
QuantConnect.Indicators
17
{
18
/// <summary>
19
/// The signal for the Relative Vigor Index, itself an indicator.
20
/// </summary>
21
public
class
RelativeVigorIndexSignal
:
Indicator
,
IIndicatorWarmUpPeriodProvider
22
{
23
private
readonly
RollingWindow<IndicatorDataPoint>
_rollingRvi;
24
25
/// <summary>
26
/// Initializes the signal term.
27
/// </summary>
28
/// <param name="name"></param>
29
protected
internal
RelativeVigorIndexSignal
(
string
name)
30
: base(name)
// Accessibility set to prevent out-of-scope use
31
{
32
WarmUpPeriod
= 3;
33
_rollingRvi =
new
RollingWindow<IndicatorDataPoint>
(3);
34
}
35
36
/// <summary>
37
/// Gets a flag indicating when this indicator is ready and fully initialized
38
/// </summary>
39
public
override
bool
IsReady
=> _rollingRvi.IsReady;
40
41
/// <summary>
42
/// Resets this indicator to its initial state
43
/// </summary>
44
public
int
WarmUpPeriod
{
get
; }
45
46
/// <summary>
47
/// Computes the next value of this indicator from the given state
48
/// </summary>
49
/// <param name="input">The input given to the indicator</param>
50
/// <returns>A new value for this indicator</returns>
51
protected
override
decimal
ComputeNextValue
(
IndicatorDataPoint
input)
52
{
53
if
(
IsReady
)
54
{
55
var output = (input.
Value
+ 2 * (_rollingRvi[0] + _rollingRvi[1]) + _rollingRvi[2]) / 6;
56
_rollingRvi.Add(input);
57
return
output;
58
}
59
60
_rollingRvi.Add(input);
61
return
0m;
62
}
63
64
/// <summary>
65
/// Resets this indicator to its initial state
66
/// </summary>
67
public
override
void
Reset
()
68
{
69
base.Reset();
70
_rollingRvi.Reset();
71
}
72
}
73
}
Indicators
RelativeVigorIndexSignal.cs
Generated by
1.8.17