Update BB volume protection

This commit is contained in:
2025-11-25 12:04:26 +07:00
parent 4b5c1c5ce0
commit 3802187155
2 changed files with 48 additions and 17 deletions

View File

@@ -34,29 +34,30 @@ public class BollingerBandsVolatilityProtection : BollingerBandsBase
// Determine confidence based on width levels (bandwidth as % of SMA)
// Lower width = less volatility = higher confidence for trading
// Higher width = more volatility = lower confidence for trading
// Typical BB bandwidth values: 0.01-0.08 for most markets
Confidence confidence;
if (width >= 0.15) // Extremely high volatility - dangerous expansion
if (width >= 0.06) // High volatility - dangerous expansion (6%+)
{
// Block all signals during dangerous volatility expansion
confidence = Confidence.None;
}
else if (width <= 0.02) // Extremely low volatility - dead market/squeeze
else if (width <= 0.01) // Extremely low volatility - dead market/squeeze (1% or less)
{
// Block all signals in dead markets or extreme squeezes
confidence = Confidence.None;
}
else if (width <= 0.05) // Low to normal volatility - good for trading
else if (width <= 0.025) // High confidence - optimal for trading (1% - 2.5%)
{
// Validate signals during low volatility trending conditions
confidence = Confidence.High;
}
else if (width <= 0.10) // Normal volatility - acceptable for trading
else if (width <= 0.035) // Medium confidence - acceptable for trading (2.5% - 3.5%)
{
// Validate signals during normal volatility conditions
confidence = Confidence.Medium;
}
else // Moderate high volatility (0.10 - 0.15)
else // Moderate high volatility (3.5% - 6%)
{
// Lower confidence during elevated but not extreme volatility
confidence = Confidence.Low;

View File

@@ -658,13 +658,13 @@ const TradeChart = ({
// @ts-ignore
volatilityWidthSeries.setData(volatilityWidthData)
// Add confidence range lines (0.02 - 0.10)
const confidenceMinLine = chart.current.addLineSeries({
color: '#16A34A', // Green for confidence range minimum
// Add confidence range lines with clear range indicators
const highConfidenceMinLine = chart.current.addLineSeries({
color: '#16A34A', // Green for high confidence zone
lineWidth: 1,
priceLineVisible: true,
priceLineWidth: 1,
title: 'Conf Min (2%)',
title: 'High: 1% → 2.5%',
pane: paneCount,
lineStyle: LineStyle.Dashed,
priceFormat: {
@@ -674,12 +674,27 @@ const TradeChart = ({
},
})
const highMediumThresholdLine = chart.current.addLineSeries({
color: '#CA8A04', // Yellow/Amber to separate High from Medium confidence
lineWidth: 1,
priceLineVisible: true,
priceLineWidth: 1,
title: 'Medium: 2.5% → 3.5%',
pane: paneCount,
lineStyle: LineStyle.Dotted,
priceFormat: {
minMove: 0.001,
precision: 3,
type: 'price',
},
})
const confidenceMaxLine = chart.current.addLineSeries({
color: '#16A34A', // Green for confidence range maximum
lineWidth: 1,
priceLineVisible: true,
priceLineWidth: 1,
title: 'Conf Max (10%)',
title: 'Max: 3.5%',
pane: paneCount,
lineStyle: LineStyle.Dashed,
priceFormat: {
@@ -689,30 +704,45 @@ const TradeChart = ({
},
})
// Create horizontal lines for confidence range
// Create horizontal lines for confidence zones
// High confidence: 1% - 2.5%
// Medium confidence: 2.5% - 3.5%
const bollingerBands = indicatorsValues.BollingerBandsVolatilityProtection.bollingerBands
if (bollingerBands && bollingerBands.length > 0) {
const confidenceMinData = [
const highConfidenceMinData = [
{
time: moment(bollingerBands[0].date).unix(),
value: 0.02, // Confidence minimum threshold
value: 0.01, // High confidence minimum threshold (1%)
},
{
time: moment(bollingerBands[bollingerBands.length - 1].date).unix(),
value: 0.02, // Confidence minimum threshold
value: 0.01, // High confidence minimum threshold (1%)
}
]
// @ts-ignore
confidenceMinLine.setData(confidenceMinData)
highConfidenceMinLine.setData(highConfidenceMinData)
const highMediumThresholdData = [
{
time: moment(bollingerBands[0].date).unix(),
value: 0.025, // High/Medium confidence threshold (2.5%)
},
{
time: moment(bollingerBands[bollingerBands.length - 1].date).unix(),
value: 0.025, // High/Medium confidence threshold (2.5%)
}
]
// @ts-ignore
highMediumThresholdLine.setData(highMediumThresholdData)
const confidenceMaxData = [
{
time: moment(bollingerBands[0].date).unix(),
value: 0.10, // Confidence maximum threshold
value: 0.035, // Confidence maximum threshold (3.5%)
},
{
time: moment(bollingerBands[bollingerBands.length - 1].date).unix(),
value: 0.10, // Confidence maximum threshold
value: 0.035, // Confidence maximum threshold (3.5%)
}
]
// @ts-ignore