Creating a Moving Average Crossover Indicator

This tutorial explains how to create a custom moving average crossover indicator. A moving average crossover is when two moving averages of different periods cross one another. One of the most used pairs is the 50/200 day moving average. So we’ll use that pair for this example.

Open the indicator builder by picking the Indicators tab from the top menu. Now select Greater than from the drop down menu.

Card image cap

Create a Greater than operator with two moving averages as input

Greater than has two operands. Set both of these to Moving Average.

We set the first moving average to have a period of 50 bars, and the second to have a period of 200 bars.

Card image cap

Set the period of the second moving average to 200

Check that it works by clicking the spy glass icon on the top row. This should show a chart something like the one below.

Card image cap

Click preview to view the result on the chart

The resulting chart shows where the fast moving average, namely the 50-day is greater than the 200 day moving average.

But since we’re interested in the crossover events, we need to add another operator. Select the Greater than operator by clicking on it. Now click the Plus icon (+) from the toolbar. This should add a new row above the one selected.

Select the Gradient operator from the drop down box. Open the parameters for the Gradient and set the shift value to 1 bar. Then click save from the parameters form. We can then check that this works by clicking the spy glass icon on the top row. It should display a chart like the one below.

Card image cap

Add a Gradient operator above, and select preview again

The gradient is positive only where there’s an upwards crossing and is negative where there’s a downwards crossing of our moving averages.

This completes the logic for the indicator. We could filter this further to create a buy signal on an upwards cross and sell signal on a downwards crossover. For this example, we’ll just create a buy signal on any crossover.

To do this, click the Plus icon (+) from the toolbar and select a Buy operator. Then click preview again. The chart should show the buy signals being generated for each crossover event.

Card image cap

Set the output of the gradient to a Buy signal and preview

To see how it performs on a stock for example, we can set the chart to Facebook (FB). Then click preview again to create a chart as shown below.

The crossover indicator performs better on Facebook in this example, than it did on the currency.

Card image cap

Previewing the result on ticker FB

Finally we can save the indicator by clicking the disk icon from the top toolbar and entering a name.

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.