Tuesday 24 April 2012

First Use of Rcpp Package

In preparation for the tests I want to conduct, I have finally started to use the Rcpp package. The reason for this decision is straightforward; I cannot begin to imagine how the code for the tests I want to conduct could be vectorised, and since loops in R are slow and not recommended there is no realistic alternative to biting the Rcpp bullet. Another reason is that some R packages, such as the ttrTests package, require an R function as part of the input and using Rcpp will enable me to transfer my .oct C++ function coding directly into R without having to rewrite in R code itself. A simple proof of concept programming exercise I set myself is shown below.
rm(list=ls()) # clear the entire workspace
library(xts)  # load the required library
library(zoo)  # load the required library
library(Rcpp) # load the required library
library(inline) # load the required library
library(compiler) # load the required library

# load the "indicator" file 
data <- read.csv(file="sind",head=FALSE,sep=,)
tick_size <- 0.025
tick_value <- 12.50

# extract other vectors of interest
#open <- data[,2]
market_mode <- data[,228]
kalman <- data[,283]

# source the Rcpp inline file for the C++ code for the test in question
# this file effectively creates a function that takes input and gives test 
# output in the desired form e.g. equity curve, position vector etc. for
# further statistical tests in the R environment, e.g the ttrTests package.

source("basic_market_mode_equity.r")
results <- basic_market_mode_equity(data[,2],market_mode,kalman,tick_size,tick_value)
This is "normal" R code which
  • loads the required libraries
  • loads the required file(s) from disk and takes other inputs for the test in question
  • extracts the required information from the loaded file(s)
  • sources and then calls the test function, named "basic_market_mode_equity"
This second code block contains the actual C++ test function code, which is contained in a file named "basic_market_mode_equity.r"
# This function takes as inputs vectors of opening prices, the "market mode," 
# the kalman filter of vwap, and single values for tick size and tick value.
# The values of "market_mode" are as follows:-
# 0 = cyclic
# 1 = up with retracement
# 2 = up with no retracement
# 3 = down with retracement
# 4 = down with no retracement
# 
# This first test is very simple - be long when market mode is 1 or 2, 
# short when 3 or 4, and when 0 be long or short depending on the direction
# of the kalman filter. This test is just practice in coding using Rcpp:- 
# don't expect any meaningful results. Equity curves for each market mode 
# are the function outputs

src <- '
Rcpp::NumericVector open(a) ;
Rcpp::NumericVector market_mode(b) ;
Rcpp::NumericVector kalman(c) ;
Rcpp::NumericVector tick_size(d) ;
Rcpp::NumericVector tick_value(e) ;
int n = open.size() ;
Rcpp::NumericVector cyc(n) ; // create output vector
Rcpp::NumericVector uwr(n) ; // create output vector
Rcpp::NumericVector unr(n) ; // create output vector
Rcpp::NumericVector dwr(n) ; // create output vector
Rcpp::NumericVector dnr(n) ; // create output vector

// fill the equity_curve with zeros for "burn in" period
for ( int ii = 0 ; ii < 100 ; ii++ ) {
    cyc[ii] = 0.0 ;
    uwr[ii] = 0.0 ;
    unr[ii] = 0.0 ;
    dwr[ii] = 0.0 ;
    dnr[ii] = 0.0 ; }

