Rename strategy to indicators
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.Shared.Rules;
|
||||
using Managing.Domain.Strategies.Base;
|
||||
using Managing.Domain.Strategies.Rules;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Domain.Strategies.Signals
|
||||
{
|
||||
public class ThreeWhiteSoldiersIndicator : Indicator
|
||||
{
|
||||
public ThreeWhiteSoldiersIndicator(string name, int period)
|
||||
: base(name, IndicatorType.ThreeWhiteSoldiers)
|
||||
{
|
||||
Period = period;
|
||||
}
|
||||
|
||||
public TradeDirection Direction { get; }
|
||||
|
||||
public override List<Signal> Run()
|
||||
{
|
||||
var signals = new List<Signal>();
|
||||
|
||||
if (Candles.Count <= 3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var lastFourCandles = Candles.TakeLast(4);
|
||||
Candle previousCandles = null;
|
||||
|
||||
foreach (var currentCandle in lastFourCandles)
|
||||
{
|
||||
if (Direction == TradeDirection.Long)
|
||||
{
|
||||
Check.That(new CloseHigherThanThePreviousHigh(previousCandles, currentCandle));
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.That(new CloseLowerThanThePreviousHigh(previousCandles, currentCandle));
|
||||
}
|
||||
|
||||
previousCandles = currentCandle;
|
||||
}
|
||||
|
||||
return signals;
|
||||
}
|
||||
catch (RuleException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override IndicatorsResultBase GetStrategyValues()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user