Candlestick Pattern

Counterattack

Introduction

Create a new Counterattack candlestick pattern to indicate the pattern's presence.

Create Manual Indicators

A candlestick pattern indicator requires manual creation and update with a TradeBar object. Manual indicators let you update their values with any data you choose. The following reference table describes the Counterattack constructor.

Counterattack()1/2

            Counterattack QuantConnect.Indicators.CandlestickPatterns.Counterattack (
     string  name
   )
        

Initializes a new instance of the Counterattack class using the specified name.

Counterattack()2/2

            Counterattack QuantConnect.Indicators.CandlestickPatterns.Counterattack (
   )
        

Initializes a new instance of the Counterattack class.

Update Manual Indicators

You can update the indicator automatically or manually.

Automatic Update

To register a manual indicator for automatic updates with the security data, call the RegisterIndicator method.

using QuantConnect.Indicators.CandlestickPatterns;

private Counterattack _counterattack;

// In Initialize()
_counterattack = new Counterattack(name);
_counterattack.Updated += IndicatorUpdateMethod;

RegisterIndicator(symbol, _counterattack, Resolution.Daily);

// In IndicatorUpdateMethod()
if (_counterattack.IsReady)
{
    var indicatorValue = _counterattack.Current.Value;
}
from QuantConnect.Indicators.CandlestickPatterns import Counterattack
    
# In Initialize()
self.counterattack = Counterattack(name)
self.counterattack.Updated += self.IndicatorUpdateMethod

self.RegisterIndicator(symbol, self.counterattack, Resolution.Daily)

# In IndicatorUpdateMethod()
if self.counterattack.IsReady:
    indicator_value = self.counterattack.Current.Value

To customize the data that automatically updates the indicator, see Custom Indicator Periods and Custom Indicator Values.

Manual Update

Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update method with a TradeBar. The indicator will only be ready after you prime it with enough data.

using QuantConnect.Indicators.CandlestickPatterns;
    
private Counterattack _counterattack;
private Symbol symbol;

// In Initialize()
_counterattack = new Counterattack();
symbol = AddEquity("SPY").Symbol;

// In OnData()
if (data.Bars.ContainsKey(_symbol))
{
    _counterattack.Update(data.Bars[symbol]);
}
if (_counterattack.IsReady)
{
    var indicatorValue = _counterattack.Current.Value;
}
from QuantConnect.Indicators.CandlestickPatterns import Counterattack
    
# In Initialize()
self.counterattack = Counterattack()
self.symbol = self.AddEquity("SPY").Symbol

# In OnData()
if data.Bars.ContainsKey(self.symbol):
    self.counterattack.Update(data.Bars[self.symbol])
if self.counterattack.IsReady:
    indicator_value = self.counterattack.Current.Value

Get Indicator Values

To get the value of the indicator, use its Current.Value attribute.

private Counterattack _counterattack;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_counterattack = Counterattack(symbol);

// In OnData()
if (_counterattack.IsReady)
{
    var current = _counterattack.Current.Value;
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.counterattack = self.Counterattack(symbol)

# In OnData()
if self.counterattack.IsReady:
    current = self.counterattack.Current.Value

Visualization

To plot indicator values, in the OnData event handler, call the Plot method.

private Counterattack _counterattack;

// In Initialize()
var symbol = AddEquity("SPY").Symbol;
_counterattack = Counterattack(symbol);

// In OnData()
if (_counterattack.IsReady)
{
    Plot("My Indicators", "counterattack", _counterattack.Current);
}
# In Initialize()
symbol = self.AddEquity("SPY").Symbol
self.counterattack = self.Counterattack(symbol)

# In OnData()
if self.counterattack.IsReady:
    self.Plot("My Indicators", "counterattack", self.counterattack.Current)

For more information about plotting indicators, see Plotting Indicators.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: