831525b402
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.
20 lines
517 B
Plaintext
20 lines
517 B
Plaintext
;; 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))))))
|