Monday, September 17, 2012

Introductory Time Series with R

---------------Notes and shortcuts------------
> data(AirPassengers)
> AP = AirPassengers
> AP

> www ="http://www.massey.ac.nz/~pscowper/data/pounds_nz.dat"
> z = read.table(www, header=T)
> z.ts = ts(z, st=1991, fr=4)

Reading Columns of a series
plot(YTL[,3]) //3rd column of the series

 
gld = read.csv("http://ichart.finance.yahoo.com/table.csv?s=6012.KL&ignore=.csv", stringsAsFactors=F) 
 


colnames(gld)
[1] "Date"      "Open"      "High"     
[4] "Low"       "Close"     "Volume"   
[7] "Adj.Close"
 
gld$Open          #Access the Open column 
gld$Adj.Close     #Access last column from CSV file
 
 

ts.plot(z.ts, predict( HoltWinters(z.ts),n.ahead=4*12), lty=1:2)

---------CHAPTER 1----------


When a variable is measured sequentially in time over a fixed interval (or sampling interval ) the data form a time series.

Observations that have been collected in the past over fixed sampling intervals
form an historical time series.

A sequence of random variables taken over fixed sampling intervals is
sometimes referred to as a discrete-time stochastic process

> data(AirPassengers)
> AP = AirPassengers


Seasonal data is removed via Aggregate
Cycle function extracts the seasons for each item of data

> plot(aggregate(AP), ylab="Annual passengers/1000’s")
> boxplot(AP ~ cycle(AP), names=month.abb)
> layout(1:2)
> plot(aggregate(AP)); boxplot(AP ~ cycle(AP))

Read external data
> www = "http://www.massey.ac.nz/~pscowper/data/cbe.dat"
> cbe = read.table(www, header=T)
> cbe[1:4,]

to create  a time series data
ts(1:120, start=c(1990, 1), end=c(1993, 8), freq=12)

For a data file like above
> elec.ts = ts(cbe[,3], start=1958, freq=12)
> beer.ts = ts(cbe[,2], start=1958, freq=12)
> choc.ts = ts(cbe[,1], start=1958, freq=12)

plot to see each data frame converted to a time series
plot(cbind(elec.ts, beer.ts, choc.ts),
main="Chocolate, Beer, and Electricity Production: 1958-1990")

The three series constitute a multiple time series. There are many functions
in R for handling more than one series. to obtain the intersection of two series which overlap in time use ts.intersect

ap.elec = ts.intersect(AP, elec.ts)


The term non-stationary is used to describe a time series that has underlying
trends or seasonal effects

covariance
a measure of linear association between two variables
sum((x - mean(x))*(y - mean(y)))/(n - 1)
cov(x,y)
if y tends to decrease as x increases the covariance will tend to be negative
if x and y tend to increase together, resulting in a positive covariance

Correlation measures the linear association between a pair of variables (x, y),
cor(x, y)
A value of +1 or -1 indicates an exact linear association
a value of 0 indicating no linear association.

In R the lag k autocorrelation can be obtained from the autocorrelation
function acf. By default it is called the correlogram.
acf(x)

For example, the lag 1 autocorrelation for x is:
> acf(x)$acf[2]

pairs of values taken at a time difference of lag 1 will tend to have a high correlation when there are trends in the data.

Correlation is dimensionless, so there are no units for the y-axis
The dotted lines represent the 5% significance level for the statistical test:Pk = 0.
Any correlations that fall outside these lines are ‘significantly’ different from zero.

**Usually a trend in the data will show in the correlogram as a slow decay in the autocorrelations,

mean and variance -> ‘centre’ and the ‘spread’

stationary time series {xt}, If the mean and autocovariance do not change with time, then {xt} is a called a second-order stationary process. this means variance and autocorrelation do not change with time

A simple additive decomposition model also called a classical decomposition model.
xt = mt + st + et

xt is the observed series, mt is the trend, st is the seasonal effect, and et is the remainder or residual series

