Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more...

28
1 Analisi tecnica della dinamica dei prezzi dei titoli azionari di Francesco Martino INDICE: PARTE PRIMA TURNING POINTS Technical analysis: Peaks & Troughs, Trends, Volume 2 Recurring patterns 7 Oscillatori 9 Detecting and forecasting business cycle turning points 11 Swing trading 12 PARTE SECONDA APPLICAZIONE Obiettivi 14 Ambiente di programmazione 14 Idea di fondo 14 Dati operativi 14 Sviluppo dell’applicazione 15 Codice .Net 16 Output 26 Conclusioni 27 BIBLIOGRAFIA 28

Transcript of Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more...

Page 1: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

1

Analisi tecnica della dinamica dei prezzi dei titoli azionari

di

Francesco Martino

INDICE:

PARTE PRIMA – TURNING POINTS

Technical analysis: Peaks & Troughs, Trends, Volume 2

Recurring patterns 7

Oscillatori 9

Detecting and forecasting business cycle turning points 11

Swing trading 12

PARTE SECONDA – APPLICAZIONE

Obiettivi 14

Ambiente di programmazione 14

Idea di fondo 14

Dati operativi 14

Sviluppo dell’applicazione 15

Codice .Net 16

Output 26

Conclusioni 27

BIBLIOGRAFIA 28

Page 2: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

2

TECHNICAL ANALYSIS:

PEAKS & TROUGHS, TRENDS, VOLUME

Peaks and Troughs

Peaks and troughs are patterns that are developed by the price action experienced by all securities.

As we know, prices never move in straight lines, whether in an uptrend or a downtrend.

Analyzing peaks and troughs is a very precise way of identifying trends.

In order to identify peaks and troughs, you need to be able to identify short term trends.

A short term up trend exists when there are two consecutive days of higher highs and higher lows.

A short term down trend is the exact opposite and exists when there is two consecutive days of

lower highs and lower lows.

Once you have identified the short term up and down trends, you can identify the medium term

trends using peaks and troughs. A peak is the highest point between a short term up trend and a

short term down trend. A trough is the lowest point between a short term down trend and a short

term up trend.

The final step is identifying the different peaks and troughs along a chart. When a price exhibits

successive higher peaks and higher troughs, it is in a medium term up trend. When a price exhibits

successive lower peaks and lower troughs, it is in a medium term down trend.

Technical Analysis

Technical analysis is a method of evaluating securities by analyzing the statistics generated by

market activity, such as past prices and volume. Technical analysts do not attempt to measure a

security's intrinsic value, but instead use charts and other tools to identify patterns that can suggest

future activity. Just as there are many investment styles on the fundamental side, there are also

many different types of technical traders. Some rely on chart patterns; others use technical

indicators and oscillators, and most use some combination of the two. In any case, technical

analysts' exclusive use of historical price and volume data is what separates them from their

fundamental counterparts. Unlike fundamental analysts, technical analysts don't care whether a

stock is undervalued - the only thing that matters is a security's past trading data and what

information this data can provide about where the security might move in the future.

In technical analysis, price movements are believed to follow trends. This means that after a trend

has been established, the future price movement is more likely to be in the same direction as the

trend than to be against it. Most technical trading strategies are based on this assumption.

Technical analysis can be used on any security with historical trading data. This includes stocks,

futures and commodities, fixed-income securities, forex, etc.. Technical analysis is more frequently

associated with commodities and forex, where the participants are predominantly traders.

At the most basic level, a technical analyst approaches a security from the charts. Technical traders

believe there is no reason to analyze a company's fundamentals because these are all accounted for

in the stock's price. Technicians believe that all the information they need about a stock can be

found in its charts.

Technical analysis can be used on a timeframe of weeks, days or even minutes.

Page 3: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

3

Trading Versus Investing

Not only is technical analysis more short term in nature that fundamental analysis, but the goals of a

purchase (or sale) of a stock are usually different for each approach. In general, technical analysis is

used for a trade, whereas fundamental analysis is used to make an investment. Investors buy assets

they believe can increase in value, while traders buy assets they believe they can sell to somebody

else at a greater price. The line between a trade and an investment can be blurry, but it does

characterize a difference between the two schools.

Trands

Unfortunately, trends are not always easy to see. In other words, defining a trend goes well beyond

the obvious. In any given chart, you will probably notice that prices do not tend to move in a

straight line in any direction, but rather in a series of highs and lows. In technical analysis, it is the

movement of the highs and lows that constitutes a trend. For example, an uptrend is classified as a

series of higher highs and higher lows, while a downtrend is one of lower lows and lower highs.

The figure below is an example of an uptrend. Point 2 in the chart is the first high, which is

determined after the price falls from this point. Point 3 is the low that is established as the price falls

from the high. For this to remain an uptrend, each successive low must not fall below the previous

lowest point or the trend is deemed a reversal.

Types of Trend

There are three types of trend:

1. Uptrends

2. Downtrends

Sideways/Horizontal Trends As the names imply, when each successive peak and trough is higher,

it's referred to as an upward trend. If the peaks and troughs are getting lower, it's a downtrend.

When there is little movement up or down in the peaks and troughs, it's a sideways or horizontal

trend. If you want to get really technical, you might even say that a sideways trend is actually not a

trend on its own, but a lack of a well-defined trend in either direction. In any case, the market can

really only trend in these three ways: up, down or nowhere.

Page 4: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

4

Trend Lengths

Along with these three trend directions, there are three trend classifications. A trend of any direction

can be classified as a long-term trend, intermediate trend or a short-term trend. In terms of the stock

market, a major trend is generally categorized as one lasting longer than a year. An intermediate

trend is considered to last between one and three months and a near-term trend is anything less than

a month. A long-term trend is composed of several intermediate trends, which often move against

the direction of the major trend. If the major trend is upward and there is a downward correction in

price movement followed by a continuation of the uptrend, the correction is considered to be an

intermediate trend. The short-term trends are components of both major and intermediate trends.

Take a look a figure below to get a sense of how these three trend lengths might look.

When analyzing trends, it is important that the chart is constructed to best reflect the type of trend

being analyzed. To help identify long-term trends, weekly charts or daily charts spanning a five-

year period are used by chartists to get a better idea of the long-term trend. Daily data charts are