for ( int ii = 100 ; ii < n ; ii++ ) {
    
    // uwr market type
    if ( market_mode[ii-2] == 1 ) { 
    cyc[ii] = cyc[ii-1] ;
    uwr[ii] = uwr[ii-1] + tick_value[0] * ( (open[ii]-open[ii-1])/tick_size[0] ) ;
    unr[ii] = unr[ii-1] ;
    dwr[ii] = dwr[ii-1] ;
    dnr[ii] = dnr[ii-1] ; }

    // unr market type
    if ( market_mode[ii-2] == 2 ) { 
    cyc[ii] = cyc[ii-1] ;
    uwr[ii] = uwr[ii-1] ; 
    unr[ii] = unr[ii-1] + tick_value[0] * ( (open[ii]-open[ii-1])/tick_size[0] ) ;
    dwr[ii] = dwr[ii-1] ;
    dnr[ii] = dnr[ii-1] ; }

    // dwr
    if ( market_mode[ii-2] == 3 ) { 
    cyc[ii] = cyc[ii-1] ;
    uwr[ii] = uwr[ii-1] ;
    unr[ii] = unr[ii-1] ;
    dwr[ii] = dwr[ii-1] + tick_value[0] * ( (open[ii-1]-open[ii])/tick_size[0] ) ; 
    dnr[ii] = dnr[ii-1] ; }

    // dnr
    if ( market_mode[ii-2] == 4 ) { 
    cyc[ii] = cyc[ii-1] ;
    uwr[ii] = uwr[ii-1] ;
    unr[ii] = unr[ii-1] ;
    dwr[ii] = dwr[ii-1] ; 
    dnr[ii] = dnr[ii-1] + tick_value[0] * ( (open[ii-1]-open[ii])/tick_size[0] ) ; }

    // cyc long
    if ( market_mode[ii-2] == 0 && kalman[ii-2] > kalman[ii-3] ) { 
    cyc[ii] = cyc[ii-1] + tick_value[0] * ( (open[ii]-open[ii-1])/tick_size[0] ) ;
    uwr[ii] = uwr[ii-1] ;
    unr[ii] = unr[ii-1] ;
    dwr[ii] = dwr[ii-1] ; 
    dnr[ii] = dnr[ii-1] ; }

    // cyc short
    if ( market_mode[ii-2] == 0 && kalman[ii-2] < kalman[ii-3] ) { 
    cyc[ii] = cyc[ii-1] + tick_value[0] * ( (open[ii-1]-open[ii])/tick_size[0] ) ;
    uwr[ii] = uwr[ii-1] ;
    unr[ii] = unr[ii-1] ;
    dwr[ii] = dwr[ii-1] ; 
    dnr[ii] = dnr[ii-1] ; }

} // end of main for loop

return List::create(
  _["cyc"] = cyc ,
  _["uwr"] = uwr ,
  _["unr"] = unr ,
  _["dwr"] = dwr ,
  _["dnr"] = dnr ) ; '

basic_market_mode_equity <- cxxfunction(signature(a = "numeric", b = "numeric", c = "numeric",
                                d = "numeric", e = "numeric"), body=src, 
                                plugin = "Rcpp")
which basically just outputs five equity curves corresponding to the identified market mode (see the comments in the code for more details).

This final code block is again "normal" R code
# coerce the above results list object to a data frame object
results_df <- data.frame( results )
df_max <- max(results_df) # for scaling of results plot
df_min <- min(results_df) # for scaling of results plot

# and now create an xts object for plotting
results_xts <- xts(results_df,as.Date(data[,'V1']))

# a nice plot of the results_xts object
plot(results_xts[,'cyc'],ylim=c(df_min,df_max),type="l")
par(new=TRUE,col="cyan")
plot(results_xts[,'uwr'],ylim=c(df_min,df_max),type="l")
par(new=TRUE,col="blue")
plot(results_xts[,'unr'],ylim=c(df_min,df_max),type="l")
par(new=TRUE,col="green")
plot(results_xts[,'dwr'],ylim=c(df_min,df_max),type="l")
par(new=TRUE,col="red")
plot(results_xts[,'dnr'],ylim=c(df_min,df_max),type="l")
which produces this typical plot output.
This test is just a toy test and the results are not really important. The important thing is that I can now easily import the output of my Octave .oct C++ functions into R and conduct a whole range of tests utilising R packages from CRAN or simply write my own test routines in C++ (my intention) to run in R and not have to struggle with vectorising code for speed optimisation purposes.

Saturday 14 April 2012

Bayesian Classifier Sanity Check, Part 2

