ReversedSeries
Documentation for ReversedSeries.
ReversedSeries.Reversed
ReversedSeries.ReversedFrame
Base.getindex
Base.getproperty
ReversedSeries.crossed_down
ReversedSeries.crossed_down_currently
ReversedSeries.crossed_up
ReversedSeries.crossed_up_currently
ReversedSeries.find_clusters
ReversedSeries.find_index
ReversedSeries.find_local_high
ReversedSeries.find_local_low
ReversedSeries.high_enough_fn
ReversedSeries.low_enough_fn
ReversedSeries.negative_slope_currently
ReversedSeries.percent_change
ReversedSeries.percent_difference
ReversedSeries.positive_slope_currently
ReversedSeries.regular_bearish_divergence
ReversedSeries.regular_bullish_divergence
ReversedSeries.Reversed
— Typestruct 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
ReversedSeries.ReversedFrame
— Typestruct 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.
Base.getindex
— Methodgetindex(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
Base.getproperty
— Methodgetproperty(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
ReversedSeries.crossed_down
— Methodcrossed_down(a, b; i) -> Any
Did series a become less than series b at index i.
ReversedSeries.crossed_down_currently
— Methodcrossed_down_currently(a, b; i) -> Any
Is series a
currently less than series b
?
ReversedSeries.crossed_up
— Methodcrossed_up(a, b; i) -> Any
Did series a become greater than series b at index i.
ReversedSeries.crossed_up_currently
— Methodcrossed_up_currently(a, b; i) -> Any
Is series a
currently greater than series b
?
ReversedSeries.find_clusters
— Methodfind_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.
ReversedSeries.find_index
— Methodfind_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.
ReversedSeries.find_local_high
— Methodfind_local_high(rf, cluster; close) -> Any
Out of the cluster, which index had the highest close?
ReversedSeries.find_local_low
— Methodfind_local_low(rf, cluster; close) -> Any
Out of the cluster, which index had the lowest close?
ReversedSeries.high_enough_fn
— Methodhigh_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
ReversedSeries.low_enough_fn
— Methodlow_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
ReversedSeries.negative_slope_currently
— Methodnegative_slope_currently(a; i, back) -> Any
Return true if a is currently sloping down. In other words, a[i] < a[i+back]
.
ReversedSeries.percent_change
— Methodpercent_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
.
ReversedSeries.percent_difference
— Methodpercent_difference(a, b; i) -> Any
Return the percent difference between a[i]
and b[i]
. If either value is missing, return missing
.
ReversedSeries.positive_slope_currently
— Methodpositive_slope_currently(a; i, back) -> Any
Return true if a is currently sloping up. In other words, a[i] > a[i+back]
.
ReversedSeries.regular_bearish_divergence
— Methodregular_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
argument | default | description |
---|---|---|
indicator | :rsi14 | Name in rf for the indicator being tested |
high | :h | Name in rf for he OHLCV high value |
upper | :bb_upper | Name in rf for the upper band of the BBs |
lower | :bb_lower | Name in rf for the lower band of the BBs |
age_threshold | 1 | ? |
gap_threshold | (7,30) | ? |
peak_threshold | 9.0 | ? |
Example
julia> regular_bearish_divergence(rf)
ReversedSeries.regular_bullish_divergence
— Methodregular_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
argument | default | description |
---|---|---|
indicator | :rsi14 | Name in rf for the indicator being tested |
low | :l | Name in rf for he OHLCV high value |
upper | :bb_upper | Name in rf for the upper band of the BBs |
lower | :bb_lower | Name in rf for the lower band of the BBs |
age_threshold | 1 | ? |
gap_threshold | (7,30) | ? |
peak_threshold | 9.0 | ? |
Example
julia> regular_bearish_divergence(rf)