best used when analyzing both intermediate and short-term trends. It is also important to remember

that the longer the trend, the more important it is; for example, a one-month trend is not as

significant as a five-year trend.

Trendlines

A trendline is a simple charting technique that adds a line to a chart to represent the trend in the

market or a stock. Drawing a trendline is as simple as drawing a straight line that follows a general

trend. These lines are used to clearly show the trend and are also used in the identification of trend

reversals. An upward trendline is drawn at the lows of an upward trend. This line represents the

support the stock has every time it moves from a high to a low. Notice how the price is propped up

by this support. This type of trendline helps traders to anticipate the point at which a stock's price

will begin moving upwards again. Similarly, a downward trendline is drawn at the highs of the

downward trend. This line represents the resistance level that a stock faces every time the price

moves from a low to a high.

Channels

A channel, or channel lines, is the addition of two parallel trendlines that act as strong areas of

support and resistance. The upper trendline connects a series of highs, while the lower trendline

connects a series of lows. A channel can slope upward, downward or sideways but, regardless of the

direction, the interpretation remains the same. Traders will expect a given security to trade between

Page 5: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

5

the two levels of support and resistance until it breaks beyond one of the levels, in which case

traders can expect a sharp move in the direction of the break. Along with clearly displaying the

trend, channels are mainly used to illustrate important areas of support and resistance.

The Importance of Trend

It is important to be able to understand and identify trends so that you can trade with rather than

against them. Two important sayings in technical analysis are "the trend is your friend" and "don't

buck the trend," illustrating how important trend analysis is for technical traders.

Once you understand the concept of a trend, the next major concept is that of support and

resistance. You'll often hear technical analysts talk about the ongoing battle between the bulls and

the bears, or the struggle between buyers (demand) and sellers (supply). This is revealed by the

prices a security seldom moves above (resistance) or below (support).

As you can see in the figure below, support is the price level through which a stock or market

seldom falls (illustrated by the blue arrows). Resistance, on the other hand, is the price level that a

stock or market seldom surpasses (illustrated by the red arrows).

The Importance of Support and Resistance

Support and resistance analysis is an important part of trends because it can be used to make trading

decisions and identify when a trend is reversing. For example, if a trader identifies an important

level of resistance that has been tested several times but never broken, he or she may decide to take

profits as the security moves toward this point because it is unlikely that it will move past this level.

Support and resistance levels both test and confirm trends and need to be monitored by anyone who

uses technical analysis. As long as the price of the share remains between these levels of support

and resistance, the trend is likely to continue. It is important to note, however, that a break beyond a

level of support or resistance does not always have to be a reversal. For example, if prices moved

above the resistance levels of an upward trending channel, the trend would accelerate, not reverse.

This means that the price appreciation is expected to be faster than it was in the channel.

Being aware of these important support and resistance points should affect the way that you trade a

stock. Traders should avoid placing orders at these major points, as the area around them is usually

marked by a lot of volatility. If you feel confident about making a trade near a support or resistance

level, it is important that you follow this simple rule: do not place orders directly at the support or

resistance level. This is because in many cases, the price never actually reaches the whole number,

Page 6: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

6

but flirts with it instead. So if you're bullish on a stock that is moving toward an important support

level, do not place the trade at the support level. Instead, place it above the support level, but within

a few points. On the other hand, if you are placing stops or short selling, set up your trade price at or

below the level of support.

To this point, we've only discussed the price of a security. While price is the primary item of

concern in technical analysis, volume is also extremely important.

What is Volume?

Volume is simply the number of shares or contracts that trade over a given period of time, usually a

day. The higher is the volume, the more active is the security. To determine the movement of the

volume (up or down), chartists look at the volume bars that can usually be found at the bottom of

any chart. Volume bars illustrate how many shares have traded per period and show trends in the

same way that prices do.

Why Volume is Important

Volume is an important aspect of technical analysis because it is used to confirm trends and chart

patterns. Any price movement up or down with relatively high volume is seen as a stronger, more

relevant move than a similar move with weak volume. Therefore, if you are looking at a large price

movement, you should also examine the volume to see whether it tells the same story.

Say, for example, that a stock jumps 5% in one trading day after being in a long downtrend. Is this a

sign of a trend reversal? This is where volume helps traders. If volume is high during the day

relative to the average daily volume, it is a sign that the reversal is probably for real. On the other

hand, if the volume is below average, there may not be enough conviction to support a true trend

reversal.

Volume should move with the trend. If prices are moving in an upward trend, volume should

increase (and vice versa). If the previous relationship between volume and price movements starts

to deteriorate, it is usually a sign of weakness in the trend. For example, if the stock is in an uptrend

but the up trading days are marked with lower volume, it is a sign that the trend is starting to lose its

legs and may soon end.

When volume tells a different story, it is a case of divergence, which refers to a contradiction

between two different indicators. The simplest example of divergence is a clear upward trend on

declining volume.

Page 7: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

7

Volume and Chart Patterns

The other use of volume is to confirm chart patterns. Patterns such as head and shoulders, triangles,

flags and other price patterns can be confirmed with volume, a process which we'll describe in more

detail later in this tutorial. In most chart patterns, there are several pivotal points that are vital to

what the chart is able to convey to chartists. Basically, if the volume is not there to confirm the

pivotal moments of a chart pattern, the quality of the signal formed by the pattern is weakened.

Volume Precedes Price

Another important idea in technical analysis is that price is preceded by volume. Volume is closely

monitored by technicians and chartists to form ideas on upcoming trend reversals. If volume is

starting to decrease in an uptrend, it is usually a sign that the upward run is about to end.

RECURRING PATTERNS

Head-and-Shoulders

The Head-and-Shoulders price pattern is the most reliable and well-known chart pattern. It gets its

name from the resemblance of a head with two shoulders on either side. The reason this reversal

pattern is so common is due to the manner in which trends typically reverse.

An up-trend is formed as prices make higher-highs and higher-lows in a stair-step fashion. The

trend is broken when this upward climb ends. As you can see in the following illustration, the "left

shoulder" and the "head" are the last two higher-highs

The right shoulder is created as the bulls try to push prices higher, but are unable to do so. This

signifies the end of the up-trend. Confirmation of a new down-trend occurs when the "neckline" is

