Skip to content

Commit

Permalink
Implement visualization for DEMA
Browse files Browse the repository at this point in the history
  • Loading branch information
g-gundam committed Dec 19, 2024
1 parent 318c8c7 commit 93bbbc7
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 @@ -88,7 +88,7 @@ golden_cross_chart |> visualize |> lwc_show
- [ ] ChandeKrollStop
- [ ] CHOP
- [ ] CoppockCurve
- [ ] DEMA
- [x] DEMA
- [ ] DonchianChannels
- [ ] DPO
- [x] EMA
Expand Down
23 changes: 23 additions & 0 deletions src/DEMA.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
denominated_price(dema::DEMA) = true

"""$(TYPEDSIGNATURES)
Visualize DEMA using 1 lwc_line.
"""
function visualize(dema::DEMA, opts::Union{AbstractDict,Nothing}, df::DataFrame)
name = indicator_fields(dema)[1]
start = findfirst(!ismissing, df[!, name])
kwargs = Dict(
:label_name => "DEMA $(dema.period)",
:line_color => "#058ED9",
: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 @@ -478,6 +478,7 @@ function visualize(chart::Chart;
end

include("BB.jl")
include("DEMA.jl")
include("EMA.jl")
include("HMA.jl")
include("RSI.jl")
Expand Down
18 changes: 18 additions & 0 deletions test/DEMA.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using TechnicalIndicatorCharts

@testset "DEMA" begin
if !isdefined(Main, :sample_candles)
include("helper/main.jl")
end
chart = Chart(
"TEST", Minute(1),
indicators=[DEMA{Float64}(;period=8)],
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 93bbbc7

Please sign in to comment.