WiseTrader Toolbox

AutoSupport

Background

A support level is a price the market keeps falling to but struggles to drop below. Buyers tend to step in around there, so the price often bounces. The opposite idea is resistance, a level the price keeps rising to but can't get above. These levels are useful because they are places where the price is likely to pause or turn.

AutoSupport finds a support level for you automatically and updates it bar by bar. At each bar it looks back over a window of prices, sorts them, and finds the cluster of values that sit closest together. The more prices that bunch up near the same level, the stronger that level is, so it returns the average of the biggest cluster as the support line. Because it works on any array you hand it, you can run it on the price or on an indicator such as RSI.

Included formula

The toolbox ships a ready-made Automatic Support Indicator built on this function, so you can use it without writing any code. In AmiBroker open the Charts window, expand the WiseTraderToolbox group and drag Automatic Support Indicator onto a price chart. It plots the support line and updates it bar by bar, with the look-back and colour set from its parameters.

The exported function

If you would rather build your own formula, the toolbox exports the calculation as a single AFL function you can call directly — it is the engine inside that indicator.

AutoSupport(Source, LookBack, Threshold)

Parameters

ParameterDescription
SourceThe array the support line is calculated from. This can be the price or another indicator such as RSI.
LookBackThe number of bars to look back over when working out the support level. Must be at least 1.
ThresholdA percentage. How close two prices have to be to count as part of the same support cluster. Larger values group more prices together into one level.

Usage

support = AutoSupport( Close, 50, 1.5 );
Plot( Close, "Price", colorDefault, styleCandle );
Plot( support, "Auto Support", colorBlue );
Note

The first LookBack bars have no value because there isn't enough history yet to work out a level. The Source array must be clean (no empty, infinite or not-a-number values) or the function returns nothing.