Trading System Example: Jeff Cooper 1234

This trading system example is based on chapter 6 of the book Hit and Run Trading by Jeff Cooper, in this example we will separate signal generation part of indicator code from trading system part of indicator code. The benefit of this coding style beside making code more readable is signal generator can be easily replace with another signal generator to make a completely different trading system, also use signal generate part of the code when used in pattern scanner can find trading signals for a basket of symbols.

The signal generation indicator named Jeff Cooper 1234 Signal (Listing 1) has three integer parameters ADX period, +DI period and -DI period, it returns either a 1 (for buy signals), 0 (no signal) or -1 (for sell signals).

1234 signal script

Line 1: this line generate first condition of both buy and sell signals, the ADX call use param1 instead of a number, because a parameter allow users to change it to test out effect of different period number.

Line 2-3: line 2 is second condition of buy signals and line 3 is second condition of sell signals, they are comparing +DI and -DI to generate buy/sell signals, param2 and param3 are adjustable values for the DI indicators.

Line 5-9: line 5 is third condition of buy signals and line 8 is third condition of sell signals.

Right click on 1234 signal script to download 1234 signal script to your local drive, then use indicator manager to install it into NeoTicker.

In this explanation lets concentrate on buy side signals, the sell side signal employ the same logic but opposite detection algorithm.

Buy signals must have either three consecutive lower low bars or two consecutive lower low bars and an inside day to satisfy third condition of a buy signal.

In order to detect a lower low bar in formula language, lowest low bar (llb) indicator with parameter of 2 is used, what llb does is comparing 2 bars and return 0 if current bar is lower of the two bars, so when there is a 0 at current bar that means current bar is lower low bar. Then to detect 3 consecutive lower low bars, a summation with parameter 3 is apply on top of llb, what this summation does is sum up 3 previous llb results, so when there are 3 consecutive llb return 0 means all 3 consecutive bars has lower low than previous bar, this means part 3 of a buy signal is valid.

Another qualifying buy condition require two consecutive lower low bars and an inside day. First sum the first two llb of a three bars set, when a 0 is returned it means there are 2 consecutive lower low bars as previously explained in last paragraph. Next determine if built-in indicator insidebar has return 1 means the current bar is an insidebar. If both conditions are true then part 3 of a buy signal is fulfilled.

Sell signal employ the exact same logic but use hhb to find higher high bars instead of llb used in buy signals generation.

Line 6: this line return result base on all three conditions of buy/sell signals, choose statement is a built-in formula function that allow users to specific multiple conditions and return values.

Next let’s look at the trading system indicator named Jeff Cooper 1234 System (Listing 2), it has two parameters: entry point and position size, it returns the system current equity number.

1234 system script

Line 1: assign param1 to local valuables, this make the code more readable.

Line 3: longstop built-in function in formula language, in condition part of longstop function check for buy signals which means signal indicator returns a greater than 0 value and there is no open position then a long stop trade is issued.

Line 7: when there is a buy signal save current bar low as the initial protective stop price.

Line 10: if best price is greater than entry price which means this position is profitable, change protective stop price to trail stop at 5% below current bar low.

Line 13: formula function to issue an exit order according to exit price resulted from calculation of line 5 and line 6.

Since formula language trade functions are all fill or kill functions, which mean stop orders are issued on every bar, so altering the price of the stop will make a trailing stop.

Line 16: formula function to issue a short stop order when there is no open position and a sell signal is detected.

Line 20: save current bar high as the initial protective stop for sell trades.

Line 22: when sell position is profitable trail stop at 5% above current bar high.

Line 25: issue short exit orders base on stop price calculated from line 8 and line 9.

Line 28: plot current equity and output values of this trading system indicator.

This system is a framework for a system that uses the signal bar high/low as initial stop along with a trail stop, signal generation indicators of this system are interchangeable.

Right click on 1234 system script to download 1234 system script to your local drive, then use indicator manager to install it into NeoTicker.

Click on the link below to purchase the book from

Buy the book

Discuss this article.

One Comment on “Trading System Example: Jeff Cooper 1234”

  1. Janet Burgetti Says:

    just keep on!

Leave a Comment

Blog Developed
By ContentRobot