Beispiele zum Technical Trader

ADDITIVE GmbH
Abt. Engineering & Science
Rohrwiesenstraße 2
D-61381 Friedrichsdorf/Ts.
  Tel.:  +49 6172 5905 30
  Fax:  +49 6172 77613
  email: mathematica@additive-net.de
  www:  http://www.additive.net.de

Die Mathematica Applications Library

Mathematica hat sich in den vergangenen Jahren als unentbehrliches Werkzeug im Ingenieurwesen etabliert. Es bietet dem professionellen Anwender, durch seinen mächtigen und fortschrittlichen Funktionsumfang, eine unerreichte Flexibilität bei der Analyse, Modellierung und Visualisierung der während der täglichen Ingenieurarbeit anfallenden Daten. Im Sommer 1994 startete Wolfram Research die Veröffentlichung der Mathematica Anwendungs-Pakete, die dem Benutzer sofort einsetzbare Funktionen aus speziellen Anwendungsbereichen bieten. Dem Anwender wird durch diese Pakete der schrittweise Einstieg in die Thematik bis zum Expertenwissen leicht gemacht. Die Zahl der Zusatzpakete wurde seit dieser Zeit auf über 30 Zusatzpakete erweitert.

Ein Übersicht zu den Zusatzpaketen ist aktuell im INTERNET zu finden.

http://www.additive-net.de/software/mathematica/packages/mma.packages.shtml

System Anpassung Demonstration

Mit den Beispielen in desem Dokument können Sie nur arbeiten, wenn Sie das Zusatzpaket installiert haben. Das ist bei Ihnen nicht der Fall.
Das Dokument stellt damit lediglich eine Demonstration der Möglichkeiten dar.
Nachfolgende werden Ihnen die Möglichkeiten des Zusatzpaketes aufgezeigt.

Introduction

What is Technical Trader?

Technical Trader brings you the latest software concept for testing and implementing financial trading systems.
It takes you beyond conventional systems by providing you with an open and creative work environment that is not limited by a predefined set of tools.
With Technical Trader you have access to tools and techniques that have previously been used only by an elite set of analysts. 
You can prototype an entire trading system in a single language, and you can make rapid modifications to any part of your system without having to maintain more than one set of code.

Features in Technical Traders

General

Numerical and Graphic Equivalency
                              System Testing Using Ito Processes 
                              Arbitrary Extensibility

Data  Import And Data Handling

ASCII, Commodities System
                            Incorportated, and MetaStock Data 
                            Compressed Data and Range Selection

Graphics

• High, Low, Open, Close Plot 
                              • Volume Charting 
                              • Simultaneous Multiple-Plot Viewing 
                              • Japanese Candlestick Charting 
                              • Brownian Motion 
                              • Three-Dimensional Indicator and Stability Analysis 
                              • Three-Dimensional ParametricPrice-Volume-Volatility Representations 
                              •  All of the Major Studies-Point and Figure Plot; 
                              •  Fibonacci Numbers; 
                              •  Arcs, Lines, and Retracement Levels;
                              •  Quadrant Lines; 
                              •  Tirone Levels;
                              •  Automatic Support and Resistant Levels; 
                              •  Trend Search and Quantification; 
                              •  Channel Identification and Validation

Smoothing

• Simple and Center-Weighted Moving Averages 
                              • Exponential Parameter Conversion 
                              • First-, Second-, and Third-Order Exponential Smoothing

Indicators

• Accumulation Distribution 
                              • Median Price 
                              • Bollinger Bands 
                              • Chaikin Oscillator and Volatility 
                              • MACD 
                              • Momentum 
                              • Negative and Positive Volume 
                              • Rate of Change 
                              • Price and Volume Velocity and Acceleration 
                              • On Balance Volume 
                              • Price Volume Trend 
                              • Stochastic Oscillator 
                              • Highest High and Lowest Low 
                              • Percent Oscillator 
                              • PercentK and PercentD 
                              • Weighted Close 
                              • Williams PercentR 
                              • Williams AD

Loading the package

The following command initializes the package.

Needs["TechnicalTrader`Master`"];

Some options which will make my work easier

\($ExampleData; 
standard = TableHeadings -> None; 

    msoptions\  = \ 
      TableHeadings\  -> 
        \ {None, 
          \ {"Date", 
"High", \ "Low", \ "Close", \ 
            "Volume"}}; 

    csioptions\  = \ 
      TableHeadings\  -> 
        \ {None, 
          \ {"Date", \ "C", 
"Vol", \ "OI", \ "CI", \ 
            "COI"}}; \)

