Add series, SMA, and WMA indicators
Introduce new indicators for Simple Moving Average (SMA) and Weighted Moving Average (WMA), along with their Hull Moving Average (HMA) derivative. Also refactors series implementation to use `RefCell` for interior mutability and adds `SeriesMember` trait for better dynamic series access. Updates `soa_series.myc` example to reflect new series creation and push syntax.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
;; advanced.myc
|
||||
|
||||
;; Hull Moving Average
|
||||
;; Formula: WMA(2 * WMA(n/2) - WMA(n), sqrt(n))
|
||||
(def HMA (fn [len]
|
||||
(do
|
||||
;; Create inner WMA instances
|
||||
(def wma_half (WMA (/ len 2)))
|
||||
(def wma_full (WMA len))
|
||||
;; Create outer WMA instance
|
||||
;; Note: sqrt is a native RTL function
|
||||
(def wma_outer (WMA (sqrt len)))
|
||||
|
||||
(fn [val]
|
||||
(do
|
||||
(def v_half (wma_half val))
|
||||
(def v_full (wma_full val))
|
||||
(def diff (- (* 2 v_half) v_full))
|
||||
(wma_outer diff))))))
|
||||
Reference in New Issue
Block a user