-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor dropTA to use panel functionality
Since S4 method and chartSeries.chob are deprecated, dropTA, listTA and get.chob functions are refactored to use panel functionality of xts::plot.xts. The way TAs are removed is based on which frame they are added to.
- Loading branch information
1 parent
3f56737
commit 49ec234
Showing
3 changed files
with
26 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,18 +61,15 @@ function(ta,pos,occ=1,dev) { | |
} | ||
|
||
`dropTA` <- | ||
function(ta,occ=1,dev,all=FALSE) { | ||
function(ta,occ=1,chob,all=FALSE) { | ||
|
||
if(all) return(do.call('dropTA', list(1:length(listTA())))) | ||
|
||
if(missing(ta)) stop("no TA indicator specified") | ||
|
||
# default to the current device if none specified | ||
if(missing(dev)) dev <- dev.cur() | ||
ta.list <- listTA(dev) | ||
|
||
# get the current chob | ||
lchob <- get.chob()[[dev]] | ||
if(missing(chob)) chob <- get.chob() | ||
ta.list <- listTA(chob) | ||
|
||
sel.ta <- NULL | ||
|
||
|
@@ -91,22 +88,32 @@ function(ta,occ=1,dev,all=FALSE) { | |
if(!is.na(which.ta)) { | ||
|
||
# decrease window count if necessary | ||
if(lchob@passed.args$TA[[which.ta]]@new) | ||
lchob@windows <- lchob@windows - 1 | ||
#if([email protected]$TA[[which.ta]]@new) | ||
# lchob@windows <- lchob@windows - 1 | ||
|
||
sel.ta <- c(sel.ta,which.ta) | ||
} else { | ||
stop("nothing to remove") | ||
} | ||
} | ||
|
||
if(is.null(sel.ta)) stop("nothing to remove") | ||
|
||
# remove TA from current list | ||
lchob@passed.args$TA <- lchob@passed.args$TA[-sel.ta] | ||
if(length(lchob@passed.args$TA) < 1) | ||
lchob@passed.args$TA <- list() | ||
ta.list <- ta.list[-sel.ta] | ||
for(li in sel.ta) { | ||
frame <- attr(chob$Env$actions[[9 + sel.ta]], "frame") | ||
if(abs(frame)==2) | ||
chob$Env$actions[[9 + sel.ta]] <- NULL | ||
else | ||
chob$remove_frame(frame) | ||
chob$Env$TA[[1 + sel.ta]] <- NULL | ||
ncalls <- length(chob$Env$call_list) | ||
chob$Env$call_list[1 + sel.ta] <- NULL | ||
} | ||
|
||
# redraw chart | ||
do.call("chartSeries.chob",list(lchob)) | ||
chob | ||
|
||
write.chob(lchob,lchob@device) | ||
#write.chob(lchob,lchob@device) | ||
} |