penetrated.

Page 8: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

8

Rounding Tops and Bottoms

Rounding tops occur as expectations gradually shift from bullish to bearish. The gradual, yet steady

shift forms a rounded top. Rounding bottoms occur as expectations gradually shift from bearish to

bullish. The following chart shows Goodyear and a classic rounding bottom formation:

Triangles

A triangle occurs as the range between peaks and troughs narrows. Triangles typically occur as

prices encounter a support or resistance level which constricts the prices.

A "symmetrical triangle" occurs when prices are making both lower-highs and higher-lows. An

"ascending triangle" occurs when there are higher-lows (as with a symmetrical triangle), but the

highs are occurring at the same price level due to resistance. The odds favor an upside breakout

from an ascending triangle. A "descending triangle" occurs when there are lower-highs (as with a

symmetrical triangle), but the lows are occurring at the same price level due to support. The odds

favor a downside breakout from a descending triangle.

Just as pressure increases when water is forced through a narrow opening, the "pressure" of prices

increases as the triangle pattern forms. Prices will usually breakout rapidly from a triangle.

Breakouts are confirmed when they are accompanied by an increase in volume.

The most reliable breakouts occur somewhere between half and three-quarters of the distance

between the beginning and end (apex) of the triangle. There are seldom many clues as to the

direction prices will break out of a symmetrical triangle. If prices move all the way through the

triangle to the apex, a breakout is unlikely.

The following chart shows Boeing and a descending triangle:

Page 9: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

9

Note the strong downside breakout on increased volume.

OSCILLATORI

Gli "oscillatori" o "indicatori" sono strumenti statistico-matematici, utilizzati per eseguire analisi

più profonde sui grafici . Attraverso di essi è possibile evidenziare informazioni che sfuggono alla

semplice analisi grafica. Queste informazioni sono molto importanti nella pratica di trading e sono i

livelli di ipercomprato e ipervenduto, la volatilità, le divergenze e l‟accelerazione. I segnali degli

oscillatori devono essere utilizzati come conferma o meno di segnali grafici. Gli oscillatori più

utilizzati dai trader e dagli analisti sono:

Media Mobile

Relative Strength Index (RSI)

Momentum

RSI

RSI è sinonimo di Relative Strength Index. Anche questo indicatore fu elaborato da Wilder e

costituisce un‟evoluzione del Momentum. A differenza di questo, l‟RSI considera una media delle

chiusure precedenti. Esso è calcolato considerando la media delle sedute positive dell‟intervallo

temporale preso in esame e la media delle sedute negative nello stesso periodo e dividendo quindi la

media rialzista per quella ribassista. La formula:

RSI= 100 – (100/(1+RS)

RS= rapporto tra MEDIA DELLE CHIUSURE AL RIALZO DI X GIORNI MEDIA DELLE

CHIUSURE AL RIBASSO DI X GIORNI.

Page 10: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

10

Il risultato è rapportato su una scala da 0 a 100, dove i valori 20 e 80 rappresentano le aree di

ipercomprato e ipervenduto. RSI quindi non è un indicatore trend-following, ma ha lo scopo di

evidenziare gli eccessi del mercato. L‟indicatore genera quindi un segnale operativo quando il

valore dell‟indicatore scende dai livelli di ipercomprato/ipervenduto. In pratica l‟RSI misura la

forza della domanda e dell‟offerta e le mette in relazione fra loro.

Media mobile

La Media Mobile è un oscillatore trend-following, ossia analizza la tendenza in atto. Può essere di

tre tipi: semplice, ponderata ed esponenziale. E‟ possibile tarare la Media Mobile in funzione delle

analisi che l‟operatore deve realizzare. L‟esatta taratura della Media Mobile è funzione del profilo

temporale dell‟operazione che si deve svolgere. Infatti un numero di rilevazioni contenute fornirà

una Media Mobile molto reattiva alle variazioni della serie in esame mentre viceversa una Media

Mobile tarata su un numero elevato di sessioni è più indicata a rilevare i movimenti di medio -

lungo periodo.

Nella pratica di trading le medie mobili forniscono un segnale operativo quando sono intersecate dal

grafico del prezzo. Infatti, normalmente la media mobile sta sotto il livello dei prezzi in un mercato

rialzista e sopra il livello dei prezzi in un mercato ribassista. Quando il prezzo "rompe" la media

mobile dal basso verso l‟alto si genera un segnale di acquisto e quando la rompe dall‟alto verso il

basso si genera un segnale di vendita. Un altro metodo operativo consiste nell‟utilizzo di due medie

mobili, una di breve e una di medio - lungo periodo. Quando le due medie si incrociano si genera un

segnale di acquisto/vendita.

Page 11: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

11

Momentum

Il momentum è un altro indicatore della tendenza. E‟ stato elaborato da J. Welles Wilder Jr. assieme

ad un altro famoso oscillatore, l‟RSI. Il Momentum indica la velocità del trend e rapporta l‟ultima

chiusura con quella delle n sessioni precedenti. Ecco la formula:

M = C – Cn

Dove C = ultima chiusura

Cn = chiusura di n periodi precedenti

Ad esempio, per ottenere un Momentum di ordine 10 si sottrae l‟ultima chiusura a quella della

decima sessione precedente. Si ottiene così un valore positivo o negativo che è evidenziato sopra o

sotto la linea dello zero. L‟indicatore ci dice quindi se il mercato si trova in una fase di

accelerazione del trend o di decelerazione dello stesso. Consideriamo un mercato rialzista.

Accelerazione: i prezzi si muovono al rialzo e il Momentum sale; decelerazione: i prezzi aumentano

ma l‟indicatore scende.

DETECTING AND FORECASTING BUSINESS CYCLE TURNING POINTS

Bry and Boschan (1971) cycle-dating Procedure - Don Harding (2003)

Select local peaks and troughs using a rolling window of a given number of quarters.

Step 1: Identification of turning points

In the first step, the local peaks and troughs in real house prices are identified as local maxima and

minima in the series. More formally, a turning point corresponding to a local maximum:

and a turning point corresponding to a local minimum:

The arbitrary choice in this step concerns the number of leads and lags used in the formulas as

denoted by parameter k, or, put differently, the length of the period (corresponding to 2k + 1) on

which local maxima or minima are determined.

Step 2: Identification of major peaks and troughs

Having identified local peaks and troughs using for instance k=6, it turns out that some of them still

capture relatively small fluctuations in prices of only a few per cent and, hence, should not be

considered as major peaks and troughs from a historical perspective. Therefore, we impose in the

second step thresholds on minimum price changes prior and after the turning points with respect to

the price level of neighboring turning points that allows us to call some of the local peaks and

troughs, respectively, as major peaks and troughs. If a local peak or trough fails to satisfy the

threshold rule, it is ignored and we move on to the next local peak or trough and test again.

Page 12: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

12

SWING TRADING

Trading ‘nel breve periodo’

Concentriamo la nostra attenzione su un‟altra tecnica importante del Trading di „breve periodo‟: lo

Swing Trading.

È fondato su operazioni della durata di pochi giorni, al massimo una settimana, e che approfitta

di situazioni, come ipervenduto o ipercomprato, che possono essere particolarmente favorevoli per

l‟investitore, se sfruttate al meglio, e aperte e chiuse negli istanti giusti.

Lo Swing Trading si basa sullo studio tecnico del comportamento del prezzo, che comprende

momenti di forza e di debolezza rispetto alla posizione tecnica del mercato. Le operazioni, come

detto, sono particolarmente frequenti, ma al tempo stesso dalla durata molto limitata.

Titoli particolarmente indicati per lo Swing Trading sono sicuramente le azioni che registrano i

maggiori volumi e con un’elevata volatilità, poiché danno la possibilità di entrare/uscire dal

mercato in tempi relativamente brevi.

Possiamo affermare che lo Swing Trading offre maggiori vantaggi con andamenti di prezzi che, nel

periodo temporale considerato, si invertono, magari crescendo per un determinato periodo, e poi

invertendo l‟andamento.

Swing traders aim to profit from the upswings and downswings in the market, identifying rally tops

to sell into and troughs in price declines in which to buy. The generally accepted view is that the

risk/reward trade-off is at its most favorable when both the mini and major trends are moving in the

same direction, namely when buying at the bottom of the dips in a well-defined uptrend or when

selling at the top of the rallies in a well-defined downtrend.

There is no universally accepted and defined method of swing trading.

Markets spend a lot of time churning around, especially in the smaller time frames, and these sort of

choppy sideways conditions within established ranges are perhaps the best in which to look to

exploit the swings.

Page 13: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

13

There are various practical ways of identifying the swing points at which to trade. Momentum

indicators such as the moving average convergence divergence (MACD) and the relative strength

index (RSI) are good in a sideways market. Clearly it is safer to sell into a rising market if there is a

strong layer of prior resistance and vice-versa. This is especially applicable when shorter-term price

moves encounter multiple layers of support or resistance evident in the daily/weekly chart.

Robert Newgrosh, a seminar trainer sees swing trading as a technique for capturing moves of

anything from two days to two weeks. He uses it to get an entry into a medium term trend, for

example, trying to catch the next upswing in a medium-term uptrend following a retracement. The

idea is to enter the market at a point when the ongoing trend is about to resume. „If the market

closes near its high then this is a good indication that the medium term trend will continue the next

day,‟ he says. „However it‟s dangerous to enter the market just on the back of one day‟s data,

instead I would always look at the bigger picture and check for support or resistance before

deciding on a trade.‟

Page 14: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

14

OBIETTIVI

L‟applicazione si propone di eseguire un‟analisi previsiva su serie temporali di prezzi di azioni.

L‟obiettivo è prevedere dei massimi locali (peaks) e dei minimi locali (troughs) in cui risulti

conveniente a un qualsiasi investitore rispettivamente vendere o comprare una certa quantità di

azioni.

L‟analisi sarà eseguita senza considerare numerose variabili fondamentali in quest‟ambito, come ad

esempio variabili macroeconomiche o volume di acquisti e vendite da parte di tutti gli investitori. Ci

si propone invece di studiare l‟andamento temporale dei prezzi da un punto di vista perlopiù

geometrico. Saranno presi in considerazione solo alcuni concetti fin qui presentati, i quali

risulteranno utili ai fini di una previsione di questo tipo.

Ovviamente l‟applicazione presenterà alcuni punti critici e si baserà su ipotesi solo verosimili;

nonostante ciò potrà essere un buon punto di partenza per lo sviluppo futuro di altre applicazioni

che si basino su concetti simili.

AMBIENTE DI PROGRAMMAZIONE

Il software utilizzato è la versione gratuita di Visual Studio 2010. Il linguaggio di programmazione

è invece .Net, un linguaggio di tipo object oriented utilizzato maggiormente sul sistema operativo

Windows di proprietà della Microsoft.

IDEA DI FONDO

Come già ricordato precedentemente, i concetti presi in considerazione dall‟applicazione sono

solamente quelli che hanno una certa validità dal punto di vista geometrico.

L‟idea che sta alla base dell‟applicazione è di prevedere i turning points (punti di svolta) come punti

di chiusura di un più o meno lungo trend crescente o decrescente. Il primo passo sarà quindi

formulare delle ipotesi valide al fine di poter individuare un trend sulla serie temporale dei dati.

Successivamente saranno individuati dei turning points laddove risulti violato un trend oltre una

certa soglia.

Ovviamente, essendo l‟analisi di tipo previsivo, sarà presente un margine più o meno tollerato di

errore. Al fine di valutare quanto l‟applicazione riesca a individuare validi punti di svolta, si

cercherà di creare un indice di performance che ne misuri l‟efficacia.

DATI OPERATIVI

Le serie temporali dei prezzi sono create in maniera randomica, prendendo come prezzo iniziale la

quantità 1000, la quale varierà di una quota (tick) pari a ± 10 in ogni successivo istante temporale

Page 15: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

15

(anche questo calcolato secondo randomizzazione). Il numero di osservazioni così create sarà 1000,

mentre il numero di serie sul quale poi calcolare una media dell‟indice di performance sarà 10000.

SVILUPPO DELL’APPLICAZIONE

Il primo passo applicativo consiste quindi nel creare la serie randomizzata dei dati. In particolare si

creano contemporaneamente due differenti serie: una che specifica la componente ask dei prezzi e

l‟altra quella bid, rispettivamente il prezzo al quale è possibile acquistare e vendere i titoli azionari

di riferimento. Le due serie sono strettamente connesse, in quanto la seconda è creata

semplicemente differenziando di un tick il dato di tipo ask. Gli intervalli temporali che distanziano

le osservazioni sono anch‟essi creati con logica randomica. Le variabili associate a ciascun dato

sono dunque due (presso e istante), a cui ne viene associata una terza, istante_dec, che altro non è

che la trasformazione in decimali della stessa variabile espressa in formato data.

I passi successivi sono volti all‟individuazione dei trend, la cui violazione porterà alla

determinazione dei turning points. A tal fine risulta indispensabile fare delle ipotesi sulla crescenza

o decrescenza della funzione, cioè sull‟esistenza di uptrend o downtrend locali. La loro

individuazione verte sullo studio rispettivamente di troughs locali e peaks locali: questo è il fulcro

operativo dell‟algoritmo. Con riferimento agli studi di Don Harding (2003), creiamo una finestra

mobile di ampiezza k=5 che scorra i dati ordinatamente. Otteniamo, utilizzando le seguenti

definizioni, un peak locale quando:

e un trough locale se:

dove, come detto, k viene scelto nel presente studio pari a 5.

Notiamo che in questa fase preliminare l‟ottica in cui si lavora non è ancora di tipo previsivo,

poiché, al fine di individuare i punti “stazionari” descritti, ricorriamo a osservazioni successivi ai

massimi o minimi stessi. Ciò è molto importante anche perché, successivamente, sarà impossibile

individuare dei turning points significativi con certezza assoluta, non avendo a disposizione, in

ottica previsiva, alcuna osservazione riferita ad un futuro istante temporale. Detto questo, il presente

lavoro non si propone di prevedere dei punti stazionari assoluti, bensì dei punti in cui risulti

conveniente acquistare o vendere titoli azionari per un investitore.

Torniamo ora all‟applicazione. Contemporaneamente all‟individuazione dei massimi e minimi

locali, avviene anche la formulazione dei coefficienti che determinano i trend lineari. La loro

costruzione avviene secondo ipotesi abbastanza standard, sovente utilizzate nell‟analisi tecnica. Si

dirà perciò che esiste un trend crescente nel momento in cui siano individuati tre troughs locali

consecutivi strettamente crescenti. In modo simmetrico, esisterà un trend decrescente qualora tre

peaks locali consecutivi siano strettamente decrescenti.

Page 16: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

16

A questo punto, senza dimenticare che tutti i presenti passaggi sono effettuati all‟interno del

medesimo ciclo di creazione random dei dati, è possibile determinare una regola secondo cui possa

risultare significativamente violato l‟andamento locale della curva dei prezzi. Tale regola permette

cioè di individuare tali punti una volta violato oltre una certa soglia (l‟1% del prezzo corrente) il

trend lineare già specificato. In particolare, quando la curva scende al di sotto di un uptrend lineare

di più dell‟1%, il prezzo corrispondente sarà etichettato come probabile punto di conclusione

dell‟andamento crescente, cioè come punto sell. Allo stesso modo, se la curva scende sotto un

downtrend lineare oltre l‟1% del prezzo corrente, in quello stesso istante sarà localizzato un punto

buy.

Qualora invece l‟andamento lineare prosegua nel tempo, ogni successivo massimo o minimo locale

osservato rientrerà nel ricalcolo di intercetta e coefficiente angolare dei rispettivi down o up trend.

Tale ricalcolo avverrà fin quando un‟osservazione violi significativamente il trend, momento in cui

la lista contenente i punti determinanti lo stesso sarà svuotata, per poi essere riempita

successivamente con nuovi peaks e troughs.

L‟ultima parte dell‟algoritmo serve invece alla trasposizione grafica del procedimento fin qui

effettuato, la quale avviene standardizzando tutte le 1000 osservazioni della serie temporale create,

al fine di potere essere compatibili con la dimensione del bitmap grafico.

CODICE .NET

Qui di seguito si riporta l‟intero codice sopra riassunto, alla fine del quale viene anche riportata la

definizione della classe osservazione_prezzo con le risepttive proprietà:

Public Class peaks '----------------------------------- 'Creazione generatore numeri casuali '----------------------------------- Public rnd As New Random '--------------------------- 'Creazione bitmap e graphics '--------------------------- Public mybitmap As Bitmap Public mygraphics As Graphics Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ MyBase.Load Me.mybitmap = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height) Me.mygraphics = Graphics.FromImage(Me.mybitmap) End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Button1.Click