Importing data

Before manipulating data, we must read it in a form we can use. There are three basic data formats  can import: CSI, MetaStock, and ASCII. The DataImport package is responsible for functions associated with reading data into Technical Trader.

Reading ASCII data

Here we read the first ten bars of data from the file ASCII file aace.txt.

{m, d, y, o, h, l, c, v} = ReadASCIIData[$ExampleData <>
"aace.txt", 10];

TableForm[%, standard]

Reading CSI data

Here we read the first ten bars of data from the data file f001.dta for the ticker RARE.

!! 
      "C:\\Program Files\\Wolfram \
Research\\Mathematica\\3.0\\AddOns\\Applications\\TechnicalTrader\\Data\\f001.\
dta"

{d, o, h, l, c, v, oi, ci, coi} = ReadCSIData[$ExampleData
<> "f001.dta", -4, 10];

TableForm[%, csioptions]

Reading MetaStock data

msdata  =  ReadMSData[$ExampleData <> "f1.dat",  5,  5];

\(\(SetOptions[TableForm, \ 
      TableHeadings\  -> 
        \ {None, 
          \ {"Date", 
"High", \ "Low", \ "Close", \ 
            "Volume"}}]; \)\)

TableForm[Transpose[msdata], msoptions]

Data Smoothing

Smoothing methods can often help clarify underlying characteristics of time series by removing noise. Here are some examples of smoothing algoritms in Technical Trader

Exponential smoothing

The function ExponentialSmoothing provides for first-, second-, and third-order exponential smoothing. The following plot shows the differences of those three methods.

Moving averages

The centered moving average is often used to prepare data for neural network training as well as for crossover trading systems.

This creates three centered moving average plots of increasing length.

plots = Table[ ListPlot[ CenteredMovingAverage[c, 10 i -1], PlotJoined -> True, PlotStyle -> plotcolors[[i]], DisplayFunction -> Identity], {i, 1, 3}];

Show[Flatten[{hloc1, plots}], DisplayFunction -> $DisplayFunction]

For comparison, here are the simple moving averages for identical length

CandleStickPlot

CandleStickPlot summarizes price activity over a specified period in a vertical bar with the top of the bar indicating the maximum price, the bottom of the bar indicating the minimum price, and two horizontal bars indicating the open and close prices. The open and close horizontal bars are connected by vertical bars forming the rectangular real body of the candlestick. If the open exceeds the close, the main body is filled with color, otherwise it is the same as the background. The two vertical lines that extend from the main body are called the top and bottom shadows.

?TechnicalTrader`Candlesticks`*

We will illustrate candlesticks with data from stock ab.txt.

{m, d, y, o, h, l, c, v} = ReadASCIIData[$ExampleData <>
"ab.txt"];

Then we compress the data by a factor of 50 before showing it with the

{m1, d1, y1, o1, h1, l1, c1, v1} = CompressData[{m, d, y, o,
h, l, c, v}, 50];

\(CandleStickPlot[{h1, \ l1, \ o1, \ c1}, \ Volume\  -> \ v1, \ 
      TradeDates
 -> \ {m1, \ d1, \ y1}, \ NumDates\  -> \ 4]\)

High Low Open Close Plot

A basic HLPlot

Here we display only the high low information

A HLOC plot with trading volume information

A HLOC Plot with Bollinger Bands

Combined HLOC plots

Indicators

The Indicators package consists of algorithms to generate buy and sell signals for a security. The human observer is a crucial component of many trading systems because of the need for pattern recognition: this is a topic computers have yet to fully automate. Indicators can often point the way to further understanding of price and volume action by illuminating market features. All graphical indicators given in this package have numeric equivalents, thus allowing a trader to prototype a system using observations from data, and then move toward an automated refinement using the numeric representations.

Next, we display the indicator functions and their options.

?TechnicalTrader`Indicators`*

Some indicators and indicator graphics

?AccumulationDistribution

?MedianPrice

?BollingerBands

The code for Bollinger Bands is actually quite simple in Mathematica:

