TechnicalIndicatorCharts

Documentation for TechnicalIndicatorCharts.

TechnicalIndicatorCharts.ChartType

Summary

A Chart is a mutable struct that has:

  • a name (typically of the asset like "BTCUSD" or "AAPL")
  • a timeframe (which controls how much time each candle on the chart represents)
  • a DataFrame to hold OHLCV values and indicator values
  • a Vector of OnlineTechnicalIndicators to display on the chart.
  • another Vector of display configuration for each indicator.

If you were to go to TradingView and look at a chart, imagine what kind of data structure would be required to represent it in memory. That's what the Chart struct aims to be.

Fields

  • name::AbstractString

  • tf::Dates.Period

  • indicators::AbstractVector{OnlineTechnicalIndicators.TechnicalIndicator}

  • visuals::AbstractVector

  • df::DataFrames.DataFrame

  • ts::Union{Missing, Dates.DateTime}

  • candle::Union{Missing, Candle}

Constructors

Chart(name, tf; indicators=[], visuals=[])

Examples

julia> just_candles = Chart("ETHUSD", Minute(1))

julia> golden_cross = Chart(
           "BTCUSD", Hour(4);
           indicators = [
               SMA{Float64}(;period=50),
               SMA{Float64}(;period=200)
           ],
           visuals = [
               Dict(
                   :label_name => "SMA 50",
                   :line_color => "#E072A4",
                   :line_width => 2
               ),
               Dict(
                   :label_name => "SMA 200",
                   :line_color => "#3D3B8E",
                   :line_width => 5
               )
           ]
       )

julia> default_visuals = Chart(
           "BNBUSDT", Hour(4);
           indicators = [BB{Float64}(), StochRSI{Float64}()],
           visuals    = [nothing,       nothing]  # To use defaults, pass in `nothing`.
       )
source
TechnicalIndicatorCharts.extract_valueMethod
extract_value(value) -> Vector{Any}

Extract values out of an indicators value struct. This is only intended to be used for indicators that emit multiple values per tick.

source
TechnicalIndicatorCharts.ismultiinputMethod

This is a wrapper around OnlineTechnicalIndicators.ismultiinput that takes any instance of a TechnicalIndicator and digs out its unparametrized type before running the original ismultiinput method.

source
TechnicalIndicatorCharts.ismultioutputMethod

This is a wrapper around OnlineTechnicalIndicators.ismultioutput that takes any instance of a TechnicalIndicator and digs out its unparametrized type before running the original ismultioutput method.

source
TechnicalIndicatorCharts.merge_candle!Method
merge_candle!(
    last_candle::Union{Missing, Candle},
    c::Union{Candle, DataFrames.DataFrameRow}
) -> Candle

If last candle is not provided, construct a new candle with the given OHLCV data. If last candle is provided, mutate last_candle such that it's HLCV are updated. When tw candles are passed in, it's assumed they have the same timestamp.

source
TechnicalIndicatorCharts.push_new_candle!Method
push_new_candle!(
    chart::Chart,
    c::Candle
) -> DataFrames.DataFrame

This is meant to be called on timeframe boundaries to onto the chart's dataframe. It also does indicator calculation at this time.

source
TechnicalIndicatorCharts.update!Method
update!(chart::Chart, c::Candle) -> Union{Nothing, Candle}

Update a chart with a candle. When a candle is completed, return it. Otherwise, return nothing on update.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    unimplemented,
    opts,
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

This is a visualize method that's a catch-all for indicators that haven't had a visualize method made for them yet. For now, it returns missing.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    chart::Chart;
    min_height,
    mode,
    up_color,
    down_color,
    copyright
) -> LightweightCharts.LWCLayout

Return an LWCLayout that visualizes all the components in chart appropriately.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    alma::OnlineTechnicalIndicators.ALMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize ALMA using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    atr::OnlineTechnicalIndicators.ATR,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize ATR using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    bb::OnlineTechnicalIndicators.BB,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> Vector{LightweightCharts.LWCChart}

Visualize Bollinger Bands using 3 lwc_lines.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    dema::OnlineTechnicalIndicators.DEMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize DEMA using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    ema::OnlineTechnicalIndicators.EMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize EMA using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    hma::OnlineTechnicalIndicators.HMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize HMA using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    keltnerchannels::OnlineTechnicalIndicators.KeltnerChannels,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> Vector{LightweightCharts.LWCChart}

Visualize Keltner Channels (KC) using 3 lwc_lines.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    mcginleydynamic::OnlineTechnicalIndicators.McGinleyDynamic,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize McGinleyDynamic using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    obv::OnlineTechnicalIndicators.OBV,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize On Balance Volume (OBV) using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    rsi::OnlineTechnicalIndicators.RSI,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize RSI using 1 lwc_line.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    sma::OnlineTechnicalIndicators.SMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Return an lwc_line for visualizing an SMA indicator.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    SMMA::OnlineTechnicalIndicators.SMMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Return an lwc_line for visualizing an SMMA indicator.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    srsi::OnlineTechnicalIndicators.StochRSI,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> Vector{LightweightCharts.LWCChart}

Visualize StochRSI using 2 lwc_lines.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    tsi::OnlineTechnicalIndicators.TSI,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize True Strength Index (TSI) using 1 lwc_line. Note that on TradingView, TSI includes a second signal line that is not included here.

source
TechnicalIndicatorCharts.visualizeMethod
visualize(
    wma::OnlineTechnicalIndicators.WMA,
    opts::Union{Nothing, AbstractDict},
    df::DataFrames.DataFrame
) -> LightweightCharts.LWCChart

Visualize WMA using 1 lwc_line.

source