docker files fixes from liaqat
This commit is contained in:
55
src/Managing.Domain/Strategies/ThreeWhiteSoldiersStrategy.cs
Normal file
55
src/Managing.Domain/Strategies/ThreeWhiteSoldiersStrategy.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.Shared.Rules;
|
||||
using Managing.Domain.Strategies;
|
||||
using Managing.Domain.Strategies.Rules;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Application.Strategies
|
||||
{
|
||||
public class ThreeWhiteSoldiersStrategy : Strategy
|
||||
{
|
||||
public ThreeWhiteSoldiersStrategy(string name, Timeframe timeframe, int period)
|
||||
: base(name, timeframe, StrategyType.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user