Page 17: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

17

'------------------------------------------------------ 'Creazione di tutte le variabili utili all'applicazione '------------------------------------------------------ Dim Origine As Date = New Date(Now.Year, Now.Month, Now.Day, 0, 0, 0) Dim prezzoiniziale As Decimal = 1000 Dim prezzoprec As Decimal = prezzoiniziale Dim istanteprec As Date = Origine Dim istantecorrente As Date Dim prezzocorrente As Decimal Dim sommaprezzo As Decimal Dim mediaprezzo As Decimal Dim sommaistante_dec As Decimal Dim mediaistante_dec As Decimal Dim scartoPrezzo As Decimal Dim scartoIstante_dec As Decimal Dim prodottoScarti As Decimal Dim prodottoScartiIstante_dec As Decimal Dim sommaProdottoScarti As Decimal Dim sommaProdottoScartiIstante_dec As Decimal Dim tick As Double = 10 Dim lista_oss_casuali_bid As New List(Of osservazione_prezzo) Dim lista_oss_casuali_ask As New List(Of osservazione_prezzo) Dim minX As Double = Double.MaxValue Dim maxX As Double = Double.MinValue Dim minY As Double = Double.MaxValue Dim maxY As Double = Double.MinValue Dim ListaPuntiNonTrasformati_bid As New List(Of PointF) Dim ListaPuntiNonTrasformati_ask As New List(Of PointF) Dim ListaPeaks As New List(Of osservazione_prezzo) Dim ListaTroughs As New List(Of osservazione_prezzo) Dim ListaDowntrend As New List(Of osservazione_prezzo) Dim ListaUptrend As New List(Of osservazione_prezzo) Dim CoeffAngDowntrend As Decimal Dim IntercDowntrend As Decimal Dim CoeffAngUptrend As Decimal Dim IntercUptrend As Decimal Dim ListaBuy As New List(Of osservazione_prezzo) Dim ListaSell As New List(Of osservazione_prezzo) '-------------------------------------------------------------------------- 'Inizio ciclo iterativo per la generazione di dati casuali, peaks e troughs '-------------------------------------------------------------------------- For i As Integer = 1 To 1000

