pub struct KeltnerChannel { /* private fields */ }Expand description
Keltner Channel (KC).
A Keltner Channel is an indicator showing the Average True Range (ATR) of a price surrounding a central moving average. The ATR bands are typically shown ‘k’ times moved away from the moving average.
§Formula
See EMA, ATR documentation.
KC is composed as:
- KCMiddle Band - Exponential Moving Average (EMA).
- KCUpper Band = EMA + ATR of observation * multipler (usually 2.0)
- KCLower Band = EMA - ATR of observation * multipler (usually 2.0)
§Example
use ta::indicators::{KeltnerChannel, KeltnerChannelOutput};
use ta::Next;
let mut kc = KeltnerChannel::new(3, 2.0_f64).unwrap();
let out_0 = kc.next(2.0);
let out_1 = kc.next(5.0);
assert_eq!(out_0.average, 2.0);
assert_eq!(out_0.upper, 2.0);
assert_eq!(out_0.lower, 2.0);
assert_eq!(out_1.average, 3.5);
assert_eq!(out_1.upper, 6.5);
assert_eq!(out_1.lower, 0.5);§Links
Implementations§
Trait Implementations§
Source§impl Clone for KeltnerChannel
impl Clone for KeltnerChannel
Source§fn clone(&self) -> KeltnerChannel
fn clone(&self) -> KeltnerChannel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeltnerChannel
impl Debug for KeltnerChannel
Source§impl Default for KeltnerChannel
impl Default for KeltnerChannel
Source§impl Display for KeltnerChannel
impl Display for KeltnerChannel
Source§impl Next<f64> for KeltnerChannel
impl Next<f64> for KeltnerChannel
Auto Trait Implementations§
impl Freeze for KeltnerChannel
impl RefUnwindSafe for KeltnerChannel
impl Send for KeltnerChannel
impl Sync for KeltnerChannel
impl Unpin for KeltnerChannel
impl UnwindSafe for KeltnerChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more