Price Mean Reversion

This mean reversion strategy is similar to the Bollinger swing trade. It triggers a buy whenever the price moves more than a set distance below the moving average and a sell when it moves more than a set distance above the moving average line. The price move distance is measured in standard deviations.

Go to the Indicator page & choose the builder tab.

Card image cap

Distance between moving average and median price

Add a subtract operator. Set the first input to a Moving Average. Set the second to median price. This will create a line that’s the distance between the moving average and the median price at any bar. Next add a Greater Than in the top line. To do this, click to select the Subtract row, then click the plus icon in the toolbar. Set the input to Greater Than.

Card image cap

Add Greater Than

Set the second input to Standard Deviation. Click to open the settings box of the standard deviation by clicking the cogs icon.

Card image cap

Add a Standard Deviation

Set the length parameter of the Standard Deviation to 50 and number of deviations to 2.5, or as required.

Card image cap

Configuring the standard deviation

Next set the input to median price. To preview the standard deviation output, click the spyglass icon in that row. The result should look something like the image below.

Card image cap

Preview the standard deviation

Click the top row, and then click the plus icon in the toolbar to add a new row above that one. Then set that row to a Buy operator.

Card image cap

Add a buy operator

This logic will now trigger a buy signal whenever the price falls below 2.5 standard deviations of the mean line (moving average). The length of the standard deviation and the moving average are both set to 50. To preview the output, click the spyglass icon in the top row. The result should look something like the chart below, depending on symbol and timeframe.

Card image cap

Previewing mean reversion strategy

To save the indicator, click the disk icon in the toolbar and choose 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.