ReversedSeries

Documentation for ReversedSeries.

ReversedSeries.ReversedType
struct Reversed{T<:AbstractArray}
  • A::AbstractArray

This presents a reversed view of anything array-like.

Credit: @simsurace

Example

julia> a = [1, 2, 3]
julia> r = Reversed(a)
julia> r[1]
3
julia> r[3]
1
julia> a[end] == r[1]
true
source
ReversedSeries.ReversedFrameType
struct ReversedFrame{df<:DataFrames.DataFrame}
  • __df::DataFrames.DataFrame

  • __s::Dict

This presents a reversed view of an entire DataFrame.

Example

julia> rf = ReversedFrame(btcusd) # btcusd is a DataFrame
julia> rf.ts[1] # the most recent timestamp
julia> rf.ts[2] # the timestamp before that
julia> rf.c[1]  # the close at 1 corresponds with the timestamp at 1
julia> rf.o[1] == btcusd.o[end]
true
  • Index 1 is the origin and represents the present time.
  • Higher indices go back in time.
  • This is similar to how series are indexed in TradingView's PineScript except they use a 0-based index.
source
Base.getindexMethod
getindex(rf::ReversedFrame, k::Symbol) -> Any

Return a reversed view of a DataFrame column via indexing.

Example

julia> rf = ReversedFrame(DataFrame(o=[1,2,3]))
julia> rf[:o]
Reversed{Vector{Int64}}([1, 2, 3])

julia> rf[:o][1]
3
source
Base.getpropertyMethod
getproperty(rf::ReversedFrame, k::Symbol) -> Any

Return a reversed view of a DataFrame column via key.

Example

julia> rf = ReversedFrame(DataFrame(o=[1,2,3]))
julia> rf.o
Reversed{Vector{Int64}}([1, 2, 3])

julia> rf.o[1]
3
source
ReversedSeries.find_clustersMethod
find_clusters(
    rf::ReversedFrame,
    max::Integer,
    fn::Function;
    close
) -> Vector{Any}

Return a vector of vector of indices of consecutive candles that satisfy the given function.

source
ReversedSeries.find_indexMethod
find_index(
    collection::AbstractArray,
    testfn::Function
) -> Any

Given a collection and a test function, return the index of the first item that returns true for testfn(collection[i]). If nothing is found, return missing. This is a port of JavaScript's Array.prototype.findIndex.

source
ReversedSeries.high_enough_fnMethod
high_enough_fn(
    threshold::AbstractFloat;
    high,
    upper,
    lower
) -> ReversedSeries.var"#5#6"{Symbol, Symbol, Symbol, <:AbstractFloat}

Return a function that tries to find highs by their proximity to the BB upper bands

source
ReversedSeries.low_enough_fnMethod
low_enough_fn(
    threshold::AbstractFloat;
    low,
    upper,
    lower
) -> ReversedSeries.var"#2#3"{Symbol, Symbol, Symbol, <:AbstractFloat}

Return a function that tries to find lows by their proximity to the BB lower bands

source
ReversedSeries.percent_changeMethod
percent_change(a; i, back) -> Any

Return the percent change of series a the previous value to the current value. If you want to compare the current value to a value further in the past, increase the value of back.

source
ReversedSeries.regular_bearish_divergenceMethod
regular_bearish_divergence(
    rf::ReversedFrame;
    indicator,
    high,
    upper,
    lower,
    age_threshold,
    gap_threshold,
    peak_threshold
) -> Any

Return true if regular bearish divergence on the given indicator was detected near index 1. Note that Bollinger Bands are used to help detect divergence, so their presence is required in the rf in addition to the indicator that's being tested for divergence.

Keyword Arguments

argumentdefaultdescription
indicator:rsi14Name in rf for the indicator being tested
high:hName in rf for he OHLCV high value
upper:bb_upperName in rf for the upper band of the BBs
lower:bb_lowerName in rf for the lower band of the BBs
age_threshold1?
gap_threshold(7,30)?
peak_threshold9.0?

Example

julia> regular_bearish_divergence(rf)
source
ReversedSeries.regular_bullish_divergenceMethod
regular_bullish_divergence(
    rf::ReversedFrame;
    indicator,
    low,
    upper,
    lower,
    age_threshold,
    gap_threshold,
    peak_threshold
) -> Any

Return true if regular bullish divergence on the given indicator was detected near index 1. Note that Bollinger Bands are used to help detect divergence, so their presence is required in the rf in addition to the indicator that's being tested for divergence.

Keyword Arguments

argumentdefaultdescription
indicator:rsi14Name in rf for the indicator being tested
low:lName in rf for he OHLCV high value
upper:bb_upperName in rf for the upper band of the BBs
lower:bb_lowerName in rf for the lower band of the BBs
age_threshold1?
gap_threshold(7,30)?
peak_threshold9.0?

Example

julia> regular_bearish_divergence(rf)
source