Page 18: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

18

'-------------------------------- 'Generazione osservazione casuale '-------------------------------- If Me.rnd.NextDouble < 0.5 Then prezzocorrente = prezzoprec - tick Else prezzocorrente = prezzoprec + tick End If istantecorrente = istanteprec.AddSeconds(Me.rnd.Next(5, 61)) '------------------------------------ 'Aggiunta osservazione bid alla lista '------------------------------------ Dim oss_bid As New osservazione_prezzo With oss_bid .prezzo = prezzocorrente .istante = istantecorrente .istante_dec = ((istantecorrente - Origine).TotalSeconds) End With lista_oss_casuali_bid.Add(oss_bid) '------------------------------------ 'Aggiunta osservazione ask alla lista '------------------------------------ Dim oss_ask As New osservazione_prezzo With oss_ask .prezzo = prezzocorrente + tick .istante = istantecorrente .istante_dec = ((istantecorrente - Origine).TotalSeconds) End With lista_oss_casuali_ask.Add(oss_ask) '---------------------- 'CALCOLO TURNING POINTS '---------------------- Dim j As Integer = i - 1 If lista_oss_casuali_ask.Count > 4 Then '------------------------ 'Localizzazione punti buy '------------------------ If ListaDowntrend.Count > 3 And lista_oss_casuali_ask(j).prezzo > _ IntercDowntrend + CoeffAngDowntrend * lista_oss_casuali_ask(j).prezzo + _ (1 / 100) * lista_oss_casuali_ask(j).prezzo Then ListaBuy.Add(lista_oss_casuali_ask(j)) ListaDowntrend.Clear() '------------------------- 'Localizzazione punti sell '------------------------- ElseIf ListaUptrend.Count > 3 And lista_oss_casuali_ask(j).prezzo < _

Page 19: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

19

IntercUptrend + CoeffAngUptrend * lista_oss_casuali_ask(j).prezzo - _ (1 / 100) * lista_oss_casuali_ask(j).prezzo Then ListaSell.Add(lista_oss_casuali_bid(j)) ListaUptrend.Clear() '-------------------- 'Calcolo peaks locali '-------------------- ElseIf lista_oss_casuali_ask(j - 2).prezzo > _ lista_oss_casuali_ask(j).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo > _ lista_oss_casuali_ask(j - 1).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo > _ lista_oss_casuali_ask(j - 3).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo > _ lista_oss_casuali_ask(j - 4).prezzo Then ListaPeaks.Add(lista_oss_casuali_ask(j - 2)) ListaDowntrend.Add(lista_oss_casuali_ask(j - 2)) '--------------------------------------- 'Calcolo coefficenti downtrend (2 peaks) '--------------------------------------- If ListaDowntrend.Count = 2 Then If ListaDowntrend(0).prezzo > ListaDowntrend(1).prezzo Then CoeffAngDowntrend = (ListaDowntrend(1).prezzo - _ ListaDowntrend(0).prezzo) / (ListaDowntrend(1).istante_dec _ - ListaDowntrend(0).istante_dec) IntercDowntrend = ListaDowntrend(0).prezzo - _ ((ListaDowntrend(0).prezzo - ListaDowntrend(1).prezzo) / _ (ListaDowntrend(0).istante_dec - _ ListaDowntrend(1).istante_dec) * _ ListaDowntrend(0).istante_dec) Else ListaDowntrend.Clear() ListaDowntrend.Add(lista_oss_casuali_ask(j - 2)) End If '---------------------------------------------------- 'Conferma Downtrend e ricalcolo coefficenti (3 peaks) '---------------------------------------------------- ElseIf ListaDowntrend.Count = 3 Then If ListaDowntrend(2).prezzo >= ListaDowntrend(1).prezzo Then ListaDowntrend.Clear() ListaDowntrend.Add(lista_oss_casuali_ask(j - 2)) Else sommaprezzo = 0 mediaistante_dec = 0 For Each oss As osservazione_prezzo In ListaDowntrend

Page 20: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

20

sommaprezzo = sommaprezzo + oss.prezzo sommaistante_dec = sommaistante_dec + oss.istante_dec Next mediaprezzo = sommaprezzo / ListaDowntrend.Count mediaistante_dec = sommaistante_dec / ListaDowntrend.Count scartoPrezzo = 0 scartoIstante_dec = 0 prodottoScarti = 0 prodottoScartiIstante_dec = 0 sommaProdottoScarti = 0 sommaProdottoScartiIstante_dec = 0 For Each oss As osservazione_prezzo In ListaDowntrend scartoPrezzo = oss.prezzo - mediaprezzo scartoIstante_dec = oss.istante_dec - mediaistante_dec prodottoScarti = scartoPrezzo * scartoIstante_dec prodottoScartiIstante_dec = scartoIstante_dec * _ scartoIstante_dec sommaProdottoScarti = sommaProdottoScarti + _ prodottoScarti sommaProdottoScartiIstante_dec = _ sommaProdottoScartiIstante_dec + prodottoScartiIstante_dec Next CoeffAngDowntrend = sommaProdottoScarti / _ sommaProdottoScartiIstante_dec IntercDowntrend = mediaprezzo - CoeffAngDowntrend * _ mediaistante_dec End If '------------------------------------------ 'Ricalcolo coefficenti downtrend (>3 peaks) '------------------------------------------ ElseIf ListaDowntrend.Count > 3 Then sommaprezzo = 0 mediaistante_dec = 0 For Each oss As osservazione_prezzo In ListaDowntrend sommaprezzo = sommaprezzo + oss.prezzo sommaistante_dec = sommaistante_dec + oss.istante_dec Next mediaprezzo = sommaprezzo / ListaDowntrend.Count mediaistante_dec = sommaistante_dec / ListaDowntrend.Count scartoPrezzo = 0 scartoIstante_dec = 0 prodottoScarti = 0

