Tommy Gun

The signal is the setup, entry rule is as follows:

    • Enter the position after the price breaks above the prior day's high, Stop loss below the last support or prior day's low, exit at the first profitable opening.

For bearish trades do the opposite.

#######################################################

#

# TommyGun Algorithm by Larry Williams

#

# Addapted to TOS by Rick Edwards 3/7/2012

#

# Direction = UP

# --------------

# Identifies a shift from bearish to bullish sentiment in a

# downtrend. Position is entered at break above the high on

# the most recent candle that generated the signal.

#

# Direction = DOWN

# ----------------

# Identifies a shift from bullish to bearish in uptrend.

# Position is entered at a break below the low on the most

# recent candle that generated the signal.

#

###############################################################

input Direction = {default UP, DOWN};

plot signal;

switch (Direction) {

case UP: # generate an UP arrow if the

signal = (close - low) > (close[1] - low[1]) # difference between today's open and close

# is greater than yesterday's open and close

and # and

(high - close) < (high[1] - close[1]) # the difference between today's the high and close is

# less than the difference of yesterday's high and close

and # and

(close < close[1] # today's close is less than yesterday's

and # and

close[1] < close[2]); # yesterday's close is less than 2 days ago

case DOWN: # generate an DOWN arrow if the

signal = (close - low) < (close[1] - low[1]) # the difference between today's close and low is

# less than the difference of yesterday's close and low

and # and

(high - close) > (high[1] - close[1]) # the difference between today's high and close is

# greater than yesterday's high and close difference

and # and

(close > close[1] # today's close is greater than yesterday's close

and # and

close[1] > close[2]); # Yesterday's close is greater than the close

} # two day ago

signal.DefineColor("UP", GetColor(1));

signal.DefineColor("DOWN", GetColor(5));

signal.AssignValueColor(if direction == direction.UP

then signal.color("UP")

else signal.color("DOWN"));

signal.SetPaintingStrategy(if direction == direction.UP

then PaintingStrategy.BOOLEAN_ARROW_UP

else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Tommy Gun with "UP" selected

Tommy Gun with "Down" selected