In R the functions decompose and stl estimate trends and seasonal effects using methods based on moving averages and polynomials respectively.

plot(decompose(elec.ts))
Nesting the functions within plot, using plot(decompose()) or plot(stl()), produces a single figure showing the original series xt and the decomposed series: mt, st and et

If the seasonal effect tends to increase as the trend increases a multiplicative model may be more appropriate
If the residual series is also multiplicative the data can be transformed using the natural logarithm to produce an additive model


In forcasting One approach to this is to use the past values as dependent variables in a predictive model that gives more weight to the more recent observations. This approach is used in a model based on exponential smoothing

Holt-Winters procedure provides a prediction for xn+1 by updating the trend and seasonal effect
> z.hw = HoltWinters(z.ts, beta=0, gamma=0)
> z.hw$alpha
> plot(z.hw)

In general, exponential smoothing provides good predictions when the underlying process is a random walk or a random walk with moving average error terms.

The predict function in R can be used with the fitted model to make forecasts into the future
> AP.hw = HoltWinters(AP, seasonal="mult")
> plot(AP.hw)
> AP.predict = predict(AP.hw, n.ahead=4*12)
> ts.plot(AP, AP.predict, lty=1:2)


SUMMARY
ts produces a time series object
ts.plot produces a time plot for one or more series
ts.intersect creates the intersection of one or more time series
cycle returns the season for each value in a series
time returns the times for each value in a series
acf returns the correlogram
decompose decomposes a series into the components:trend, seasonal effect and residual
HoltWinters estimates the parameters of the Holt-Winters or exponential smoothing model
predict forecasts future values



---------CHAPTER 2---------
A residual error et is the difference between an observed value and a model predicted value at time t. also called white noise.

Time series simulated using a model are sometimes called a synthetic series to distinguish them from an observed historical serie

rnorm(100) is used to simulate 100 independent standard Normal variables, which is equivalent to simulating a Gaussian white noise series of length 100
> set.seed(1)
> e = rnorm(100)
> plot(e, type="l")

set.seed is used to provide a starting point (or seed) in the simulations, thus ensuring that the simulations can be reproduced

Histogram
> x = seq(-3,3, len=1000)
> hist(rnorm(100), prob=T); points(x, dnorm(x), type="l")

Correlogram of a simulated white noise series. The underlying autocorrelations are all zero (except at lag 0); the statistically significant value at lag 7 is due to sampling variation
> acf(rnorm(100))


Differencing adjacent terms of a series can transform a non-stationary series to a stationary series

The following commands can be used to simulate random walk data for x.
> x = e = rnorm(1000)
> for (t in 2:1000) x[t] = x[t-1] + e[t]
> plot(x, type="l")

The ‘for’ loop then generates the random walk using Equation (2.3)

**The first order differences of a random walk are a white noise series,
so the correlogram of the series of differences can be used to assess whether a given series is a random walk.
> acf(diff(x))

> z.hw = HoltWinters(z.ts, gamma=0)
> acf(resid(z.hw))

The partial autocorrelation at lag k is the correlation that results after removing the effect of any correlations due to previous terms.

Hence, a plot of the partial autocorrelations can be useful when determining the order of an underlying AR process. In R, the function pacf can be used to calculate the partial autocorrelations of a time series and produce a plot of the partial
autocorrelations against lag (the ‘partial-correlogram’).
> set.seed(1)
> x = e = rnorm(100)
> for (t in 2:100) x[t] = 0.7*x[t-1] + e[t]
> plot(x); acf(x); pacf(x)

An AR(p) model can be fitted to data in R using the ar function
> x.ar = ar(x, method="mle")

The method “mle” used in the fitting procedure above is based on maximising the likelihood function

Akaike Information Criteria (AIC; Akaike (1974)), which penalises models with too many parameters
AIC = -2 × log-likelihood + 2 × number of parameters

