Long & Short Signal Generation Algorithm Summary

 

Updated 11/13/2010 

 

I’m going to stop generating this report in a public format for now, but if you’re interested in subsequent updates, contact me at nerses1@verizon.net.                                 

 

The report covers four indicators:

 

Indicator

Prognosis

Volume Adjusted Price Spread

Increased during week

Velocity-Accelerator Indicator Based on Volume-Adjusted Price

Increased during week

Experimental Algorithm – Buy Signals

Two buy signals

Experimental Algorithm – Sell Signals

No sell signals

 

The data base starts at 7/1. There are four outstanding buy positions, two from the previous week and two from this week.  Generating buy signals has to be looked upon as positive. The relative wide spread to liquidate a long position and the relative narrow spread to liquidate a short position is another positive sign.

 

 

Monthly Summary of Performance Results

 

Month

# Buys

# Profit

# Loss

# Shorts

# Profit

# Loss

June

1

1

 

 

 

 

July

5

4

1

1

 

1

August

4

3

1

7

6

1

September

6

6

0

0

 

 

 

 

Out of a total of 16 buy signals between June and September 2010, 14 were correct and out of a total of 8 sell signals, 6 were correct.
Volume Adjusted Price

 

The following chart is the comparison of the price of the S&P 500 (^GSPC) with the volume adjusted price. The volume adjusted price reflects the volume associated with price. If increasing with respect to price, it is bullish meaning up volume exceeds down volume. If decreasing, it is bearish meaning down volume exceeds up volume. There were major sell signals in October and November 2008 and a major buy in March 2009. Another sell signal marked the start of the “Greek-Crisis” market on May 4th of this year, which occurred without any pre-warning. Adjusted price and the unadjusted price have been closely following one another for weeks, but last week the spread widened, a positive sign.

 

 

 

This chart shows the spread between the price and the volume adjusted price since the start of this year. The spread has been essentially constant for weeks; but jumped at end of week from 40 to just under 50. This is bullish if this trend continues.

 

 


Velocity-Accelerator Indicator

 

This is a measure of the rate of change of the volume adjusted price (if vol adj price up +1, if down -1), which is velocity, and the rate of change of velocity, which is acceleration (if rate of change of velocity up +1, if down -1). The indicator is the sum of velocity and acceleration values. Although the spread leveled out last week – it resumed its climb this week, another bullish sign.

 

 

 

 

 

 

 


 

Optimal Spread for Liquidating Long and Short Positions of the S&P 500

 

Before the start of the “Greek Crisis”, the liquidating spread between buy and sell of a long position varied considerably with a minimum of 10 points to as high as 40. The liquidating spread between sell and buy of a short position was about 2 points. This was an indication to avoid going short. With the “Greek Crisis”, the long spread narrowed to two points, an indication of avoiding the long market while the spread associated with short positions widened to 40 points. Hence the spread for liquidation of long and short positions is itself a technical indicator.

 

The following chart shows the spread to liquidate long and short positions profitably. This technical indicator is best used when there is a wide spread for either the long and short position and a narrow spread for the other. This confirms either a bullish or bearish market. It is not really clear what information is contained when the spread is in between these extremes. There was rise in the spread to liquidate from 30 points last week to 43 points this week. Meanwhile the spread to liquidate a short fell from 3 points to 2 points. While this indicator is still under evaluation, the wide spread for liquidating longs and the narrow spread for liquidating shorts can be viewed as positive. Moreover for such a narrow spread on liquidating shorts, short selling should be avoided even if a sell signal is generated.

 

 

Experimental Algorithm

Buy Signals

 

 

Short-Term Long Portfolio

 

The approach being taken is to run the model daily and forecast only for the next day. The recent history of the model results follow.

 

Optimization

Start Date

Optimization

End Date

Forecast

Date

Buy

Signal

 

Result

5/10

6/25

6/28

None

 

5/10

6/28

6/29

None

 

5/10

6/29

6/30

None

 

5/10

6/30

7/1

None

 

5/10

6/30

7/2

Yes

Buy at 1022.2 and was sold two days for a 20 point gain

Based on past data, there were 9 transactions all profitable, but the sell spread to close out a buy position declined from 12 to 6 points, a negative sign

 

The 7/2 buy signal was right on – it came before a week of significant improvement a buy signal can be generated in a bear market when there is a sufficient improvement such as a loss of 10% one day, a loss of 5% the next and a loss of 1% on the third day. The position was liquidated the next trading day for a profit of 8 points – with the market so robust, an investor could have held on to it for greater profit

