Detrend
DetrendOscillator
Bases: IndicatorBase
Detrend Oscillator indicator.
Measures the spread between two smoothed price estimates (short and long horizon moving averages): Detrend(t) = SMA_short(t) - SMA_long(t)
This construction removes the slow-moving trend component and leaves a zero-centered oscillation.
The rolling windows are maintained independently for each symbol.
Until both windows are fully populated, the indicator yields numpy.nan.
name
property
Canonical indicator name.
Returns:
| Type | Description |
|---|---|
str
|
Stable identifier for the Detrend Oscillator. |
Source code in src/onesecondtrader/indicators/oscillators/detrend.py
__init__(short_period=3, long_period=7, max_history=100, bar_field=models.BarField.CLOSE, plot_at=99, plot_as=models.PlotStyle.LINE, plot_color=models.PlotColor.BLACK)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
short_period
|
int
|
Window size for the short-horizon moving average. |
3
|
long_period
|
int
|
Window size for the long-horizon moving average. |
7
|
max_history
|
int
|
Maximum number of computed indicator values retained per symbol. |
100
|
bar_field
|
BarField
|
Bar field used as the input series. |
CLOSE
|
plot_at
|
int
|
Opaque plotting identifier forwarded to the charting backend. |
99
|
plot_as
|
PlotStyle
|
Visual style used to render the indicator. |
LINE
|
plot_color
|
PlotColor
|
Color used to render the indicator. |
BLACK
|
Source code in src/onesecondtrader/indicators/oscillators/detrend.py
_compute_indicator(incoming_bar)
Compute the detrend oscillator for a single received bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incoming_bar
|
BarReceived
|
Market bar used as input for the computation. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Detrend oscillator value, or |
Source code in src/onesecondtrader/indicators/oscillators/detrend.py
_extract_field(incoming_bar)
Extract the configured bar field from an incoming bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
incoming_bar
|
BarReceived
|
Market bar providing the input data. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Extracted field value, or |