Page 21: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

21

prodottoScartiIstante_dec = 0 sommaProdottoScarti = 0 sommaProdottoScartiIstante_dec = 0 For Each oss As osservazione_prezzo In ListaDowntrend scartoPrezzo = oss.prezzo - mediaprezzo scartoIstante_dec = oss.istante_dec - mediaistante_dec prodottoScarti = scartoPrezzo * scartoIstante_dec prodottoScartiIstante_dec = scartoIstante_dec * _ scartoIstante_dec sommaProdottoScarti = sommaProdottoScarti + prodottoScarti sommaProdottoScartiIstante_dec = _ sommaProdottoScartiIstante_dec + prodottoScartiIstante_dec Next CoeffAngDowntrend = sommaProdottoScarti / _ sommaProdottoScartiIstante_dec IntercDowntrend = mediaprezzo - CoeffAngDowntrend * _ mediaistante_dec End If '---------------------- 'Calcolo troughs locali '---------------------- ElseIf lista_oss_casuali_ask(j - 2).prezzo < _ lista_oss_casuali_ask(j).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo < _ lista_oss_casuali_ask(j - 1).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo < _ lista_oss_casuali_ask(j - 3).prezzo And _ lista_oss_casuali_ask(j - 2).prezzo < _ lista_oss_casuali_ask(j - 4).prezzo Then ListaTroughs.Add(lista_oss_casuali_ask(j - 2)) ListaUptrend.Add(lista_oss_casuali_ask(j - 2)) '--------------------------------------- 'Calcolo coefficenti uptrend (2 troughs) '--------------------------------------- If ListaUptrend.Count = 2 Then If ListaUptrend(0).prezzo < ListaUptrend(1).prezzo Then CoeffAngUptrend = (ListaUptrend(1).prezzo - _ ListaUptrend(0).prezzo) / (ListaUptrend(1).istante_dec - _ ListaUptrend(0).istante_dec) IntercUptrend = ListaUptrend(0).prezzo - _ ((ListaUptrend(0).prezzo - ListaUptrend(1).prezzo) / _ (ListaUptrend(0).istante_dec - ListaUptrend(1).istante_dec) _ * ListaUptrend(0).istante_dec) Else ListaUptrend.Clear() ListaUptrend.Add(lista_oss_casuali_ask(j - 2)) End If

Page 22: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

22

'---------------------------------------------------- 'Conferma Uptrend e ricalcolo coefficenti (3 troughs) '---------------------------------------------------- ElseIf ListaUptrend.Count = 3 Then If ListaUptrend(2).prezzo <= ListaUptrend(1).prezzo Then ListaUptrend.Clear() ListaUptrend.Add(lista_oss_casuali_ask(j - 2)) Else sommaprezzo = 0 mediaistante_dec = 0 For Each oss As osservazione_prezzo In ListaUptrend sommaprezzo = sommaprezzo + oss.prezzo sommaistante_dec = sommaistante_dec + oss.istante_dec Next mediaprezzo = sommaprezzo / ListaUptrend.Count mediaistante_dec = sommaistante_dec / ListaUptrend.Count scartoPrezzo = 0 scartoIstante_dec = 0 prodottoScarti = 0 prodottoScartiIstante_dec = 0 sommaProdottoScarti = 0 sommaProdottoScartiIstante_dec = 0 For Each oss As osservazione_prezzo In ListaUptrend scartoPrezzo = oss.prezzo - mediaprezzo scartoIstante_dec = oss.istante_dec - mediaistante_dec prodottoScarti = scartoPrezzo * scartoIstante_dec prodottoScartiIstante_dec = scartoIstante_dec * _ scartoIstante_dec sommaProdottoScarti = sommaProdottoScarti + _ prodottoScarti sommaProdottoScartiIstante_dec = _ sommaProdottoScartiIstante_dec + prodottoScartiIstante_dec Next CoeffAngUptrend = sommaProdottoScarti / _ sommaProdottoScartiIstante_dec IntercUptrend = mediaprezzo - CoeffAngUptrend * _ mediaistante_dec End If '------------------------------------------ 'Ricalcolo coefficenti uptrend (>3 troughs) '------------------------------------------ ElseIf ListaUptrend.Count > 3 Then

Page 23: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

23

sommaprezzo = 0 mediaistante_dec = 0 For Each oss As osservazione_prezzo In ListaUptrend sommaprezzo = sommaprezzo + oss.prezzo sommaistante_dec = sommaistante_dec + oss.istante_dec Next mediaprezzo = sommaprezzo / ListaUptrend.Count mediaistante_dec = sommaistante_dec / ListaUptrend.Count scartoPrezzo = 0 scartoIstante_dec = 0 prodottoScarti = 0 prodottoScartiIstante_dec = 0 sommaProdottoScarti = 0 sommaProdottoScartiIstante_dec = 0 For Each oss As osservazione_prezzo In ListaUptrend scartoPrezzo = oss.prezzo - mediaprezzo scartoIstante_dec = oss.istante_dec - mediaistante_dec prodottoScarti = scartoPrezzo * scartoIstante_dec prodottoScartiIstante_dec = scartoIstante_dec * _ scartoIstante_dec sommaProdottoScarti = sommaProdottoScarti + prodottoScarti sommaProdottoScartiIstante_dec = _ sommaProdottoScartiIstante_dec + prodottoScartiIstante_dec Next CoeffAngUptrend = sommaProdottoScarti / _ sommaProdottoScartiIstante_dec IntercUptrend = mediaprezzo - CoeffAngUptrend * _ mediaistante_dec End If End If End If '---------------------------------------------- 'Ricalcolo punti bidimensionali delle due liste '---------------------------------------------- Dim x_bid As Single = CSng((oss_bid.istante - Origine).TotalSeconds) Dim y_bid As Single = oss_bid.prezzo Dim x_ask As Single = CSng((oss_ask.istante - Origine).TotalSeconds) Dim y_ask As Single = oss_ask.prezzo ListaPuntiNonTrasformati_bid.Add(New PointF(x_bid, y_bid)) ListaPuntiNonTrasformati_ask.Add(New PointF(x_ask, y_ask)) '---------------------------------------- 'Calcolo dei punti di minimo e di massimo