Here are the results of the sliced_charts script when applied to the "down with no retracement" market mode, and again it is pleasing to see such high percentages.
octave:1> sliced_charts
Enter matrix e.g. gcmatrix: clmatrix
points_of_interest =  132
dwr_to_dnr =  118
dwr_to_dnr_percent =  0.89394
cyc_to_dnr =  13
cyc_to_dnr_percent =  0.098485
octave:2> sliced_charts
Enter matrix e.g. gcmatrix: homatrix
points_of_interest =  124
dwr_to_dnr =  100
dwr_to_dnr_percent =  0.80645
cyc_to_dnr =  20
cyc_to_dnr_percent =  0.16129
octave:3> sliced_charts
Enter matrix e.g. gcmatrix: ngmatrix
points_of_interest =  150
dwr_to_dnr =  127
dwr_to_dnr_percent =  0.84667
cyc_to_dnr =  21
cyc_to_dnr_percent =  0.14000
octave:4> sliced_charts
Enter matrix e.g. gcmatrix: rbmatrix
points_of_interest =  121
dwr_to_dnr =  104
dwr_to_dnr_percent =  0.85950
cyc_to_dnr =  13
cyc_to_dnr_percent =  0.10744
octave:5> sliced_charts
Enter matrix e.g. gcmatrix: ccmatrix
points_of_interest =  153
dwr_to_dnr =  132
dwr_to_dnr_percent =  0.86275
cyc_to_dnr =  19
cyc_to_dnr_percent =  0.12418
octave:6> sliced_charts
Enter matrix e.g. gcmatrix: kcmatrix
points_of_interest =  148
dwr_to_dnr =  123
dwr_to_dnr_percent =  0.83108
cyc_to_dnr =  23
cyc_to_dnr_percent =  0.15541
octave:7> sliced_charts
Enter matrix e.g. gcmatrix: ojmatrix
points_of_interest =  147
dwr_to_dnr =  120
dwr_to_dnr_percent =  0.81633
cyc_to_dnr =  21
cyc_to_dnr_percent =  0.14286
octave:8> sliced_charts
Enter matrix e.g. gcmatrix: sbmatrix
points_of_interest =  109
dwr_to_dnr =  94
dwr_to_dnr_percent =  0.86239
cyc_to_dnr =  12
cyc_to_dnr_percent =  0.11009
octave:9> sliced_charts
Enter matrix e.g. gcmatrix: ctmatrix
points_of_interest =  143
dwr_to_dnr =  122
dwr_to_dnr_percent =  0.85315
cyc_to_dnr =  14
cyc_to_dnr_percent =  0.097902
octave:10> sliced_charts
Enter matrix e.g. gcmatrix: lbmatrix
points_of_interest =  142
dwr_to_dnr =  120
dwr_to_dnr_percent =  0.84507
cyc_to_dnr =  20
cyc_to_dnr_percent =  0.14085
octave:11> sliced_charts
Enter matrix e.g. gcmatrix: hgmatrix
points_of_interest =  119
dwr_to_dnr =  101
dwr_to_dnr_percent =  0.84874
cyc_to_dnr =  10
cyc_to_dnr_percent =  0.084034
octave:12> sliced_charts
Enter matrix e.g. gcmatrix: smatrix
points_of_interest =  117
dwr_to_dnr =  107
dwr_to_dnr_percent =  0.91453
cyc_to_dnr =  8
cyc_to_dnr_percent =  0.068376
octave:13> sliced_charts
Enter matrix e.g. gcmatrix: smmatrix
points_of_interest =  123
dwr_to_dnr =  105
dwr_to_dnr_percent =  0.85366
cyc_to_dnr =  17
cyc_to_dnr_percent =  0.13821
octave:14> sliced_charts
Enter matrix e.g. gcmatrix: bomatrix
points_of_interest =  136
dwr_to_dnr =  121
dwr_to_dnr_percent =  0.88971
cyc_to_dnr =  11
cyc_to_dnr_percent =  0.080882
octave:15> sliced_charts
Enter matrix e.g. gcmatrix: cmatrix
points_of_interest =  137
dwr_to_dnr =  111
dwr_to_dnr_percent =  0.81022
cyc_to_dnr =  24
cyc_to_dnr_percent =  0.17518
octave:16> sliced_charts
Enter matrix e.g. gcmatrix: omatrix
points_of_interest =  138
dwr_to_dnr =  108
dwr_to_dnr_percent =  0.78261
cyc_to_dnr =  24
cyc_to_dnr_percent =  0.17391
octave:17> sliced_charts
Enter matrix e.g. gcmatrix: wmatrix
points_of_interest =  145
dwr_to_dnr =  122
dwr_to_dnr_percent =  0.84138
cyc_to_dnr =  21
cyc_to_dnr_percent =  0.14483
octave:18> sliced_charts
Enter matrix e.g. gcmatrix: lcmatrix
points_of_interest =  136
dwr_to_dnr =  113
dwr_to_dnr_percent =  0.83088
cyc_to_dnr =  22
cyc_to_dnr_percent =  0.16176
octave:19> sliced_charts
Enter matrix e.g. gcmatrix: fcmatrix
points_of_interest =  123
dwr_to_dnr =  105
dwr_to_dnr_percent =  0.85366
cyc_to_dnr =  15
cyc_to_dnr_percent =  0.12195
octave:20> sliced_charts
Enter matrix e.g. gcmatrix: lhmatrix
points_of_interest =  147
dwr_to_dnr =  122
dwr_to_dnr_percent =  0.82993
cyc_to_dnr =  21
cyc_to_dnr_percent =  0.14286
octave:21> sliced_charts
Enter matrix e.g. gcmatrix: gcmatrix
points_of_interest =  132
dwr_to_dnr =  115
dwr_to_dnr_percent =  0.87121
cyc_to_dnr =  16
cyc_to_dnr_percent =  0.12121
octave:22> sliced_charts
Enter matrix e.g. gcmatrix: simatrix
points_of_interest =  127
dwr_to_dnr =  105
dwr_to_dnr_percent =  0.82677
cyc_to_dnr =  16
cyc_to_dnr_percent =  0.12598
octave:23> sliced_charts
Enter matrix e.g. gcmatrix: plmatrix
points_of_interest =  128
dwr_to_dnr =  112
dwr_to_dnr_percent =  0.87500
cyc_to_dnr =  14
cyc_to_dnr_percent =  0.10938
octave:24> sliced_charts
Enter matrix e.g. gcmatrix: pamatrix
points_of_interest =  120
dwr_to_dnr =  96
dwr_to_dnr_percent =  0.80000
cyc_to_dnr =  18
cyc_to_dnr_percent =  0.15000
octave:25> sliced_charts
Enter matrix e.g. gcmatrix: usmatrix
points_of_interest =  94
dwr_to_dnr =  78
dwr_to_dnr_percent =  0.82979
cyc_to_dnr =  14
cyc_to_dnr_percent =  0.14894
octave:26> sliced_charts
Enter matrix e.g. gcmatrix: tymatrix
points_of_interest =  104
dwr_to_dnr =  99
dwr_to_dnr_percent =  0.95192
cyc_to_dnr =  2
cyc_to_dnr_percent =  0.019231
octave:27> sliced_charts
Enter matrix e.g. gcmatrix: edmatrix
points_of_interest =  108
dwr_to_dnr =  96
dwr_to_dnr_percent =  0.88889
cyc_to_dnr =  10
cyc_to_dnr_percent =  0.092593
octave:28> sliced_charts
Enter matrix e.g. gcmatrix: dxmatrix
points_of_interest =  116
dwr_to_dnr =  94
dwr_to_dnr_percent =  0.81034
cyc_to_dnr =  20
cyc_to_dnr_percent =  0.17241
octave:29> sliced_charts
Enter matrix e.g. gcmatrix: spmatrix
points_of_interest =  106
dwr_to_dnr =  85
dwr_to_dnr_percent =  0.80189
cyc_to_dnr =  19
cyc_to_dnr_percent =  0.17925
octave:30> sliced_charts
Enter matrix e.g. gcmatrix: esmatrix
points_of_interest =  109
dwr_to_dnr =  86
dwr_to_dnr_percent =  0.78899
cyc_to_dnr =  20
cyc_to_dnr_percent =  0.18349
octave:31> sliced_charts
Enter matrix e.g. gcmatrix: ndmatrix
points_of_interest =  107
dwr_to_dnr =  83
dwr_to_dnr_percent =  0.77570
cyc_to_dnr =  18
cyc_to_dnr_percent =  0.16822
octave:32> sliced_charts
Enter matrix e.g. gcmatrix: eurusdmatrix
points_of_interest =  72
dwr_to_dnr =  60
dwr_to_dnr_percent =  0.83333
cyc_to_dnr =  11
cyc_to_dnr_percent =  0.15278
octave:33> sliced_charts
Enter matrix e.g. gcmatrix: gbpusdmatrix
points_of_interest =  85
dwr_to_dnr =  72
dwr_to_dnr_percent =  0.84706
cyc_to_dnr =  11
cyc_to_dnr_percent =  0.12941
octave:34> sliced_charts
Enter matrix e.g. gcmatrix: usdchfmatrix
points_of_interest =  86
dwr_to_dnr =  69
dwr_to_dnr_percent =  0.80233
cyc_to_dnr =  14
cyc_to_dnr_percent =  0.16279
octave:35> sliced_charts
Enter matrix e.g. gcmatrix: usdyenmatrix
points_of_interest =  100
dwr_to_dnr =  80
dwr_to_dnr_percent =  0.80000
cyc_to_dnr =  16
cyc_to_dnr_percent =  0.16000
octave:36> sliced_charts
Enter matrix e.g. gcmatrix: eurchfmatrix
points_of_interest =  100
dwr_to_dnr =  83
dwr_to_dnr_percent =  0.83000
cyc_to_dnr =  15
cyc_to_dnr_percent =  0.15000
octave:37> sliced_charts
Enter matrix e.g. gcmatrix: eurgbpmatrix
points_of_interest =  91
dwr_to_dnr =  79
dwr_to_dnr_percent =  0.86813
cyc_to_dnr =  12
cyc_to_dnr_percent =  0.13187
octave:38> sliced_charts
Enter matrix e.g. gcmatrix: euryenmatrix
points_of_interest =  94
dwr_to_dnr =  75
dwr_to_dnr_percent =  0.79787
cyc_to_dnr =  15
cyc_to_dnr_percent =  0.15957
octave:39> sliced_charts
Enter matrix e.g. gcmatrix: eurausmatrix
points_of_interest =  99
dwr_to_dnr =  81
dwr_to_dnr_percent =  0.81818
cyc_to_dnr =  18
cyc_to_dnr_percent =  0.18182
octave:40> sliced_charts
Enter matrix e.g. gcmatrix: eurcadmatrix
points_of_interest =  92
dwr_to_dnr =  81
dwr_to_dnr_percent =  0.88043
cyc_to_dnr =  9
cyc_to_dnr_percent =  0.097826
octave:41> sliced_charts
Enter matrix e.g. gcmatrix: usdcadmatrix
points_of_interest =  97
dwr_to_dnr =  86
dwr_to_dnr_percent =  0.88660
cyc_to_dnr =  7
cyc_to_dnr_percent =  0.072165
octave:42> sliced_charts
Enter matrix e.g. gcmatrix: gbpchfmatrix
points_of_interest =  87
dwr_to_dnr =  70
dwr_to_dnr_percent =  0.80460
cyc_to_dnr =  14
cyc_to_dnr_percent =  0.16092
octave:43> sliced_charts
Enter matrix e.g. gcmatrix: gbpyenmatrix
points_of_interest =  85
dwr_to_dnr =  74
dwr_to_dnr_percent =  0.87059
cyc_to_dnr =  9
cyc_to_dnr_percent =  0.10588
octave:44> sliced_charts
Enter matrix e.g. gcmatrix: auscadmatrix
points_of_interest =  72
dwr_to_dnr =  59
dwr_to_dnr_percent =  0.81944
cyc_to_dnr =  13
cyc_to_dnr_percent =  0.18056
octave:45> sliced_charts
Enter matrix e.g. gcmatrix: aususdmatrix
points_of_interest =  74
dwr_to_dnr =  59
dwr_to_dnr_percent =  0.79730
cyc_to_dnr =  9
cyc_to_dnr_percent =  0.12162
octave:46> sliced_charts
Enter matrix e.g. gcmatrix: ausyenmatrix
points_of_interest =  65
dwr_to_dnr =  49
dwr_to_dnr_percent =  0.75385
cyc_to_dnr =  13
cyc_to_dnr_percent =  0.20000
But what does this all mean? For the purposes of simplicity I shall discuss "up with no retracement" only, but everything will apply equally to the "down with retracement," but of course in reverse.

