Update ichimoku
This commit is contained in:
@@ -74,8 +74,11 @@ public class IchimokuKumoTrend : IndicatorBase
|
||||
if (preCalculatedValues?.Ichimoku != null && preCalculatedValues.Ichimoku.Any())
|
||||
{
|
||||
// Filter pre-calculated Ichimoku values to match the candles we're processing
|
||||
// and ensure we have valid cloud data (non-null, non-zero values)
|
||||
ichimokuResults = preCalculatedValues.Ichimoku
|
||||
.Where(i => i.SenkouSpanA.HasValue && i.SenkouSpanB.HasValue && candles.Any(c => c.Date == i.Date))
|
||||
.Where(i => i.SenkouSpanA.HasValue && i.SenkouSpanB.HasValue &&
|
||||
i.SenkouSpanA.Value != 0 && i.SenkouSpanB.Value != 0 &&
|
||||
candles.Any(c => c.Date == i.Date))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -128,8 +131,14 @@ public class IchimokuKumoTrend : IndicatorBase
|
||||
var candleIchimokuResults = new List<CandleIchimoku>();
|
||||
|
||||
// Map IchimokuResult to CandleIchimoku
|
||||
// Only include results where we have valid cloud data
|
||||
foreach (var ichimoku in ichimokuList)
|
||||
{
|
||||
// Skip if cloud data is not available (null or 0 values indicate insufficient data)
|
||||
if (!ichimoku.SenkouSpanA.HasValue || !ichimoku.SenkouSpanB.HasValue ||
|
||||
ichimoku.SenkouSpanA.Value == 0 || ichimoku.SenkouSpanB.Value == 0)
|
||||
continue;
|
||||
|
||||
// Find the corresponding candle
|
||||
var candle = candles.FirstOrDefault(c => c.Date == ichimoku.Date);
|
||||
if (candle == null) continue;
|
||||
@@ -143,8 +152,8 @@ public class IchimokuKumoTrend : IndicatorBase
|
||||
Exchange = candle.Exchange,
|
||||
TenkanSen = ichimoku.TenkanSen ?? 0,
|
||||
KijunSen = ichimoku.KijunSen ?? 0,
|
||||
SenkouSpanA = ichimoku.SenkouSpanA ?? 0,
|
||||
SenkouSpanB = ichimoku.SenkouSpanB ?? 0
|
||||
SenkouSpanA = ichimoku.SenkouSpanA.Value,
|
||||
SenkouSpanB = ichimoku.SenkouSpanB.Value
|
||||
});
|
||||
}
|
||||
|
||||
@@ -161,6 +170,10 @@ public class IchimokuKumoTrend : IndicatorBase
|
||||
var previousCandle = mappedData[0];
|
||||
foreach (var currentCandle in mappedData.Skip(1))
|
||||
{
|
||||
// Skip if cloud data is not available (values are 0 due to insufficient data)
|
||||
if (currentCandle.SenkouSpanA == 0 || currentCandle.SenkouSpanB == 0)
|
||||
continue;
|
||||
|
||||
// For trend assessment, check if price is above or below the cloud
|
||||
// The cloud is formed by Senkou Span A and Senkou Span B
|
||||
var cloudTop = Math.Max(currentCandle.SenkouSpanA, currentCandle.SenkouSpanB);
|
||||
@@ -193,6 +206,10 @@ public class IchimokuKumoTrend : IndicatorBase
|
||||
if (candle == null || !currentResult.SenkouSpanA.HasValue || !currentResult.SenkouSpanB.HasValue)
|
||||
continue;
|
||||
|
||||
// Skip if cloud data is not available (values are 0 due to insufficient data)
|
||||
if (currentResult.SenkouSpanA.Value == 0 || currentResult.SenkouSpanB.Value == 0)
|
||||
continue;
|
||||
|
||||
// For trend assessment, check if price is above or below the cloud
|
||||
// The cloud is formed by Senkou Span A and Senkou Span B
|
||||
var cloudTop = Math.Max(currentResult.SenkouSpanA.Value, currentResult.SenkouSpanB.Value);
|
||||
|
||||
Reference in New Issue
Block a user