Context: I have a list of transactions (trades) in a csv file. I like to import these transactions into R and then plot the trades on the chart so that I can see visually the entries and exits. I finally figured the import part (from amzn_test.R in blotter demo) but having difficulty in changing color for plotted trade markers on the chart.
I noticed that the colors are currently fixed for the trade markers in source code for chart.Posn.R (package:blotter). (Filename: chart.Posn.R, Code URL: https://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/chart.Posn.R?view=markup&root=blotter)
if(!is.null(nrow(Buys)) && nrow(Buys) >=1 ) (add_TA(Buys,pch=2,type='p',col='green', on=1));
if(!is.null(nrow(Sells)) && nrow(Sells) >= 1) (add_TA(Sells,pch=6,type='p',col='red', on=1));
Question: Is there any way I can override these colors? If I cannot is there any way I can change the background chart theme to black so that the trade markers are visible better? I tried various ways to set the chartTheme but ran into errors.
To reproduce error, execute following blotter amzn_test demo code fragment and then the custom code.
Demo code:
require(blotter)
# Remove portfolio and account data if run previously
try(rm("portfolio.amzn_port","account.amzn_acct",pos=.blotter))
# load the example data
data("amzn")
currency("USD")
stock("amzn",currency="USD",multiplier=1)
# Initialize the Portfolio
initPortf("amzn_port",symbols="amzn",initDate="2010-01-14")
initAcct("amzn_acct",portfolios="amzn_port",initDate="2010-01-14", initEq=10000)
# look at the transactions data
amzn.trades
# Add the transactions to the portfolio
blotter:::addTxns("amzn_port","amzn",TxnData=amzn.trades,verbose=TRUE)
# update the portfolio stats
updatePortf("amzn_port",Dates="2010-01-14")
# update the account P&L
updateAcct("amzn_acct",Dates="2010-01-14")
# and look at it
chart.Posn("amzn_port","amzn",Dates="2010-01-14")
Custom Code:
> black_theme = chartTheme("black")
> chart.Posn("amzn_port","amzn",Dates="2010-01-14", theme=chartTheme("black"))
Error in if (theme$lylab) { : argument is of length zero
>
I appreciate very much if anyone can guide me on how to solve this.
Regards,