Lean
$LEAN_TAG$
ResetCompositeIndicator.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
using
System;
17
18
namespace
QuantConnect.Indicators
19
{
20
/// <summary>
21
/// Class that extends CompositeIndicator to execute a given action once is reset
22
/// </summary>
23
public
class
ResetCompositeIndicator
:
CompositeIndicator
24
{
25
/// <summary>
26
/// Action to execute once this indicator is reset
27
/// </summary>
28
private
Action _extraResetAction;
29
30
/// <summary>
31
/// Creates a new ResetCompositeIndicator capable of taking the output from the left and right indicators
32
/// and producing a new value via the composer delegate specified
33
/// </summary>
34
/// <param name="left">The left indicator for the 'composer'</param>
35
/// <param name="right">The right indicator for the 'composer'</param>
36
/// <param name="composer">Function used to compose the left and right indicators</param>
37
/// <param name="extraResetAction">Action to execute once the composite indicator is reset</param>
38
public
ResetCompositeIndicator
(
IndicatorBase
left,
IndicatorBase
right,
IndicatorComposer
composer, Action extraResetAction)
39
: this($
"RESET_COMPOSE({left.Name},{right.Name})"
, left, right, composer, extraResetAction)
40
{
41
}
42
43
/// <summary>
44
/// Creates a new CompositeIndicator capable of taking the output from the left and right indicators
45
/// and producing a new value via the composer delegate specified
46
/// </summary>
47
/// <param name="name">The name of this indicator</param>
48
/// <param name="left">The left indicator for the 'composer'</param>
49
/// <param name="right">The right indicator for the 'composer'</param>
50
/// <param name="composer">Function used to compose the left and right indicators</param>
51
/// <param name="extraResetAction">Action to execute once the indicator is reset</param>
52
public
ResetCompositeIndicator
(
string
name,
IndicatorBase
left,
IndicatorBase
right,
IndicatorComposer
composer, Action extraResetAction)
53
: base(name, left, right, composer)
54
{
55
_extraResetAction = extraResetAction;
56
}
57
58
/// <summary>
59
/// Resets this indicator and invokes the given reset action
60
/// </summary>
61
public
override
void
Reset
()
62
{
63
base.Reset();
64
_extraResetAction.Invoke();
65
}
66
}
67
}
Indicators
ResetCompositeIndicator.cs
Generated by
1.8.17