forked from AlexWan/OsEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request AlexWan#578 from JChinaM/master
Ssma Offset
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
project/OsEngine/bin/Debug/Custom/Indicators/Scripts/OffsetSsma.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using OsEngine.Entity; | ||
using OsEngine.Indicators; | ||
|
||
namespace CustomIndicators.Scripts | ||
{ | ||
public class OffsetSsma : Aindicator | ||
{ | ||
private IndicatorParameterInt _lengthSsma; | ||
|
||
private IndicatorParameterInt _offset; | ||
|
||
private IndicatorDataSeries _series; | ||
|
||
private Aindicator _OffsetSsma; | ||
|
||
public override void OnStateChange(IndicatorState state) | ||
{ | ||
if (state == IndicatorState.Configure) | ||
{ | ||
_lengthSsma = CreateParameterInt("Ssma length", 5); | ||
|
||
_offset = CreateParameterInt("Ssma offset", 5); | ||
|
||
_series = CreateSeries("Ssma", Color.DarkRed, IndicatorChartPaintType.Line, true); | ||
|
||
_OffsetSsma = IndicatorsFactory.CreateIndicatorByName("Ssma", Name + "Ssma", false); | ||
_OffsetSsma.Parameters[0].Bind(_lengthSsma); | ||
ProcessIndicator("OffsetSsma", _OffsetSsma); | ||
} | ||
} | ||
|
||
public override void OnProcess(List<Candle> candles, int index) | ||
{ | ||
if (index >= _offset.ValueInt) | ||
{ | ||
_series.Values[index] = _OffsetSsma.DataSeries[0].Values[index - _offset.ValueInt]; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters