Create a grid of ichimoku indicator conditions and next period returns. The grid facilitates the comparison of strategy returns and provides a basis for use in machine learning applications. Translates the visual representation of the relationship between cloud chart elements into a numerical format for further analysis.
an ichimoku object.
[default 'logret'] choose target variable 'logret' (log returns), 'ret' (discrete returns), or 'none'.
[default 1L] number of periods time horizon over which to calculate target variable 'y'.
[default 'long'] trade direction, either 'long' or 'short'.
[default 'boolean'] choose 'boolean', 'numeric' or 'z-score'. 'boolean' creates a grid of dummy variables for ichimoku indicator conditions of the form 1 if c1 > c2, 0 otherwise. 'numeric' creates a grid of the numeric difference c1 - c2. 'z-score' standardises the numeric grid by the mean and standard deviation of each feature.
[default 'dataframe'] select either 'dataframe' or 'matrix' for the format of returned object.
[default TRUE] to return only unique combinations of c1 and c2. Set to FALSE to return both c1 > c2 and c2 > c1.
A data.frame or matrix in a 'tidy' format with one observation per
row and one feature per column with the target 'y' as the first column
(unless set to 'none').
The 'y' and 'k' parameters, trade direction and grid type are set as
attributes. To view these, use look
on the returned object.
The date-time index corresponds to when the indicator condition is met at the close for that period. The return is the k-period return achieved by transacting at the immediately following opening price until the next opening price.
Only valid combinations are included. This excludes any combination involving 'open' as it is in effect a lagged indicator and not contemporaneous. The following trivial or highly-collinear pairs are also excluded: (high, close), (low, close), (low, high), (cloudTop, Senkou A), (cloudBase, senkou A), (cloudTop, senkouB), (cloudBase, senkouB), (cloudBase, cloudTop).
Please refer to the strategies vignette by calling:
vignette("strategies", package = "ichimoku")
cloud <- ichimoku(sample_ohlc_data, ticker = "TKR")
grid <- mlgrid(cloud, y = "ret", k = 2, dir = "short", type = "z-score")
str(grid)
#> 'data.frame': 152 obs. of 38 variables:
#> $ y : num -0.00645 0.00242 -0.00321 -0.00242 -0.0016 ...
#> $ chikou_close : num -1.086 -0.79 -0.79 -0.856 -0.757 ...
#> $ chikou_high : num -0.964 -0.85 -0.768 -0.752 -0.719 ...
#> $ chikou_low : num -1.061 -0.866 -0.85 -0.898 -0.833 ...
#> $ chikou_tenkan : num -0.783 -0.67 -0.751 -0.945 -0.88 ...
#> $ chikou_kijun : num -0.631 -0.514 -0.498 -0.531 -0.431 ...
#> $ chikou_senkouA : num -0.326 -0.218 -0.203 -0.241 -0.169 ...
#> $ chikou_senkouB : num -0.709 -0.58 -0.562 -0.599 -0.489 ...
#> $ chikou_cloudT : num -0.345 -0.238 -0.222 -0.253 -0.161 ...
#> $ chikou_cloudB : num -0.714 -0.581 -0.562 -0.609 -0.519 ...
#> $ close_tenkan : num 0.783 1.092 1.036 0.643 0.615 ...
#> $ close_kijun : num -0.527 -0.313 -0.237 -0.298 -0.114 ...
#> $ close_senkouA : num -0.724 -0.606 -0.64 -0.757 -0.673 ...
#> $ close_senkouB : num -0.841 -0.711 -0.692 -0.729 -0.618 ...
#> $ close_cloudT : num -0.62 -0.499 -0.534 -0.655 -0.568 ...
#> $ close_cloudB : num -0.983 -0.852 -0.834 -0.871 -0.759 ...
#> $ high_tenkan : num 0.698 0.793 0.856 0.412 0.38 ...
#> $ high_kijun : num -0.643 -0.548 -0.404 -0.468 -0.277 ...
#> $ high_senkouA : num -0.784 -0.733 -0.733 -0.852 -0.767 ...
#> $ high_senkouB : num -0.904 -0.847 -0.791 -0.829 -0.716 ...
#> $ high_cloudT : num -0.682 -0.629 -0.629 -0.753 -0.664 ...
#> $ high_cloudB : num -1.047 -0.99 -0.934 -0.971 -0.859 ...
#> $ low_tenkan : num 0.362 1.029 1.492 0.855 0.652 ...
#> $ low_kijun : num -0.7564 -0.3619 -0.0129 -0.195 -0.1039 ...
#> $ low_senkouA : num -0.846 -0.63 -0.513 -0.696 -0.663 ...
#> $ low_senkouB : num -0.976 -0.736 -0.552 -0.662 -0.607 ...
#> $ low_cloudT : num -0.751 -0.526 -0.405 -0.595 -0.56 ...
#> $ low_cloudB : num -1.113 -0.873 -0.689 -0.799 -0.744 ...
#> $ tenkan_kijun : num -1.283 -1.221 -1.077 -0.871 -0.604 ...
#> $ tenkan_senkouA : num -1.041 -1.014 -1.032 -1.032 -0.932 ...
#> $ tenkan_senkouB : num -1.145 -1.116 -1.078 -0.981 -0.855 ...
#> $ tenkan_cloudT : num -0.948 -0.919 -0.938 -0.938 -0.833 ...
#> $ tenkan_cloudB : num -1.29 -1.261 -1.222 -1.125 -0.999 ...
#> $ kijun_senkouA : num -0.706 -0.706 -0.829 -0.965 -0.992 ...
#> $ kijun_senkouB : num -0.666 -0.666 -0.702 -0.702 -0.702 ...
#> $ kijun_cloudT : num -0.507 -0.507 -0.63 -0.767 -0.795 ...
#> $ kijun_cloudB : num -0.909 -0.909 -0.948 -0.948 -0.948 ...
#> $ senkouA_senkouB: num -0.0681 -0.0681 0.0317 0.198 0.2312 ...
#> - attr(*, "y")= chr "ret"
#> - attr(*, "k")= int 2
#> - attr(*, "direction")= chr "short"
#> - attr(*, "type")= chr "z-score"
#> - attr(*, "ticker")= chr "TKR"