## ----------------------------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 ) ## ----------------------------------------------------------------------------- library(ichimoku) ## ----------------------------------------------------------------------------- # Simulated OHLC pricing data is assigned to data frame 'TKR': TKR <- sample_ohlc_data cloud <- ichimoku(TKR) ## ----------------------------------------------------------------------------- strat <- strat(cloud, c1 = "cloudB", c2 = "kijun") print(strat[100:105, ], plot = FALSE) ## ----------------------------------------------------------------------------- summary(strat) ## ----------------------------------------------------------------------------- plot(strat, theme = "dark") ## ----------------------------------------------------------------------------- strat2 <- strat(cloud, "kijun", "tenkan") newstrat <- stratcombine(strat, strat2) summary(newstrat) ## ----------------------------------------------------------------------------- # library(PerformanceAnalytics) # # To chart performance comparison of strategy vs benchmark, daily returns and drawdowns # charts.PerformanceSummary(strat[, c("sret", "ret")]) # # For a table detailing drawdowns, including depth, length of recovery etc. # table.Drawdowns(strat[, "sret"]) ## ----------------------------------------------------------------------------- autostrat(cloud, n = 3) ## ----------------------------------------------------------------------------- autostrat(cloud, n = 3, dir = "short", level = "2") ## ----------------------------------------------------------------------------- autostrat(cloud, n = 3, dir = "long", level = "3") ## ----------------------------------------------------------------------------- mlgrid(cloud, y = "logret", dir = "long", type = "boolean", unique = TRUE)[100:105, 1:4] ## ----------------------------------------------------------------------------- mlgrid(cloud, y = "ret", dir = "short", type = "numeric", unique = FALSE)[100:105, 1:4] ## ----------------------------------------------------------------------------- mlgrid(cloud, y = "ret", dir = "short", type = "z-score", unique = FALSE)[100:105, 1:4] ## ----------------------------------------------------------------------------- relative(cloud, signif = 0.4)[1:10, ]