Skip to content

Commit 2449c1d

Browse files
committed
build fix.
1 parent 5781023 commit 2449c1d

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

Samples/06_Strategies/02_HistoryBollingerBands/BollingerStrategyClassicStrategy.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override void OnStarted(DateTimeOffset time)
7070
// Create subscription and bind indicator
7171
var subscription = SubscribeCandles(CandleType);
7272
subscription
73-
.Bind(_bollingerBands, ProcessCandle)
73+
.BindEx(_bollingerBands, ProcessCandle)
7474
.Start();
7575

7676
// Setup chart visualization if available
@@ -83,7 +83,7 @@ protected override void OnStarted(DateTimeOffset time)
8383
}
8484
}
8585

86-
private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal upperBand, decimal lowerBand)
86+
private void ProcessCandle(ICandleMessage candle, IIndicatorValue bollingerValue)
8787
{
8888
// Skip unfinished candles
8989
if (candle.State != CandleStates.Finished)
@@ -93,14 +93,16 @@ private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal up
9393
if (!IsFormedAndOnlineAndAllowTrading())
9494
return;
9595

96+
var typed = (BollingerBandsValue)bollingerValue;
97+
9698
// Trading logic:
9799
// Sell when price is at or above the upper band
98-
if (candle.ClosePrice >= upperBand && Position >= 0)
100+
if (candle.ClosePrice >= typed.UpBand && Position >= 0)
99101
{
100102
SellMarket(Volume + Math.Abs(Position));
101103
}
102104
// Buy when price is at or below the lower band
103-
else if (candle.ClosePrice <= lowerBand && Position <= 0)
105+
else if (candle.ClosePrice <= typed.LowBand && Position <= 0)
104106
{
105107
BuyMarket(Volume + Math.Abs(Position));
106108
}

Samples/06_Strategies/02_HistoryBollingerBands/BollingerStrategyLowBandStrategy.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override void OnStarted(DateTimeOffset time)
7070
// Create subscription and bind indicator
7171
var subscription = SubscribeCandles(CandleType);
7272
subscription
73-
.Bind(_bollingerBands, ProcessCandle)
73+
.BindEx(_bollingerBands, ProcessCandle)
7474
.Start();
7575

7676
// Setup chart visualization if available
@@ -83,7 +83,7 @@ protected override void OnStarted(DateTimeOffset time)
8383
}
8484
}
8585

86-
private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal upperBand, decimal lowerBand)
86+
private void ProcessCandle(ICandleMessage candle, IIndicatorValue bollingerValue)
8787
{
8888
// Skip unfinished candles
8989
if (candle.State != CandleStates.Finished)
@@ -93,14 +93,16 @@ private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal up
9393
if (!IsFormedAndOnlineAndAllowTrading())
9494
return;
9595

96+
var typed = (BollingerBandsValue)bollingerValue;
97+
9698
// Trading logic:
9799
// Sell when price touches the lower band (only when no position)
98-
if (candle.ClosePrice <= lowerBand && Position == 0)
100+
if (candle.ClosePrice <= typed.LowBand && Position == 0)
99101
{
100102
SellMarket(Volume);
101103
}
102104
// Buy to close position when price reaches the middle band (only when short)
103-
else if (candle.ClosePrice >= middleBand && Position < 0)
105+
else if (candle.ClosePrice >= typed.MovingAverage && Position < 0)
104106
{
105107
BuyMarket(Math.Abs(Position));
106108
}

Samples/06_Strategies/02_HistoryBollingerBands/BollingerStrategyUpBandStrategy.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override void OnStarted(DateTimeOffset time)
7070
// Create subscription and bind indicator
7171
var subscription = SubscribeCandles(CandleType);
7272
subscription
73-
.Bind(_bollingerBands, ProcessCandle)
73+
.BindEx(_bollingerBands, ProcessCandle)
7474
.Start();
7575

7676
// Setup chart visualization if available
@@ -83,7 +83,7 @@ protected override void OnStarted(DateTimeOffset time)
8383
}
8484
}
8585

86-
private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal upperBand, decimal lowerBand)
86+
private void ProcessCandle(ICandleMessage candle, IIndicatorValue bollingerValue)
8787
{
8888
// Skip unfinished candles
8989
if (candle.State != CandleStates.Finished)
@@ -93,14 +93,16 @@ private void ProcessCandle(ICandleMessage candle, decimal middleBand, decimal up
9393
if (!IsFormedAndOnlineAndAllowTrading())
9494
return;
9595

96+
var typed = (BollingerBandsValue)bollingerValue;
97+
9698
// Trading logic:
9799
// Buy when price touches the upper band (only when no position)
98-
if (candle.ClosePrice >= upperBand && Position == 0)
100+
if (candle.ClosePrice >= typed.UpBand && Position == 0)
99101
{
100102
BuyMarket(Volume);
101103
}
102104
// Sell to close position when price reaches the middle band (only when long)
103-
else if (candle.ClosePrice <= middleBand && Position > 0)
105+
else if (candle.ClosePrice <= typed.MovingAverage && Position > 0)
104106
{
105107
SellMarket(Math.Abs(Position));
106108
}

0 commit comments

Comments
 (0)