Homepage | Buy & Sell Side Summary

 

Experimental Algorithm

Generating Buy Signals

 

This model is an experiment for generating buy signals. An algorithm is constructed that takes into account the open, close, high, low and volume of a stock on a given day and integrates this information with the velocity and acceleration of both price and volume adjusted price. Sinusoidal wave patterns are interposed to try to capture the cyclical behavior of prices. A software optimizer is used to find the value of constants in the algorithm that leads to optimal performance. Buy signals are generated when there are three days of upward movement and the increment between each day is a variable determined by the optimizer. The variable is not constant, but changes with time from the inclusion of a sinusoidal function. Optimal performance has two objectives. One is to maximize the sum of total % gain plus maximize the total number of transactions.

 

Model Test 1

(6/8/2009-3/19/2010)

 

The following is the results of the model covering the approximate 9 month period from 6/8/2009 to 3/19/2010 for the S&P 500 (^GSPC). The objective of 7.25 is the sum of the % Gains plus total transactions divided by 100. This objective is designed to give priority to 100% gains over the number of transactions.

 

 

 

 

During this nine-month period, 25 buy signals were generated, which were all successful. The multiple buys take into account that a series of buy signals can be generated before a position is closed out. The Excel formulation requires that these be treated as separate buys. Since the buy signal cannot be calculated until the market has closed, the buying of one unit of stock is done the following day at the average price. The optimizer closes out any position that declines by more than nine points and liquidates a position after it achieves a gain of 13 points. The following chart shows the buy signals in relation to the S&P500 (^GSPC). The thickness of the line indicates multiple buy signals for a number of consecutive days.

 

 

 

Had the optimal values of the algorithm been known in advance of 6/8/2009, a 100% success record would have been achieved. While we can conclude that the optimizer works on past market data, does it work on future data?

 

The methodology for testing the model is to keep the optimizer values constant, but add one week’s of data and see if a buy signal is generated. If so, then the buy signal will be tracked to see what its performance would have been to judge the efficacy of the model. If the price declines after the purchase by nine points, the position will be closed at a loss; if it rises by 13 points, it will be closed with a gain.

 

Two buy signals resulted:

Transaction 1

March 22  Buy: 1160.35

March 30  Sell: 1173.375

Profit: 13.025

 

Transaction 2

March 25  Buy 1172.89

April 6:      Sell: 1187.285

Profit 14.395

 


 

Model Test 2

(6/15/2009-3/26/2010)

 

The next experiment is to replace the original data base dated 6/8/2009-3/19/2010 with data from 6/15/2009-3/26/2010. The optimizer was rerun with the following results.

 

 

 

 

There were 28 buys during this period all of which were profitable $490 based on buying one unit of the S&P. This is a fair profit margin considering that the average value of the S&P500 was 1060, and while 28 units were purchased, the time element of actually holding a position was relatively short. The stop, or sell occurs when the S&P declines from the purchase price by 12 points and or when it rises 13 points above the purchase price. Notice that the constants have changed from the previous one, but not by a large margin. This shows that there is no magical elixir of one formula that can forever predict future buy signals, but on the other hand, all that we are asking is that the model remains valid for one week.

 

Another week of data yielded no new buy signals.

 


 

 

 

Model Test 3

(6/22/2009-4/1/2010)

 

The objective was maximized by increasing the number of transactions at the expense of not having a perfect record of 100% gains; nevertheless 94% accuracy based on 31 transactions is still desirable. During  the optimization process, there was 100% gains, but on about 20 transactions.

 

 

 

 

The timing of these 31 buy signals is shown below. Another week’s of data was added to the spreadsheet and one buy signal was generated on 4/7 at a price of 1183.425.

 

 

Transaction 3

 

April 7     Buy:  1183.425

April 12  Sell:   1196.955

Profit:   13.53

 

 

 

 

 

Model Test 4

(6/29/2009-4/9/2010)

 

The optimizer program was run covering the period 6/29/2009-4/9/2010 with the following results.

 

 

 

 

The objective function was changed to 2 times the total of losses plus the total of transactions divided by 100 to give greater emphasis on the chance of success. Of 32 transactions, 94% were successful. The timing of these 33 successful buy signals is shown below. Another week’s worth of data was added and no buy signals were generated.

 

 

 

 

Model Test 4

(7/2/2009-4/16/2010)

 

As shown below, 31 trades were done of which 29 were successful for a success ratio of 94%.

 

 

 

 

Buy signals are as shown below. Another week’s of data was added and no buy signals were generated.

 

 

 

 

 

Model Test 5

(7/6/2009-4/23/2010)

 

 

 

 

 

 

The profit is $456 with a success ratio of 100%. The question is what would happen in the time frame were shortened? Four weeks will be shaved off the time frame consecutively to see what the impact would be. The next run reduces time by one week.

 

 

 

Model Test 5a

