ReversedSeries
Documentation for ReversedSeries.
ReversedSeries.ReversedReversedSeries.ReversedFrameBase.getindexBase.getpropertyReversedSeries.crossed_downReversedSeries.crossed_down_currentlyReversedSeries.crossed_upReversedSeries.crossed_up_currentlyReversedSeries.find_clustersReversedSeries.find_indexReversedSeries.find_local_highReversedSeries.find_local_lowReversedSeries.high_enough_fnReversedSeries.low_enough_fnReversedSeries.negative_slope_currentlyReversedSeries.percent_changeReversedSeries.percent_differenceReversedSeries.positive_slope_currentlyReversedSeries.regular_bearish_divergenceReversedSeries.regular_bullish_divergence
ReversedSeries.Reversed — Type
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]
trueReversedSeries.ReversedFrame — Type
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.
Base.getindex — Method
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]
3Base.getproperty — Method
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
ReversedSeries.crossed_down — Method
crossed_down(a, b; i) -> Any
Did series a become less than series b at index i.
ReversedSeries.crossed_down_currently — Method
crossed_down_currently(a, b; i) -> Any
Is series a currently less than series b?
ReversedSeries.crossed_up — Method
crossed_up(a, b; i) -> Any
Did series a become greater than series b at index i.
ReversedSeries.crossed_up_currently — Method
crossed_up_currently(a, b; i) -> Any
Is series a currently greater than series b?
ReversedSeries.find_clusters — Method
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.
ReversedSeries.find_index — Method
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.
ReversedSeries.find_local_high — Method
find_local_high(rf, cluster; close) -> Any
Out of the cluster, which index had the highest close?
ReversedSeries.find_local_low — Method
find_local_low(rf, cluster; close) -> Any
Out of the cluster, which index had the lowest close?
ReversedSeries.high_enough_fn — Method
high_enough_fn(
threshold::AbstractFloat;
high,
upper,
lower
) -> ReversedSeries.var"#7#8"{Symbol, Symbol, Symbol, <:AbstractFloat}
Return a function that tries to find highs by their proximity to the BB upper bands
ReversedSeries.low_enough_fn — Method
low_enough_fn(
threshold::AbstractFloat;
low,
upper,
lower
) -> ReversedSeries.var"#3#4"{Symbol, Symbol, Symbol, <:AbstractFloat}
Return a function that tries to find lows by their proximity to the BB lower bands
ReversedSeries.negative_slope_currently — Method
negative_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 — Method
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.
ReversedSeries.percent_difference — Method
percent_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 — Method
positive_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 — Method
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
| argument | default | description |
|---|---|---|
| indicator | :rsi14 | Name in rf of the indicator being tested |
| high | :h | Name in rf of the OHLCV high value |
| upper | :bb_upper | Name in rf of the upper band of the BBs |
| lower | :bb_lower | Name in rf of 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 — Method
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
| argument | default | description |
|---|---|---|
| indicator | :rsi14 | Name in rf of the indicator being tested |
| low | :l | Name in rf of the OHLCV high value |
| upper | :bb_upper | Name in rf of the upper band of the BBs |
| lower | :bb_lower | Name in rf of the lower band of the BBs |
| age_threshold | 1 | ? |
| gap_threshold | (7,30) | ? |
| peak_threshold | 9.0 | ? |
Example
julia> regular_bullish_divergence(rf)