\(\(BollingerBands[p_List, periods_, n_:  2]\  := \ 
\ \ 
      Module[{s, m}, \ 
\ \ \ \ 
          s\  = \ Take[SimpleMovingAverage[p, periods], 
              \(-\((Length[p] - periods + 1)\)\)]; \ 
\ \ \ \ 
          m\  = \ MovingStandardDeviation[p, periods]; \ 

          \ \ \ \ {s\  + \ n\ m, \ s, \ s\  - \ n\ m}\ 
\ \ ]\  /; \ 
        Length[p]\  > \ periods\ \)\)

?ChaikinADOscillator

?ChaikinVolatility

?MACD

Of course, Technical Trade can handle indicatorsin more dimensions

Studies

The Studies package examines trend as well as other traditional "studies" such as Fibonacci retracements, arcs, and fan lines. The traditional two-dimensional plot for studying trends is called the "Point & Figure" plot.

Here are the Studies functions and options.

?TechnicalTrader`Studies`*

Let us read in 150 bars from stock ALCO.

{m, d, y, o, h, l, c, v} = ReadASCIIData[$ExampleData <>"alco.txt", {100, 250}];

We will use the hloc plot for the remainder of this section.

hlocplot = HLOCPlot[{h, l, o, c}, HighLowColorList -> {Gray}, OpenColorList -> {Gray}, CloseColorList -> {Gray}, VolumeBorderStyle -> BlueLight, Volume -> v, PlotStyle -> Thickness[.001]];

Point & Figure Plot

The Point & Figure plot is a measure of trend and reversal. By choosing the box size and reversal amounts, in boxes, the Point & Figure plot shows where the trends begin and end.

PointFigurePlot[c, 0.2, 2, XOGraphics -> True]

Fibonacci Numbers

Traders have often used Fibonacci numbers to help gauge future price tops and bottoms, as well as, to assess price support and resistance.

This displays the Fibonacci fan lines over the hloc plot.  The lowest fan line acts as support and the top fan acts as resistance.

Show[{hlocplot, fibofan}, DisplayFunction -> $DisplayFunction]

Next, we examine the Fibonacci arcs together on an hloc plot. The FibonacciArcs suggests resistance and support lines using circular arcs.

Show[{hlocplot, fiboarcs1, fiboarcs2}, DisplayFunction -> $DisplayFunction, AspectRatio -> 1]

Fibonacci Time Zones

The FibonacciTimeZones function projects vertical lines at bars corresponding to Fibonacci numbers. FibonacciTimeZones sometimes predicts market tops and bottoms or vigorous market movement.

Show[{hlocplot, fibotime}, DisplayFunction -> $DisplayFunction]

Fibonacci Retracements

The FibonacciRetracements function. 
FibonacciRetracements is the last of the Fibonacci studies and shows support and resistance levels similar to the fan and arc studies. The six levels can be individually colored and extended forward and back in time to show future and past support and resistance levels.

Show[{hlocplot, fiboret}, DisplayFunction -> $DisplayFunction];

Quadrant Lines

({{"QuadrantLines[{\!\(\*StyleBox[\"\\\"h\\\"\", \"TI\"]\), \!\(\*StyleBox[\"\\\"l\\\"\", \"TI\"]\)}, {\!\(\*StyleBox[\"\\\"m\\\"\", \"TI\"]\), \!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\)}, \!\(\*StyleBox[\"\\\"options\\\"\", \"TI\"]\)]", "separates the high-low range over the interval {\!\(\*StyleBox[\"\\\"m\\\"\", \"TI\"]\), \!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\)} into four quadrants"}})

Show[{hlocplot, QuadrantLines[{h, l}, {50, 100}, ExtendLeft -> 20, ExtendRight -> 40], QuadrantLines[{h, l}, {101, 150}] }, DisplayFunction -> $DisplayFunction]

Tirone Levels

TironeLevels draws a series of horizontal lines using either the Midpoint method or the Mean method. The lines can be extended forward and back in time.

Show[{hlocplot, tironelevel}, DisplayFunction -> $DisplayFunction, PlotRange -> All]

Support & Resistance Levels

Here we show the support and resistance levels

Show[{hlocplot, supres}, DisplayFunction -> $DisplayFunction]

Trends

This shows some calculated channels which correspond to trend durations.

This shows all the channels. We can get a feel for where the system has been linear in the past and where it may be linear in the future with the AllChannels function.

Show[{hlocplot, p2}, DisplayFunction -> $DisplayFunction]