Remove timeframe from strategy (#13)

This commit is contained in:
Oda
2025-02-26 17:24:59 +07:00
committed by GitHub
parent 298b666a0b
commit 4302bb8435
39 changed files with 299 additions and 288 deletions

View File

@@ -12,11 +12,10 @@ public class StochRsiTrendStrategy : Strategy
public StochRsiTrendStrategy(
string name,
Timeframe timeframe,
int period,
int stochPeriod,
int signalPeriod,
int smoothPeriods) : base(name, timeframe, StrategyType.StochRsiTrend)
int smoothPeriods) : base(name, StrategyType.StochRsiTrend)
{
Signals = new List<Signal>();
StochPeriods = stochPeriod;
@@ -34,7 +33,9 @@ public class StochRsiTrendStrategy : Strategy
try
{
var stochRsi = Candles.GetStochRsi(Period.Value, StochPeriods.Value, SignalPeriods.Value, SmoothPeriods.Value).RemoveWarmupPeriods().ToList();
var stochRsi = Candles
.GetStochRsi(Period.Value, StochPeriods.Value, SignalPeriods.Value, SmoothPeriods.Value)
.RemoveWarmupPeriods().ToList();
var stochRsiCandles = MapStochRsiToCandle(stochRsi, Candles.TakeLast(Period.Value));
if (stochRsi.Count == 0)
@@ -45,11 +46,11 @@ public class StochRsiTrendStrategy : Strategy
{
if (currentCandle.Signal < 20)
{
AddSignal(currentCandle, Timeframe, TradeDirection.Long, Confidence.None);
AddSignal(currentCandle, TradeDirection.Long, Confidence.None);
}
else if (currentCandle.Signal > 80)
{
AddSignal(currentCandle, Timeframe, TradeDirection.Short, Confidence.None);
AddSignal(currentCandle, TradeDirection.Short, Confidence.None);
}
previousCandle = currentCandle;
@@ -83,10 +84,11 @@ public class StochRsiTrendStrategy : Strategy
});
}
}
return emaList;
}
private void AddSignal(CandleStochRsi candleSignal, Timeframe timeframe, TradeDirection direction, Confidence confidence)
private void AddSignal(CandleStochRsi candleSignal, TradeDirection direction, Confidence confidence)
{
var signal = new Signal(
MiscExtensions.ParseEnum<Ticker>(candleSignal.Ticker),
@@ -95,7 +97,6 @@ public class StochRsiTrendStrategy : Strategy
candleSignal,
candleSignal.Date,
candleSignal.Exchange,
timeframe,
Type,
SignalType);
if (!Signals.Any(s => s.Identifier == signal.Identifier))
@@ -109,4 +110,4 @@ public class StochRsiTrendStrategy : Strategy
public double Signal { get; internal set; }
public double StochRsi { get; internal set; }
}
}
}