(7/13/2009-4/23/2010)

 

 

 

The profit of $457 is $1 above the previous run and the number of transactions remains the same.

 

 

 

Model Test 5b

(7/20/2009-4/23/2010)

 

 

 

 

The profit has declined to $398 and the number of transactions to 23.

 

 

 

Model Test 5c

(7/27/2009-4/23/2010)

 

 

 

 

Both the profit and the number of transactions have increased significantly. The buy signals are shown below and many occur during the early stages of an upswing in price. No buy signals resulted in adding one week’s of data.

 

 

 

 

Model Test 5d

(8/3/2009-4/23/2010)

 

 

 

 

While the profit has been reduced from $611 to $480, the number of transactions increased from 34 to 36.

 

 

 

Model Test 5e

(8/10/2009-4/23/2010)

 

 

 

The profit improved to $642 and the number of transactions declined from 36 to 33. So far the experiments show that the data base can be reduced and obtain comparable results. Having less data should presumably make the model more sensitive in sensing changes in the future.

 

 

 

Model Test 5f

(8/17/2009-4/23/2010)

 

 

 

 

The profit decreased from $642 to $487 and the number of buy signals increased from 33 to 36.

 

 

 

Model Test 5g

(8/24/2009-4/23/2010)

 

 

 

 

The model improved considerably by shortening the S&P 500 data base with a record $897 in profits and 51 successful transactions.

 

 

 

One cannot argue over the efficacy of the buy signals. A week’s worth of data was added, but no further buy signals were generated.

 

 

 

Model Test 5h

(8/31/2009-4/23/2010)

 

 

 

 

The model had less in profits ($577 vs $897) in profits and less successful transactions 43 vs 51).

 

 

 

Model Test 5i

(9/8/2009-4/23/2010)

 

 

 

 

This is the best test so far in terms of profitability.

 

 

 

 

The following table summarizes results so far (end date is 4/23/2010).

 

 

Start Date

Objective Value

Profit

% Gains

#Transactions

6/8/2009

7.25

$451

100%

25

6/15

7.28

$490

100%

28

6/22

10.17

$435

97%

31

6/29

20.05

$451

97%

32

7/2

20.04

$431

97%

31

7/6

20.26

$456

100%

26

7/13

20.26

$457

100%

26

7/20

20.23

$398

100%

23

7/27

20.34

$611

100%

34

8/3

20.36

$480

100%

36

8/10

20.33

$642

100%

33

8/17

20.36

$487

100%

36

8/24

20.51

$897

100%

51

8/31

20.43

$577

100%

43

9/8

20.50

$938

100%

50

 

 

The next table continues the process without graphical presentations. The Stop point was 28 and the Stop point was 13 meaning that a purchase would be allowed to become a loss for 28 points before being closed out and the profit would run for 13 points before being the position was closed. On run for 9/29, the Stop was given a maximum of 10 points and the Sell point increased to 28 points when optimized. One out of 31 positions generated a loss and the profit margin increased even though the number of transactions was less.

 

 

Start Date

Objective Value

Profit

% Gains

#Transactions

9/15

20.49

$782

100%

49

9/22

20.44

$486

100%

44

9/29

19.81

$892

97%

31

10/5

20.07

$1,111

93%

40

10/12

20.00

$883

91%

33

10/19

20.51

$753

100%

51

10/26

20.30

$476

98%

43

11/2

20.19

$555

100%

19

11/9

20.19

$555

100%

19

11/16

20.30

$664

100%

30

11/23

20.38

$494

100%

38

11/30

24.19*

$526

100%

19

12/7

24.20

$552

100%

20

12/14

24.19

$682

100%

19

12/21

24.31

$964

100%

31

12/28

24.27

$1,088

100%

27

1/4/2010

24.24

$1,016

100%

24

1/11

24.25

$1,000

100%

25

1/18

24.29

$1,033

100%

29

1/25

24.28

$1,006

100%

28

2/1

24.25

$892

100%

25

2/8

24.25

$787

100%

25

2/15

24.21

$656

100%

21

2/22

24.17

$538

100%

17

3/1

24.22

$332

100%

22

3/8

24.17

$330

100%

17

3/15

24.10

$224

100%

10

 

 

*Model expanded to 12 potential buys.

 

The last run was only 30 weeks of data. The fall-off in values is primarily caused by not sufficient time for all the buy signals to be consummated (the model only evaluates complete buy and sell trades). However the last run did not have any open positions as of 4/23/10. This shows that the model can be run on a relatively short data base in terms of time. The best performance in terms of profitability started about the start of the year for a period of approximately 4.5 months or, say, 75 trading days of data. After running the optimizer using 75 days of data, the results shown on the next page were obtained.

 

 

 

 

This resulted in the following buy signals.

 

 

 

 

This is the model being evaluated.

 

 

Homepage | Buy & Sell Side Summary