Skip to content

Commit

Permalink
Merge pull request AlexWan#578 from JChinaM/master
Browse files Browse the repository at this point in the history
Ssma Offset
  • Loading branch information
AlexWan authored Jan 3, 2024
2 parents 02aa3f4 + 97559c4 commit a495e68
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions project/OsEngine/bin/Debug/Custom/Indicators/Scripts/OffsetSsma.cs
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];
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public IntersectionOfSsmaAndSsmaOffset(string name, StartProgram startProgram) :
_ssma1.Save();

// Creating indicator Ssma2
_ssma2 = IndicatorsFactory.CreateIndicatorByName(nameClass: "OffsetEma", name: name + "Ssma2", canDelete: false);
_ssma2 = IndicatorsFactory.CreateIndicatorByName(nameClass: "OffsetSsma", name: name + "Ssma2", canDelete: false);
_ssma2 = (Aindicator)_tab.CreateCandleIndicator(_ssma2, nameArea: "Prime");
_ssma2.ParametersDigit[0].Value = _periodSsmaSlow.ValueInt;
_ssma2.ParametersDigit[1].Value = _periodOffset.ValueInt;
Expand Down

0 comments on commit a495e68

Please sign in to comment.