Page 24: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

24

'---------------------------------------- If minX > x_bid Then minX = x_bid If maxX < x_bid Then maxX = x_bid If minY > y_bid Then minY = y_bid If maxY < y_ask Then maxY = y_ask istanteprec = istantecorrente prezzoprec = prezzocorrente Next '--------------------------------------------- 'Costruzione delle liste dei punti trasformati '--------------------------------------------- Dim ListaPuntiTrasformati_bid As List(Of Point) = _ Me.CalcolaListaPuntiTrasformati(minX, maxX, minY, maxY, _ ListaPuntiNonTrasformati_bid) Dim ListaPuntiTrasformati_ask As List(Of Point) = _ Me.CalcolaListaPuntiTrasformati(minX, maxX, minY, maxY, _ ListaPuntiNonTrasformati_ask) Dim ListaBuyNonTrasformati As New List(Of PointF) Dim ListaSellNonTrasformati As New List(Of PointF) For Each buy As osservazione_prezzo In ListaBuy Dim x_buy As Single = CSng((buy.istante - Origine).TotalSeconds) Dim y_buy As Single = buy.prezzo ListaBuyNonTrasformati.Add(New PointF(x_buy, y_buy)) Next For Each sell As osservazione_prezzo In ListaSell Dim x_Sell As Single = CSng((sell.istante - Origine).TotalSeconds) Dim y_Sell As Single = sell.prezzo ListaSellNonTrasformati.Add(New PointF(x_Sell, y_Sell)) Next Dim ListaBuyTrasformati As List(Of Point) = _ Me.CalcolaListaPuntiTrasformati(minX, maxX, minY, maxY, _ ListaBuyNonTrasformati) Dim ListaSellTrasformati As List(Of Point) = _ Me.CalcolaListaPuntiTrasformati(minX, maxX, minY, maxY, _ ListaSellNonTrasformati) '------------------------------------ 'Implementazione dei dati nel grafico '------------------------------------ Me.mygraphics.FillRectangle(Brushes.LightGray, New Rectangle(Point.Empty, _ New Size(Me.mybitmap.Width, Me.mybitmap.Height))) Me.mygraphics.DrawLines(Pens.Gold, ListaPuntiTrasformati_bid.ToArray) Me.mygraphics.DrawLines(Pens.Blue, ListaPuntiTrasformati_ask.ToArray)

Page 25: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

25

For Each sell In ListaSellTrasformati Me.mygraphics.FillEllipse(Brushes.Black, sell.X - 5, sell.Y + 5, 10, 10) Next For Each buy In ListaBuyTrasformati Me.mygraphics.FillEllipse(Brushes.OrangeRed, buy.X - 5, buy.Y + 5, 10, 10) Next Me.PictureBox1.Image = Me.mybitmap End Sub '---------------------------------------------------- 'Funzione per il calcolo di tutti i punti trasformati '---------------------------------------------------- Function CalcolaListaPuntiTrasformati(ByVal minx As Double, ByVal maxx As Double, _ ByVal miny As Double, ByVal maxy As Double, ByVal listapuntinontrasformati As _ List(Of PointF)) As List(Of Point) Dim listapuntitrasformati As New List(Of Point) For Each puntonontrasformato As PointF In listapuntinontrasformati Dim x As Integer = CInt(mybitmap.Width * (puntonontrasformato.X - minx) / _ (maxx - minx)) Dim y As Integer = mybitmap.Height - CInt(mybitmap.Height * _ (puntonontrasformato.Y - miny) / (maxy - miny)) listapuntitrasformati.Add(New Point(x, y)) Next Return listapuntitrasformati End Function End Class

Classe osservazione_prezzo:

Public Class osservazione_prezzo Public istante As Date Public istante_dec As Decimal Public prezzo As Decimal End Class

Page 26: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

26

OUTPUT

Si riportano anche a titolo esemplificativo due output di dati generate casualmente. Le curve di

colore blu e giallo rappresentano rispettivamente le dinamiche dei prezzi ask e bid. I pallini rossi

indicano invece i punti buy, mentre quelli neri i punti sell:

Page 27: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

27

CONCLUSIONI

Il programma creato si era proposto in fase di costruzione di essere utile nell‟individuazione di

punti di svolta significativi, basandosi esclusivamente su considerazioni di tipo geometrico. Come

visualizzabile negli output precedente, l‟applicazione pecca in efficacia nell‟individuazione di

diversi turning points. Ciò può essere dovuto a tre fattori: la poca consistenza dei trend locali

individuati, l‟ipotesi non sempre rispettata di svolta al momento della violazione di un trend lineare,

la casualità dei dati. A causa della volatilità delle serie create in modo randomico si è inoltre

preferito non ricorrere alla valutazione dei risultati con un indice di performance.

Nonostante ciò l‟applicazione costruita sembra valida dal punto di vista concettuale e formale, per

cui, con coerenti modifiche e integrazioni (ad esempio la possibilità di individuare altri andamenti

di tipo geometrico come l’head and shoulders o triangoli di varia natura), potrebbe sicuramente

fungere da base per la costruzione di nuove applicazioni maggiormente efficaci ed efficienti.

Page 28: Analisi tecnica della dinamica dei prezzi dei titoli azionari · Technical analysis is more frequently associated with commodities and forex, where the participants are predominantly

28

BIBLIOGRAFIA

http://www.investopedia.com/articles/technical/02/070302.asp#axzz1eW0bPru2

Detecting and forecasting business cycle turning points, Don Harding, 2003

Predicting Peaks and Troughs in Real House Prices, Linda Rousová, 2011

http://www.ciaktrading.com/trading-nel-breve-periodo-lo-swing-trading-407

http://www.financial-spread-betting.com/strategies/Spread-swing-trading.html

http://www.higbank.com/index.php?option=com_content&view=article&id=120&Itemid=9

9&lang=en

http://www.optionsoutlet.com/stock_ebooks/technical_analysis_fromAtoZ/reference_chapte

c/indicators/patterns.html

http://www.equis.com/Customer/Resources/TAAZ/?p=113

http://www1.tradermaderesearch.com/guida/indice.asp?disp=1

http://www.operativetrading.it/analisi-tecnica.html