My original concern was that the market classifications might have been erratically switching directly from "dnr" to "unr" with resultant lurches from short to long market positions and along the way incurring whipsaw losses from false signals. However, the high percentages from these simple tests show that this is not actually the case. Based on this, one can assume that
  • when the market classification changes to "unr" a long position will already be held because either
  1. a cyclic long position is held, having been initiated at the most recent low cyclic turn, or
  2. a "uwr" long position is held, having been initiated at the most recent rebound from a resistance/retracement level
  • which means that this market classification change is not necessarily a new entry signal, but rather a signal to change to a trend following exit criteria
Therefore, my next test(s) will be to assume that such a long position is held when the market classification changes to "unr" and will continued to be held until a trend following exit occurs, coupled with a "re-entry" signal if appropriate. My intent at the moment is simply to plot equity curves of these long positions, in the supposition that these equity curves will be "additions" or "extensions" to the equity curves generated by signals when in other market modes. More details in a coming post.

Friday 13 April 2012

My Naive Bayesian Classifier Sanity Check

Following on from my previous post, as part of my initial attempts to "come up with a robust rule set that combines all these disparate indicators into a coherent whole," I have written a simple Octave script to conduct a basic sanity check of my Naive Bayesian Classifier. The purpose of this is to ensure that the various classifications are not wildly fluctuating between bull and bear market modes with no discernible order. This particular test identifies which market modes are indicated immediately prior to an "up with no retracement" mode being indicated. This code box shows the Octave terminal output of the test script, which is named "sliced_charts".
octave:1> sliced_charts
Enter matrix e.g. gcmatrix: clmatrix
points_of_interest =  147
uwr_to_unr =  126
uwr_to_unr_percent =  0.85714
cyc_to_unr =  16
cyc_to_unr_percent =  0.10884
octave:2> sliced_charts
Enter matrix e.g. gcmatrix: homatrix
points_of_interest =  130
uwr_to_unr =  106
uwr_to_unr_percent =  0.81538
cyc_to_unr =  20
cyc_to_unr_percent =  0.15385
octave:3> sliced_charts
Enter matrix e.g. gcmatrix: ngmatrix
points_of_interest =  123
uwr_to_unr =  104
uwr_to_unr_percent =  0.84553
cyc_to_unr =  15
cyc_to_unr_percent =  0.12195
octave:4> sliced_charts
Enter matrix e.g. gcmatrix: rbmatrix
points_of_interest =  162
uwr_to_unr =  134
uwr_to_unr_percent =  0.82716
cyc_to_unr =  23
cyc_to_unr_percent =  0.14198
octave:5> sliced_charts
Enter matrix e.g. gcmatrix: ccmatrix
points_of_interest =  123
uwr_to_unr =  95
uwr_to_unr_percent =  0.77236
cyc_to_unr =  24
cyc_to_unr_percent =  0.19512
octave:6> sliced_charts
Enter matrix e.g. gcmatrix: kcmatrix
points_of_interest =  114
uwr_to_unr =  98
uwr_to_unr_percent =  0.85965
cyc_to_unr =  14
cyc_to_unr_percent =  0.12281
octave:7> sliced_charts
Enter matrix e.g. gcmatrix: ojmatrix
points_of_interest =  129
uwr_to_unr =  109
uwr_to_unr_percent =  0.84496
cyc_to_unr =  17
cyc_to_unr_percent =  0.13178
octave:8> sliced_charts
Enter matrix e.g. gcmatrix: sbmatrix
points_of_interest =  141
uwr_to_unr =  113
uwr_to_unr_percent =  0.80142
cyc_to_unr =  23
cyc_to_unr_percent =  0.16312
octave:9> sliced_charts
Enter matrix e.g. gcmatrix: ctmatrix
points_of_interest =  114
uwr_to_unr =  90
uwr_to_unr_percent =  0.78947
cyc_to_unr =  16
cyc_to_unr_percent =  0.14035
octave:10> sliced_charts
Enter matrix e.g. gcmatrix: lbmatrix
points_of_interest =  113
uwr_to_unr =  89
uwr_to_unr_percent =  0.78761
cyc_to_unr =  19
cyc_to_unr_percent =  0.16814
octave:11> sliced_charts
Enter matrix e.g. gcmatrix: hgmatrix
points_of_interest =  132
uwr_to_unr =  118
uwr_to_unr_percent =  0.89394
cyc_to_unr =  14
cyc_to_unr_percent =  0.10606
octave:12> sliced_charts
Enter matrix e.g. gcmatrix: smatrix
points_of_interest =  141
uwr_to_unr =  118
uwr_to_unr_percent =  0.83688
cyc_to_unr =  20
cyc_to_unr_percent =  0.14184
octave:13> sliced_charts
Enter matrix e.g. gcmatrix: smmatrix
points_of_interest =  140
uwr_to_unr =  110
uwr_to_unr_percent =  0.78571
cyc_to_unr =  29
cyc_to_unr_percent =  0.20714
octave:14> sliced_charts
Enter matrix e.g. gcmatrix: bomatrix
points_of_interest =  121
uwr_to_unr =  97
uwr_to_unr_percent =  0.80165
cyc_to_unr =  16
cyc_to_unr_percent =  0.13223
octave:15> sliced_charts
Enter matrix e.g. gcmatrix: cmatrix
points_of_interest =  128
uwr_to_unr =  103
uwr_to_unr_percent =  0.80469
cyc_to_unr =  23
cyc_to_unr_percent =  0.17969
octave:16> sliced_charts
Enter matrix e.g. gcmatrix: omatrix
points_of_interest =  128
uwr_to_unr =  104
uwr_to_unr_percent =  0.81250
cyc_to_unr =  20
cyc_to_unr_percent =  0.15625
octave:17> sliced_charts
Enter matrix e.g. gcmatrix: wmatrix
points_of_interest =  105
uwr_to_unr =  91
uwr_to_unr_percent =  0.86667
cyc_to_unr =  11
cyc_to_unr_percent =  0.10476
octave:18> sliced_charts
Enter matrix e.g. gcmatrix: lcmatrix
points_of_interest =  144
uwr_to_unr =  119
uwr_to_unr_percent =  0.82639
cyc_to_unr =  23
cyc_to_unr_percent =  0.15972
octave:19> sliced_charts
Enter matrix e.g. gcmatrix: fcmatrix
points_of_interest =  132
uwr_to_unr =  110
uwr_to_unr_percent =  0.83333
cyc_to_unr =  19
cyc_to_unr_percent =  0.14394
octave:20> sliced_charts
Enter matrix e.g. gcmatrix: lhmatrix
points_of_interest =  136
uwr_to_unr =  113
uwr_to_unr_percent =  0.83088
cyc_to_unr =  21
cyc_to_unr_percent =  0.15441
octave:21> sliced_charts
Enter matrix e.g. gcmatrix: gcmatrix
points_of_interest =  137
uwr_to_unr =  118
uwr_to_unr_percent =  0.86131
cyc_to_unr =  16
cyc_to_unr_percent =  0.11679
octave:22> sliced_charts
Enter matrix e.g. gcmatrix: simatrix
points_of_interest =  121
uwr_to_unr =  102
uwr_to_unr_percent =  0.84298
cyc_to_unr =  15
cyc_to_unr_percent =  0.12397
octave:23> sliced_charts
Enter matrix e.g. gcmatrix: plmatrix
points_of_interest =  149
uwr_to_unr =  126
uwr_to_unr_percent =  0.84564
cyc_to_unr =  18
cyc_to_unr_percent =  0.12081
octave:24> sliced_charts
Enter matrix e.g. gcmatrix: pamatrix
points_of_interest =  129
uwr_to_unr =  103
uwr_to_unr_percent =  0.79845
cyc_to_unr =  22
cyc_to_unr_percent =  0.17054
octave:25> sliced_charts
Enter matrix e.g. gcmatrix: usmatrix
points_of_interest =  143
uwr_to_unr =  122
uwr_to_unr_percent =  0.85315
cyc_to_unr =  16
cyc_to_unr_percent =  0.11189
octave:26> sliced_charts
Enter matrix e.g. gcmatrix: tymatrix
points_of_interest =  148
uwr_to_unr =  128
uwr_to_unr_percent =  0.86486
cyc_to_unr =  17
cyc_to_unr_percent =  0.11486
octave:27> sliced_charts
Enter matrix e.g. gcmatrix: edmatrix
points_of_interest =  150
uwr_to_unr =  118
uwr_to_unr_percent =  0.78667
cyc_to_unr =  26
cyc_to_unr_percent =  0.17333
octave:28> sliced_charts
Enter matrix e.g. gcmatrix: dxmatrix
points_of_interest =  141
uwr_to_unr =  122
uwr_to_unr_percent =  0.86525
cyc_to_unr =  14
cyc_to_unr_percent =  0.099291
octave:29> sliced_charts
Enter matrix e.g. gcmatrix: spmatrix
points_of_interest =  158
uwr_to_unr =  123
uwr_to_unr_percent =  0.77848
cyc_to_unr =  31
cyc_to_unr_percent =  0.19620
octave:30> sliced_charts
Enter matrix e.g. gcmatrix: esmatrix
points_of_interest =  160
uwr_to_unr =  125
uwr_to_unr_percent =  0.78125
cyc_to_unr =  30
cyc_to_unr_percent =  0.18750
octave:31> sliced_charts
Enter matrix e.g. gcmatrix: ndmatrix
points_of_interest =  129
uwr_to_unr =  116
uwr_to_unr_percent =  0.89922
cyc_to_unr =  12
cyc_to_unr_percent =  0.093023
octave:32> sliced_charts
Enter matrix e.g. gcmatrix: eurusdmatrix
points_of_interest =  79
uwr_to_unr =  69
uwr_to_unr_percent =  0.87342
cyc_to_unr =  9
cyc_to_unr_percent =  0.11392
octave:33> sliced_charts
Enter matrix e.g. gcmatrix: gbpusdmatrix
points_of_interest =  84
uwr_to_unr =  72
uwr_to_unr_percent =  0.85714
cyc_to_unr =  11
cyc_to_unr_percent =  0.13095
octave:34> sliced_charts
Enter matrix e.g. gcmatrix: usdchfmatrix
points_of_interest =  80
uwr_to_unr =  73
uwr_to_unr_percent =  0.91250
cyc_to_unr =  6
cyc_to_unr_percent =  0.075000
octave:35> sliced_charts
Enter matrix e.g. gcmatrix: usdyenmatrix
points_of_interest =  74
uwr_to_unr =  62
uwr_to_unr_percent =  0.83784
cyc_to_unr =  8
cyc_to_unr_percent =  0.10811
octave:36> sliced_charts
Enter matrix e.g. gcmatrix: eurchfmatrix
points_of_interest =  93
uwr_to_unr =  80
uwr_to_unr_percent =  0.86022
cyc_to_unr =  10
cyc_to_unr_percent =  0.10753
octave:37> sliced_charts
Enter matrix e.g. gcmatrix: eurgbpmatrix
points_of_interest =  91
uwr_to_unr =  78
uwr_to_unr_percent =  0.85714
cyc_to_unr =  11
cyc_to_unr_percent =  0.12088
octave:38> sliced_charts
Enter matrix e.g. gcmatrix: euryenmatrix
points_of_interest =  103
uwr_to_unr =  88
uwr_to_unr_percent =  0.85437
cyc_to_unr =  14
cyc_to_unr_percent =  0.13592
octave:39> sliced_charts
Enter matrix e.g. gcmatrix: eurausmatrix
points_of_interest =  73
uwr_to_unr =  64
uwr_to_unr_percent =  0.87671
cyc_to_unr =  9
cyc_to_unr_percent =  0.12329
octave:40> sliced_charts
Enter matrix e.g. gcmatrix: eurcadmatrix
points_of_interest =  76
uwr_to_unr =  56
uwr_to_unr_percent =  0.73684
cyc_to_unr =  17
cyc_to_unr_percent =  0.22368
octave:41> sliced_charts
Enter matrix e.g. gcmatrix: usdcadmatrix
points_of_interest =  73
uwr_to_unr =  60
uwr_to_unr_percent =  0.82192
cyc_to_unr =  13
cyc_to_unr_percent =  0.17808
octave:42> sliced_charts
Enter matrix e.g. gcmatrix: gbpchfmatrix
points_of_interest =  98
uwr_to_unr =  84
uwr_to_unr_percent =  0.85714
cyc_to_unr =  12
cyc_to_unr_percent =  0.12245
octave:43> sliced_charts
Enter matrix e.g. gcmatrix: gbpyenmatrix
points_of_interest =  97
uwr_to_unr =  84
uwr_to_unr_percent =  0.86598
cyc_to_unr =  11
cyc_to_unr_percent =  0.11340
octave:44> sliced_charts
Enter matrix e.g. gcmatrix: auscadmatrix
points_of_interest =  107
uwr_to_unr =  92
uwr_to_unr_percent =  0.85981
cyc_to_unr =  14
cyc_to_unr_percent =  0.13084
octave:45> sliced_charts
Enter matrix e.g. gcmatrix: aususdmatrix
points_of_interest =  97
uwr_to_unr =  82
uwr_to_unr_percent =  0.84536
cyc_to_unr =  14
cyc_to_unr_percent =  0.14433
octave:46> sliced_charts
Enter matrix e.g. gcmatrix: ausyenmatrix
points_of_interest =  103
uwr_to_unr =  89
uwr_to_unr_percent =  0.86408
cyc_to_unr =  11
cyc_to_unr_percent =  0.10680
  • The clmatrix indicates which market is being tested e.g. crude oil (cl)
  • points of interest is the number of times the market mode changes to "up with no retracement" from a previously different classification
  • uwr_to_unr is the number of times such a change is from "up with retracement" to "up with no retracement"
  • cyc_to_unr is similarly from "cyclic" to "up with no retracement"
  • the *_percent is the previous two expressed as a percentage of the points of interest
It is pleasing to see such high percentages overall. I will perform a similar analysis for "down with retracement" and discuss the significance of this in my next post.