acf(z.ar$res[-1])
"-1" is used in the vector of residuals to remove the first item from the residual series. (For a fitted AR(1) model the first item has no predicted value, because there is no observation at t = 0;

> global.ar = ar(aggregate(global.ts, FUN=mean), method="mle")
> mean(aggregate(global.ts, FUN=mean))
> global.ar$order; global.ar$ar
> acf(global.ar$res[-(1:global.ar$order)], lag=50)


set.seed sets a seed for the random number generator enabling a simulation to be reproduced
rnorm simulates a white noise series
diff creates a series of first-order differences
ar gets the best fitting AR(p) model
pacf extracts partial autocorrelations and partial-correlogram


-----------CHAPTER 3 --------------
A trend is stochastic(random) when the underlying cause is not understood, and can only be attributed to high serial correlation with random error. Trends of this type, which are common in *financial series, can be simulated in R using models such as the *random walk or *autoregressive process (Chapter 2)

Deterministic trends and seasonal variation can be modelled using regression(so-called because there is a greater understanding of the underlying cause of the trend.)

linear model will often provide a good approximation even when the underlying process is non-linear

differencing turns out to be a very useful general procedure as it can ‘remove’ both stochastic and deterministic trends

Linear models are usually fitted by minimising the sum of squared errors, which can be achieved in R using the function lm.
> set.seed(1)
> z = e = rnorm(100, sd=20)
> for (t in 2:100) z[t] = 0.8*z[t-1] + e[t]
> t = 1:100
> x = 50 + 3*t + z
> x.lm = lm(x ~ t)
> coef(x.lm)
> confint(x.lm)

an approximate 95% confidence interval for the estimated parameters extracted
The function summary can be used to obtain a standard regression output to observe this, type summary(x.lm) after entering the commands above.

> summary(x.lm)$coef
> summary(x.lm)$sigma
> summary(x.lm)$r.sq

the coefficients and their standard errors with respective t-tests, the residual standard deviation, and R2 can all be extracted

> acf(resid(lm(temp ~ time(temp))))
If the autocorrelation in the residual series is not accounted for, then the standard errors used to create confidence intervals, such as those above, or any t-ratios, will be under-estimated.

> library(nlme)
> x.gls = gls(x ~ t, cor = corAR1(0.8))
The primary use of GLS is therefore in the estimation of the standard errors and adjusting the confidence intervals for the parameters.


TO BE CONTINUED PAGE 64


SUMMARY
lm fits a linear (regression) model
coef extracts the parameter estimates from a fitted model
confint returns a (95%) confidence interval for the parameters of a fitted model
summary gets basic summary information
gls fits a linear model using generalised least squares (allowing for autocorrelated residuals)located in the nlme library
factor returns variables in the form of ‘factors’ or indicator variables
predict returns predictions (or forecasts) from a fitted model
nls fits a non-linear model by least squares

Saturday, September 8, 2012

Indicators i use in ChartNexus

OBV:buying and selling pressure
price move higher if OBV is rising=buy pressure
price move lower if OBV is falling=sell pressure




MFI:uses price and volume to measure buying and selling pressure
below 20 is oversold
above 80 is overbought
above 50 is bull
below 50 is bear

RSI:speed and change of price movement
Overbought above 70
Oversold below 30

stochastic:follows speed and momentum of price
below 20% is oversold
above 80% is overbought

MACD:Moving Average Convergence-Divergence (momentum Indicator)
positive MACD means upside momentum is increasing
negative MACD means downside momentum is increasing

Ichimoku:
Trend is up when price are above cloud
Trend is down when price are below the cloud
Trend is flat when price is below the cloud.
uptrend is strong if SpanA is rising and above the leading spanB(green cloud)
downtrend is strong when SpanA is falling and below the leading spanB(red cloud)

ADX Average directional index:strength and weakness of a trend (not direction)
strong bull if +DI is greater than -DI (buy signal)
strong bear if -DI is greater than +DI
strong trend when ADX is above 25
no trend when ADX is below 20

Chaikin Money Flow (MFI)
above 0 shows buying pressure
below 0 shows selling pressure

Rate of change: price change over time
prices rise when ROC remains positive
price fall when ROC is negative

Price Channels:Show 20 day high and low.
stock is near is highest high for the past 20 days, may go down (oversold)
stock near lowest low of past 20 days may go up (overbought)

Using R as a Tool and getting your dataset

Download R
statistical computing and graphics tool.
www.r-project.org/

Download R Packages from http://cran.r-project.org/web/package/available_packages_by_name.html
forcast package with these dependencies
tseries, fracdiff, zoo, Rcpp (≥ 0.9.10), RcppArmadillo (≥ 0.2.35)

Download RStudio
http://rstudio.org/
An IDE for R use RStudio interface to download and install the packages (See image)


Find your Stock Symbol
http://finance.yahoo.com/
Search by entering the name and click "Get Quotes"


Download your Dataset using this URL (change to your desired stock symbol)
http://ichart.finance.yahoo.com/table.csv?s=4677.KL&a=0&b=1&c=2000&d=08&e=9&f=2012&g=d&ignore=.csv

s=4677.KL : my stock code
after s= goes the ticker symbol, after a= the start month (minus 1), after b= the start day, c= the start year and so on. The final g= parameter lets you choose between getting historical stock information on a daily, weekly, or monthly basis.

You have your Tool and Data. Lets Try it (Variables are CASE SENSITIVE):

Rename the download CSV file to the name of the stock, in my case table.csv->YTL.csv
Import the data to RStudio
YTL <- read.csv("C:/Users/user/Desktop/YTL.csv")

Convert the dataset to a timeseries
YTL <- ts(YTL[,-1], start=2000, frequency=4)

start is the year we are observing the data
frequncy is the number of observations per unit of time.

Plot and View the Summary
plot(YTL)
summary(YTL)

Any Correlation between Volume and Closing Price
cor.test(YTL[,"Volume"],YTL[,"Close"])

Scatterplot matrix of the variables:
 pairs(as.data.frame(YTL))

Monthly Plot:
monthplot(YTL[,"Close"])
monthplot(YTL[,"Volume"])

Wednesday, August 22, 2012

Book 3: Applied Quantitative Methods for Trading and Investment Applied Quantitative

Chapter 1:Applications of Advanced Regression Analysis for Trading and Investment

The prediction of Forex time series is one of the most challenging problems in forecasting.

a parametric model in statistics is a family of distributions that can be described using a finite number of parameters.

a model is considered non-parametric if all the parameters are in infinite dimensional parameter space.

Essentially, he concludes that non-parametric models dominate parametric ones. Of the non-parametric models, nearest neighbours dominate NNR models.

the data is obtained from Datastream for the historical forex.

FX price movements are generally non-stationary and quite random in nature, not suitable for learning purposes. To overcome this problem the series is transformed into rates of return given a formula:
Rt=( Pt/pt-1) -1

The advantage of using a return series is that it helps making the time series stationary (use statistical property)

To confirm that a series is stationary we perform the Augmented Dickey-fuller and Phillips-Perron test statistics to show  1% significance level.

ADF and PP from the above mentioned is a test for a unit root in a time series sample.
a unit root is a feature of processes that evolve through time that can cause problems in statistical inference if its not adequately dealt with.

Augmented Dickey-Fuller
Uses a negative number, the more negative it is, the stronger the rejection of the hypothesis that there is a unit root at some level of confidence
Phillips-perron
it is used in time series analysis to test the null hypothesis that a time series is integrated of order 1.
the Phillips–Perron test makes a non-parametric correction to the t-test statistic

The benchmark models used:
Naive strategy:
Assumes that the most recent period change is the best predictor of the future.

MACD Strategy:
a moving average is obtained by finding the mean for a specified set of values and then using it to forecast the next period

ARMA Methodology:
useful to a single stationary series or when economic theory is not useful. a highly refined curve fitting device that uses current and past valuesof the dependent variables to produce accurate short term forecast.
Does not assume any particular pattern in a time series,but uses an iterative approach to identify a possible model from a general class of models.
Tests of adequacy determines a satisfactory model. The general class of ARMA models is for stationary time series, if the series is not stationary an appropriate transformation is required.

Likelihood ratio(LR) is used for redundant or omitted variables
    *used to compare the fit of two models, one the null model is a special case of the other alternative model
   
Ramseys RESET test was used for model miss-specification.
    *a general specification test for the linear regression model.it tests whether nonlinear combinations of the fitted values help explain the response variable.   

significance of the model is tested via F-Test
    *a statistical test in which the test statistics has an F-distribution under the null hypothesis. its used to compare statistical models that have been for to a data set, in order to identity the model that best fits the population from which the data were sampled.

serial correlation LM test(Breusch–Godfrey test) shows further confirmation of the model at 99% confidence interval.
    *used to assess the validity of some of the modelling assumptions inherent in applying regression-like models to observed data series

Logit estimation:
logit model belongs to a group of models termed "Classification models"
a multivariate statistical technique used to estimate the probability of an upward or downward movement in a variable.


Neural Network are universal appropriators capable of approximating any continuous function.
The advantage of NNR models over traditional forecasting methods is that the model best adapted to a particular problem cannot be identified. therefore its better to resort to a method that is a generalization of the many models that rely on an a priori model.

The problem of NNR models is because of their Black-box nature. excessive training times, overfitting, large number of parameters required for training are some of the problems.
Therefore deciding on the appropriate network involves much TRIAL AND ERROR.

financial applications time series may well be quasi-random or at least contain noise.
quasi-random: n-tuple to fill n-space uniformly.

Occam's Razor: selecting among competing hypothesis which makes the fewest assumptions.
unnecessary complex models should not be preferred to simpler ones.

the objective is to find a model with the smallest possible complexity and yet still describe the dataset without overfitting

a reasonable strategy in desigining NNR models is to start with one later containing a few hidden nodes and increase the complexity while monitoring the generalisation ability. a crucial factor is determining the number of layers and hidden nodes.

Backpropagation networks are the most common multilayer network and are the most used type in financial time series forecasting (Kaastra and Boyd, 1996).

Because of the pattern matching of NNR models the representation of data is critical for a successful network design.raw data is rarely fed into the network. they are scaled between the upper and lower bounds of the activation function.

another crucial parameter of the network is the learning rate. smaller learning rate slows the learning process. while larger rates cause the rror function to change wildly without continuously improving.

linear cross-correlation analysis: give some indication of which variables to include in a model, or atleast a starting point to the analysis

How to perform Linear-Cross-Correlation?

explained variance:how much variation in that model given a dataset

post training weight analysis helps establish the importance of the explanatory variables  because of no standard statistical tests for NNR models. the idea is to find a measure of contribution a given weight has to the overall output of the network. Such analysis includes examination of a Hinton Graph.

Hinton Graph represents graphically the weight matrix within a network

The MAE and RMSE statistics are scale-dependent measures but allow a comparison between the actual and forecast values, the lower the values the better the forecasting accuracy.
When it is more important to evaluate the forecast errors independently of the scale of the variables, the MAPE and Theil-U are used. They are constructed to lie within [0,1], zero indicating a perfect fit.

The study used rates of return. Mehta 1995 suggests the use of first difference as a way to generate data sets for neural networks.

CONCLUSION
in order to use a NNR model we need to process the time series to a stable non moving series and arrange the input of the network based on the activation function available to the network. Everything else about the NNR remains the same, the regular network parameters should be tested via trial and error to find the best number of hidden nodes or hidden layers.



Saturday, August 11, 2012

Online Trading Academy DVD- Professional Trader Summary


EPS. EPS of a company is measured against its industry, if its lower than the industry EPS then its undervalued. if its higher then its overpriced
http://biz.yahoo.com/p/industries.html

the higher the spread the more the volatility and much more risky

concentrate with a spread of 0.5

buy low, sell high
buy near support, sell near resistant
 everything known or knowable is reflect in its price and volume 60 to 80% correlation
there is no real tool just a series of tools

intraday (5 min, 3 min, 1 min, tick)
Daily (1 year, 180, 90, 60 days)
Weekly/monthly (long term-decade charts)
 what chart to use in a situation?

OpenHighLowClose (OHLC)
Close most important. determines who won
trend line at 67% is as much as you can go. slope of the line

double top- upward trend just before the second top you will see longer candles and trend changes after

 be a defensive trader.

when you see the gap on a weenkend. wait 1 hour to see if there are any changes before trading.a gap down fills up 32% from the closing on friday.

if after gap down, within the house if you see goes up at 60% of the original price, the 60% chnage will close higher

while below 32% might close lower than the opening 70% of the time the percentage is based on fibonnacci

scalping-timeframe is seconds to minutes (need level 2)
very quick when you have alot of tickets.
objective is not to loose, if you do, loose very little
speed is everything-high cost of commissions-high buy power or many trades.

3 rewards to 1 risk
you need to have alot of cash because 100 shares is not worth it. you do 1000 plus shares

momentum trade.immediate momentum swing (need level 2)get out when you can not when you have to.
1 to 10 minute trader
if momentum is slow : GET OUT

swing trade: based on technical analysis. 10 minutes to 2 weeks(2 to 3 days to develop)
look for distinct trend or pattern trade and stick with it

position trader: weeks to months. uses technical anaylsis, stop loss at support lines. Larger risk.
alert to major changes in the market.ties up capital for long periods.

buy on a winner. if you want to buy 1000 stocks of a certain sector, try to find the top dog in an industry. 300 share of microsoft, 300 share of apple, 300 share of quest technology,which ever goes down the most, sell and buy on the one that goes up the most. when left with 2, sell the loss and add to the winner.

dont play mind games, STICK to your PLAN.maintain accuntability.
have an overall strategy (FUNDING, initial capital)
have an each trading day strategy. (think of loss and win on trading)

dont focus on the money, focus on the trade.
if you trade with less than 50% probability, your a fool. anything less, your a gambler.
dont count your chips when your sitting at the table. do that after your out of the game.

discipline is knowing you will follow your rules.
be consistent and repeatability. dont try to do home runs. if you can be profitable with a very small amount its only a matter of volume.

review your plan every day, dont change during trading.
if the plan of trading doesnt work a couple of times, then change or tweek it.
create a worksheet, when did you buy,what did you buy, why did you buy, what prices are there,what stop signs did you put, what is the profit margin.

your in and out according to rule, not anything else.Investors Business Daily.(Check this as a NEWS, they tell you why they think it

will go up through analytical technique. "PAY")
learn from the loosers.very important to learn if you loose, you cant always

win.

85-85-B-B-B is a rating.
85-85:EPS and Relative price strength rating is better than 85% its highly good.
1 - 99 pecrcent rating
B-B-B:Industry Relative price strength rating - sales+profit+return equity -

Accumulation distribution rating
"A" Best to "E" worst

SmartMoney.com - shows you the lead dog
Avg Volume: Average Daily Volume
Share outstanding??

beta - measure the volatilty relative to S&P(1.5 means 50% more)
PPG - price to earning to growth
open up the definitions if you dont answer in the website.

insider trading- legal stuff--shows you the buyer and sellers that are director.big stock move

play with real stocks.dont go for small penny.100$ buys alot of small

stocks.Price 15$-80$
pick the stock with an average volume of 1Million
average trading range:atleast 1$ movement but less that 8%
go to the industy you know about. so when you see the news you know whats going on.

to loose professionaly:
analyze, once you open a trade, only do risk management
be systematic, do not let your emotions change your trading behavior. follow plan and rules.

if there is a significant spread from the buying and selling(Buy:30 - Sell 35).
we sell short at 35 and buy at 30. we gain 5$. we should look at the number of stocks available also.


bid=buy
ask=offer=sell
Take the offer (lift the offer from ask) = Hit the Bid(selling to willing buyer)
demand=support=buyer=bid
supply=resistance=seller=ask

In Level 2
GO short if the number of sell is higher than buy
Go Long if the number of buyer is higher than seller

Look at the economy,then the market then the sector then the stock.
if economy is high, then market is good, and a sector will boom so the stocks should look good.

Know your tool and how to use it.(trading execution)
a float is whats left of the stock. big names always have floats. so you cant

short if the float is low.you cant short if your brokerage doesnt have inventory in a bull market things go down twice as much is it goes up. sell short in a bull market when its up incase it does down.

you can only short on an upstick waiting costs money.sell if you have stocks

10 laws of day trading:

Use Small Shares (dont take large risks until you build a buffer)
When in doubt, get out! (if it doesnt behave like expected, GET OUT)
Learn the difference between gambling and day trading (no overnites)
Dont add to losers(average UP, add to winning position)
dont overtrade (trade more only as you get experience and only if winning,not opposite)9-11.215-330/time
You must use stop loss points
Have a daily limit loss ( 1 to 2% risk capital) capital 25000$ = 250$-500$ limit
be logical not emotional ( control your temper)
dont trade if there are computer problems or slow quotes from the market
be disciplined (hearing is one thing,doing is something else)

OLD KOREAN TRADING PRINCIPLE
Dont lose money, if you do lose money, lose very little money

Monday, August 6, 2012

Summary Book 1 - Chapter 6: Optimizing Parameters and Filtering Trading Signals

Quantitative trading strategies harnessing the power of quantitative techniques to create a winning trading program:


Optimization allows the trader to fine tune a strategy. however many believe fitting strategies to past data yields unrealistic expectations.

parameters are tweaked once a successful strategy is found. ex. Length of the moving average, the volatility multiplier.

to simplify the number of parameters we can use more than one unit per test. for example increment by five insread of one.

optimization is a technique to maximize the expected value of a trading strategy.

The first would use parameters for the current period that had performed best in the prior period. The idea behind this strategy is that strings of past performance are likely to continue, and that as traders we want to stay with parameter sets that are performing the best. The second test selected parameter sets for the current period that performed the worst in the prior period. The idea behind this strategy is that performance is likely to mean revert over time. Parameter sets that have been “cold” and performing poorly are likely to revert and perform well in the future.

avoid trend-following signals when futures are caught in trading ranges but to take trend-following signals when stocks are in trading ranges.

based on the ADX indicator we can select a specific strategy
ADX<15 RSI osscillator
ADX>25 Channel Breakout

Positive autocorrelation exists when greater than average values tend to lead to greater than average values in the next period, and vice versa. Negative autocorrelation exists when greater than average values lead to less than average values.

markets trend roughly 60 percent of the time. The fact that the average falls greater than 50 percent suggests that markets do in fact trend, and we can apply trend-following strategies to exploit this inefficiency.



Summary Book 1 - Chapter 5 - Performance of Portfolios

Quantitative trading strategies harnessing the power of quantitative techniques to create a winning trading program:
 
DON’T PUT ALL YOUR EGGS IN ONE BASKET
Employed by Casino and betting houses for thousands of years.

diversification is spreading your money in a variety of investments.its a risk management strategy

goal help protect the overall value of the portfolio against loss.

Investment that gain value could potentially compensate for those that lose value.

NOTE: diversification only helps when combining non-correlated returns.

Diversification is based on mathematical principles—its advantages are not subject to debate.

Several Diversification Strategies:
Trade ACROSS MARKETS
    Oil, Forex, Sugar Market
Trade ACROSS UNCORRELATED STRATEGIES
    Moving Average, Channel Breakout
Trade ACROSS PARAMETERS WITHIN STRATEGIES
    20/40 of Channel breakout and 40/80 of channel breakout

There is not holy grail. because performance DECAYs over time to zero profitability.