56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FinlyticCore.Dtos.TechnicalAnalysis;
|
|
|
|
namespace FinlyticTechnicals.Patterns.SmartMoney;
|
|
|
|
/// <summary>
|
|
/// Detects institutional Bearish Order Blocks (last bullish candle before a strong downward displacement).
|
|
/// </summary>
|
|
public class BearishOrderBlockDetector : IPatternDetector
|
|
{
|
|
/// <inheritdoc />
|
|
public PatternType HandledType => PatternType.OrderBlock;
|
|
|
|
/// <inheritdoc />
|
|
public PatternCategory Category => PatternCategory.SmartMoney;
|
|
|
|
/// <inheritdoc />
|
|
public PatternResultDto? Evaluate(TechnicalContext context)
|
|
{
|
|
var candles = context.PrimaryCandles;
|
|
if (candles.Count < 5) return null;
|
|
|
|
var obCandle = candles[^3];
|
|
var impulse1 = candles[^2];
|
|
var impulse2 = candles.Last();
|
|
|
|
// Bearish Order Block: Green candle followed by 2 strong red candles that drop price > 1.5 ATR
|
|
if (obCandle.Close > obCandle.Open && impulse1.Close < impulse1.Open && impulse2.Close < impulse2.Open)
|
|
{
|
|
decimal displacement = obCandle.High - impulse2.Close;
|
|
if (displacement >= context.CurrentAtr * 1.5m)
|
|
{
|
|
return new PatternResultDto(
|
|
Id: Guid.NewGuid(),
|
|
Type: PatternType.OrderBlock,
|
|
Category: PatternCategory.SmartMoney,
|
|
Bias: PatternBias.Bearish,
|
|
Name: "Bearish Institutional Order Block",
|
|
Timeframe: context.Timeframe,
|
|
DetectedAt: impulse2.Timestamp,
|
|
KeyPriceLevel: (obCandle.Open + obCandle.Close) / 2m,
|
|
UpperBoundary: obCandle.High,
|
|
LowerBoundary: obCandle.Low,
|
|
InvalidationLevel: obCandle.High * 1.005m,
|
|
QualityScore: 86m,
|
|
Description: $"Bearish order block zone [{obCandle.Low:F2} - {obCandle.High:F2}] with strong downward displacement."
|
|
);
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|