Skip to content

Commit

Permalink
Implement visualization for ALMA
Browse files Browse the repository at this point in the history
>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.
  • Loading branch information
g-gundam committed Dec 22, 2024
1 parent 970c7fe commit fec1267
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
23 changes: 23 additions & 0 deletions src/ALMA.jl
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/TechnicalIndicatorCharts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ function visualize(chart::Chart;
)
end

include("ALMA.jl")
include("ATR.jl")
include("BB.jl")
include("DEMA.jl")
Expand Down
18 changes: 18 additions & 0 deletions test/ALMA.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fec1267

Please sign in to comment.