5/10

7/6

7/7

Yes

Buy at 1030.4 and was sold the same day for a profit of 14 points

5/10

7/7

7/8

Yes

Buy at 1064.7, sold next day for an 8 point gain

5/10

7/8

7/9

None

 

The model turned bullish in generating 2 buy signals in a 4-day trading week, both profitable. The only cautionary note for this week is that the sell point remained six points above the buy signal.

5/10

7/9

7/12

None

Spread to sell widened to 21 points

5/10

7/12

7/13

None

 

5/10

7/13

7/14

None

 

5/10

7/14

7/15

Yes

Buy at 1089.6, sold next day for loss of 11 points

5/10

7/15

7/16

None

 

The model kept us out of the market for the first three days even though the market was strong. It finally generated a buy signal on Thursday, the day before the market declined sharply – the position was liquidated at a loss.

5/10

7/16

7/19

None

 

5/10

7/19

7/20

None

 

5/10

7/20

7/21

Yes

Buy at 1077.1, sold next day for profit of 18.7

5/10

7/21

7/22

Yes

Buy at 1084.8, sold on 7/26 for a profit of 11.0

5/10

7/22

7/23

None

 

Two buy signals, the latter one still open at end of week and sold profitably following Monday

No buy signals for week 7/26-7/30

No buy signals for week 8/2-8/6

No buy signals for week 8/9-8/13

No buy signals for week 8/16-8/20

5/10

8/20

8/23

Yes

Buy at 1074.3 to be liquidated if the market fell to 1060.3, which occurred on 8/25 for a 14 point loss – curiously a sell signal was also generated

5/24

8/23

8/24

No

Data based shortened to increase success rate

5/24

8/24

8/25

Yes

Buy at 1053.4 – spread  indicated a sell at 2 point spread – if this was ignored, this would have been closed out at a higher level

5/24

8/25

8/26

No

 

5/24

8/26

8/27

No

 

Two buy signals generated this week – one sold at a loss and the other at a profit

5/24

8/27

8/30

Yes

Buy at 1056.9, closed out in 2 days at 1065.5 for a net profit of 8.9

5/24

8/30

8/31

No

 

5/24

8/31

9/1

Yes

Buy at 1065.5, closed out the next day for a net profit of 19.7

5/24

9/1

9/2

No

 

5/24

9/2

9/3

No

 

Two buy signals again this week, both profitable

5/24

9/3

9/7

No

 

5/24

9/7

9/8

No

 

6/1

9/8

9/9

No

 

6/1

9/9

9/10

Yes

Buy at 1107.4, closed out following Monday for a net profit of 11.2

Three profitable buy signals this week

6/1

9/10

9/13

No

 

6/1

9/13

9/14

No

 

6/1

9/14

9/15

No

 

6/1

9/15

9/16

Yes

Buy at 1122.2, closed out next day for a net profit of 4.8

6/1

9/16

9/17

Yes

Buy at 1127.0, closed out on Monday for a profit of 8.8

Two buy signals this week, one profitably closed out and one still outstanding

6/1

9/17

9/20

Yes

Buy at 1135.7, closed out next day for a profit of 6.7

6/1

9/20

9/21

No

 

6/1

9/21

9/22

No

 

6/1

9/22

9/23

No

 

6/1

9/23

9/24

No

 

One buy signal this week profitably closed out

6/1

9/24

9/27

No

 

6/1

9/27

9/28

No

 

6/1

9/28

9/29

Yes

Buy at 1144.4

6/1

9/29

9/30

Yes

Buy at 1146.6

6/1

9/30

10/1

No

 

Two open buy signals at end of week, both profitably closed out following week

No Buy signals weeks of 10/4-10/8 and 10/11-10/14 and 10/18-10/22

7/1

10/25

10/22

No

 

7/1

10/26

10/25

No

 

7/1

10/27

10/26

No

 

7/1

10/28

10/27

Yes

Buy signal: 1182.6 next day

7/1

10/29

10/28

Yes

Buy signal: 1186.7 price determined on Monday

Two Buy signals this week

7/1

11/1

10/29

No

 

7/1

11/2

11/1

Yes

Buy signal: 1190.9

7/1

11/3

11/2

Yes

Buy signal: 1209.8

7/1

11/4

11/3

No

 

7/1

11/5

11/4

No

 

Two more Buy signals this week for four open positions

 

 

 

 

 

 

 

