Higher Highs, Bullish Trend Indicator

A way to detect a bullish trend is when the chart begins to make higher highs, and higher lows over a certain period. We’ll show here how to create an indicator to detect higher highs.

To detect these events, we can use the Max function. The Max function works over a set period and outputs the value of the maximum price over that period. For example, if a stock reaches a high of $20 over a 30-day period, then Max returns 20.

As we want to find cases where the highs are increasing, we need to look at places where the Max function is consistently rising without any drops. It should look like a staircase.

To create the indicator, go to the Indicator page & choose the builder tab.

Card image cap

Add a Subtract operator operator

Set the first row to a Subtract operator. Then set the first input to the Max operator.

Card image cap

Add Max operator

Now change the settings of the Max operator by clicking the cogs icon. We’ll use a period of 15 for this example, but you can set this to any length. Once changed, click Save to save the settings.

Card image cap

Change the length of the Max operator to 15 bars

Set the second input of Subtract to Array Shift. We’ll be subtracting adjacent values from the output of Max to check that the highs are rising over a period.

Card image cap

Add Array Shift operator

Now copy the Max stub to the input of the Array Shift. To do this, click the Max row. While holding down the CTRL key, drag the stub to the input of the Array Shift. The indicator builder should look like the image below.

Card image cap

Copy Max stub Array Shift

To check the result so far, click the preview icon on the toolbar of the top row. This is a spyglass icon. The chart should look something like the one below, depending on symbol and time frame. A positive spike is showing where highs are rising, a negative spike shows where highs are falling.

Card image cap

Preview the Subtract

Since we’re only interested in rising highs, we can threshold the output at zero. To do this, add a Threshold operator in the top row. To do this, click the top row with the Subtract operator, then click the plus symbol in the toolbar to add a new row. Set this to Threshold.

Card image cap

Add a Threshold

Previewing the result so far should show that thresholding removes the parts of the chart that are below the zero line, as we needed.

Card image cap

Thresholded result

We can now count the thresholded result and that will tell us how many new highs were broken over a period. We’ll use the CountIF function to do that. CountIF will count a value of 1 everywhere that the operand is true (non zero).

Card image cap

Using CountIF

Add a new row at the top and set that to CountIF. We’ll use a length of 10 bars for the count. Set the Threshold to the operand of CountIF. The result should look like the image above.

Card image cap

Preview CountIF result

Click the spyglass to preview the output of CountIF. It should look something like the chart above.

Card image cap

Add an Equals operator

We want to select places where the number of new highs matches a certain number. For the purpose of this example, we’ll use one new high. That means, with our settings, we’ll find places where the trend is breaking a new high over the past 15 bars.

Card image cap

Set the value to 1 bar

Click the CountIF row, and add a new row above it. Set that row to Equals. Now click the second operand to Equals and click the cogs icon to set its value. We’ll set that to 1.

Card image cap

Add buy operator

Click the Equals row and add a new row above it by clicking the plus icon on the toolbar. Set the new operator to Buy. With this logic, the indicator will create a buy signal whenever there are higher highs over a 15 bar period. We’ll use the weekly time frame for this example, so this means over a 15 week period.

Card image cap

Preview result on GOOG

Click the preview icon in the top row. The chart above shows the result for Google (GOOG) weekly. The indicator has a success ratio of 91% and each signal on average made 20.79% profit.

Card image cap

Preview result on Facebook

Testing on a different symbol, Facebook, gives a success ratio of 93% and an average profit of 27%.

Use this Indicator

Risk Disclosure: Information given on this website is for general purposes only and should not be construed as investment advice. Certain instruments shown here are complex and may come with a high risk of losing money rapidly due to leverage. You should consider whether you understand how these instruments work and whether you can afford to take the high risk of losing your money. Market data displayed is indicative and is not a solicitation to buy or sell.