Comments (1)
The R-Forge bug report included an attached file with the following contents:
DVIEx = function (price, n = 252, wts = c(0.8, 0.2), smooth = 3, magnitude = c(5,
100, 5), stretch = c(10, 100, 2))
{
price <- try.xts(price, error = as.matrix)
wts.sum <- sum(wts)
wts[1] <- wts[1]/wts.sum
wts[2] <- wts[2]/wts.sum
r <- price/SMA(price, smooth) - 1
mag <- SMA((SMA(r, magnitude[1]) + SMA(r, magnitude[2])/10)/2,
magnitude[3])
b <- ifelse(price > lag(price), 1, -1)
str <- SMA((runSum(b, stretch[1]) + runSum(b, stretch[2])/10)/2,
stretch[3])
pctRank <- function(x, i) match(x[i], sort(coredata(x[(i -
(n - 1)):i])))
dvi.mag <- dvi.str <- rep(NA, NROW(price))
ii = 1
len = NROW(price)
# Find the first index for each both mag and str are not NAs
while (ii <= len && (is.na(mag[ii]) || is.na(str[ii]))) {
ii = ii + 1
}
# We want to start with n non-NA values
ii = ii + n
if (ii > len ) return(NULL)
while (ii <= len) {
dvi.mag[ii] <- pctRank(mag, ii)/n
dvi.str[ii] <- pctRank(str, ii)/n
ii = ii + 1
}
dvi <- wts[1] * dvi.mag + wts[2] * dvi.str
reclass(cbind(dvi.mag, dvi.str, dvi), price)
}
from ttr.
Related Issues (20)
- segfault in DVI caused by runPercentRank HOT 3
- "Series contains non-leading NAs" on stoch() HOT 8
- support TR calculations without Average HOT 2
- ERROR: package or namespace load failed for 'TTR' in dyn.load(file, DLLpath = DLLpath, ...): HOT 1
- Standardize leading NA checks in C code
- ALMA optimization HOT 2
- runSum produces leading NA when cumulative = TRUE HOT 2
- how can i buy and finish a operation in R? HOT 1
- Issue on nSig for TRIX HOT 2
- cumulative runSD returns all NA HOT 3
- runMean(..., cumulative = TRUE) doesn't account for leading NA in denominator
- Use R_forceSymbols(dll, TRUE) for native routines
- Add argument to EMA to prevent setting first n-1 obs to NA
- malloc(): invalid size (unsorted) HOT 8
- CTI doesn't pad non-xtsible inputs with NA
- The Symbol for Nano Labs Ltd (NASDAQ), NA, conflicts with NA in R HOT 6
- Change Readme to reflect that Fortran is no longer used HOT 1
- indicators show different values on windows of different sizes HOT 4
- rolling trimmed mean HOT 7
- Add Fibonacci Retracements and Extensions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ttr.