docs-v2/content/flux/v0.x/stdlib/universe/chandemomentumoscillator.md

2.9 KiB

title description aliases menu weight flux/v0.x/tags related introduced
chandeMomentumOscillator() function The `chandeMomentumOscillator()` function applies the technical momentum indicator developed by Tushar Chande.
/influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/chandemomentumoscillator/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator/
flux_0_x_ref
name parent
chandeMomentumOscillator universe
102
transformations
/{{< latest "influxdb" "v1" >}}/query_language/functions/#triple-exponential-moving-average, InfluxQL CHANDE_MOMENTUM_OSCILLATOR()
0.39.0

The chandeMomentumOscillator() function applies the technical momentum indicator developed by Tushar Chande.

chandeMomentumOscillator(
    n: 10,
    columns: ["_value"],
)

The Chande Momentum Oscillator (CMO) indicator calculates the difference between the sum of all recent data points with values greater than the median value of the data set and the sum of all recent data points with values lower than the median value of the data set, then divides the result by the sum of all data movement over a given time period. It then multiplies the result by 100 and returns a value between -100 and +100.

Parameters

n

The period or number of points to use in the calculation.

columns

The columns to operate on. Defaults to ["_value"].

tables

Input data. Default is piped-forward data (<-).

Output tables

For each input table with x rows, chandeMomentumOscillator() outputs a table with x - n rows.

Examples

Transform data with a two point Chande Momentum Oscillator

{{% flux/sample-example-intro %}}

import "sampledata"

sampledata.int()
    |> chandeMomentumOscillator(n: 2)

{{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}

Input data

{{% flux/sample set="int" %}}

{{% /flex-content %}} {{% flex-content %}}

Output data
_time tag _value
2021-01-01T00:00:20Z t1 60
2021-01-01T00:00:30Z t1 53.84615384615385
2021-01-01T00:00:40Z t1 66.66666666666667
2021-01-01T00:00:50Z t1 -100
_time tag _value
2021-01-01T00:00:20Z t2 -100
2021-01-01T00:00:30Z t2 51.724137931034484
2021-01-01T00:00:40Z t2 57.142857142857146
2021-01-01T00:00:50Z t2 -100

{{% /flex-content %}} {{< /flex >}} {{% /expand %}}