From fec1267e009c69582a65745eba28d9b63290c3d6 Mon Sep 17 00:00:00 2001 From: g-gundam Date: Sun, 22 Dec 2024 00:50:26 -0800 Subject: [PATCH] Implement visualization for ALMA >Legoux claimed the ALMA moving average was inspired significantly by >the Gaussian Filter and often compares his developed moving average >to the Hull Moving Average (HMA), which is said to be outperformed by >the ALMA in effectiveness and smoothness. I love the Hull Moving Average, so I had to see what ALMA had to offer. My initial impression is positive. --- README.md | 2 +- src/ALMA.jl | 23 +++++++++++++++++++++++ src/TechnicalIndicatorCharts.jl | 1 + test/ALMA.jl | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/ALMA.jl create mode 100644 test/ALMA.jl diff --git a/README.md b/README.md index aafb3d1..c420ebc 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ golden_cross_chart |> visualize |> lwc_show - [ ] AccuDist - [ ] ADX -- [ ] ALMA +- [x] [ALMA](https://www.tradingview.com/support/solutions/43000594683-arnaud-legoux-moving-average/) - [ ] AO - [ ] Aroon - [x] [ATR](https://www.tradingview.com/support/solutions/43000501823-average-true-range-atr/) diff --git a/src/ALMA.jl b/src/ALMA.jl new file mode 100644 index 0000000..7ea6688 --- /dev/null +++ b/src/ALMA.jl @@ -0,0 +1,23 @@ +denominated_price(alma::ALMA) = true + +"""$(TYPEDSIGNATURES) + +Return an lwc_line for visualizing an ALMA indicator. +""" +function visualize(alma::ALMA, opts::Union{AbstractDict,Nothing}, df::DataFrame) + name = indicator_fields(alma)[1] + start = findfirst(!ismissing, df[!, name]) + kwargs = Dict( + :label_name => "ALMA $(alma.period)", + :line_color => "#5B9CF6", + :line_width => 2 + ) + if opts !== nothing + merge!(kwargs, opts) + end + return lwc_line( + df.ts[start:end], + [df[!, name][start:end]...]; + kwargs... + ) +end diff --git a/src/TechnicalIndicatorCharts.jl b/src/TechnicalIndicatorCharts.jl index 8870c65..b905094 100644 --- a/src/TechnicalIndicatorCharts.jl +++ b/src/TechnicalIndicatorCharts.jl @@ -485,6 +485,7 @@ function visualize(chart::Chart; ) end +include("ALMA.jl") include("ATR.jl") include("BB.jl") include("DEMA.jl") diff --git a/test/ALMA.jl b/test/ALMA.jl new file mode 100644 index 0000000..8202378 --- /dev/null +++ b/test/ALMA.jl @@ -0,0 +1,18 @@ +using TechnicalIndicatorCharts + +@testset "ALMA" begin + if !isdefined(Main, :sample_candles) + include("helper/main.jl") + end + chart = Chart( + "TEST", Minute(1), + indicators=[ALMA{Float64}(;period=5)], + visuals=[nothing] + ) + candles = sample_candles() + for c in candles + update!(chart, c) + end + @test visualize(chart) isa Any + # If it gets this far, we can instantiate, update, and visualize. +end