Seventeen buy signals were generated versus 14 buy signals last week of which all but was one successful. The spread to close out a losing position remained at 9 points.  The lack of buy signals near the current date below stemmed from current buy signals “disappearing” when the model was reoptimized. But once a signal is generated, it is followed through to consummation even if these are removed during subsequent optimizations.

 

S&P 500

6/15/2010-11/5/2010

 

 

 

 

 

 

 

Experimental Algorithm

Short Signals

 

This model is similarly constructed as the Buy signal algorithm other than Short signals are generated when there is three days of decline in the indicator by a stipulated increment between each day determined by the optimizer. During the upward trend prior to the “Greek Crisis”, short positions were closed out either at a loss of 10 points on the S&P 500 or a profit of only 2 points. This in itself was an indication of not shorting the market. The dynamics of the short market changed dramatically after the “Greek Crisis.”

 

Short-Term Short Portfolio

 

The same procedure is being followed for the short portfolio as per the long portfolio.

 

Optimization

Start Date

Optimization

End Date

Forecast

Date

Short

Signal

 

Result

No short signals from 6/28-7/23

5/10

7/23

7/26

None

 

5/10

7/26

7/27

Yes

A sell signal was generated to short at 1115.4

5/10

7/27

7/28

None

 

5/10

7/28

7/29

None

 

5/10

7/29

7/30

None

 

One short position established on 7/27 still outstanding at end of week. The spread to close out this short was 10 points, which may have caused the position to be closed out on 8/3 – if not, then this would have been a profitable deal; otherwise a loss of 10 points.

5/10

7/30

8/2

None

 

5/10

8/2

8/3

Yes

A sell signal was generated to short at 1121.1

5/10

8/3

8/4

Yes

A sell signal was generated to short at 1124.1

5/10

8/4

8/5

Yes

A sell signal was generated to short at 1122.7

5/10

8/5

8/6

None

 

There are four open short positions; one from the previous week and three from this week. If we assume that the short on 7/27 was closed out for a loss, the three shorts of 8/3-5 would have been profitably closed out the following week for profits in excess of 20 points each. It is a bit remarkable that these short signals were generated during a transient up market preceding a substantial retreat.

No short signals from 8/9-8/20

5/10

8/20

8/23

Yes

A sell signal was generated to short at 1074.3 to be liquidated if the market fell by 15 points, which it did on 8/25 – the gain on the short equaled the loss on the long position generated at the same time

5/24

8/23

8/24

Yes

Data based was shortened to increase success rate. A sell signal was generated to short at 1074.3 and was closed out the next day at 1054.9 for a profit of 19.4 points

5/24

8/24

8/25

No

 

5/24

8/25

8/26

No

 

5/24

8/26

8/27

No

 

Week ended with two short positions closed out profitably

No short signals week of 8/30-10/29

7/1

11/1

10/29

No

 

7/1

11/2

11/1

No

 

7/1

11/3

11/2

No

 

7/1

11/4

11/3

No

 

7/1

11/5

11/4

No

 

Week ended with no short signals

 

 

 

 

 

 

Based on past data, the model generated 12 sell signals versus 9 last week, all but two were profitable. The spread to liquidate a profitable short position declined from 3 to 2 points and the spread to liquidate a loss remained at 10 points. The recent shorts shown below were not generated on a current basis and therefore no short positions were taken. The narrowing spread to liquidate a short position is reason enough to avoid shorting – this can be viewed as positive for market prospects

 

 

S&P 500

6/15/2010-11/5/2010

 

 

 

 


 

Attachment

 

Background Information

 

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 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.

 

As described in the background paper on buy signals (click on Algorithm Background link on www.nerses.com for greater detail), the original selected model worked off the previous 75 days of trading activity for the S&P 500 (^GSPC). As shown below, the model generated a number of buy signals. When a buy signal is generated, the position is to be closed out at a loss if the price goes down by 10 points and at a profit for the price goes up by 13 points. The illustration of the resulting buy signals are shown below for the period 1/6/10-4/23/10, which was in general a bull market since February, 2010.

 

 

The buy signals generated in adding another week’s worth of data subsequent to 4/23 resulted in losses as the upward trend suddenly reversed with the start of the “Greek Crisis” that threatened the very existence of the Euro. The sustained upward trend in stock prices generated buy signals on the eve of t

he “Greek Crisis.” When the market turned, then current buy signals resulted in losses. Further experimentation suggested that the turmoil in the market could best be handled by reducing the data base to the previous 25 trading days for optimization purposes.