WiseTrader Toolbox

VariablePeriodLLV

Background

AmiBroker's built-in LLV returns the lowest value of an array over a fixed number of bars. It is the mirror of HHV and is just as common in trading rules — breakout systems, Donchian channels, trailing stops and support detection all rely on knowing the recent low-water mark.

VariablePeriodLLV works the same way but accepts a period for each bar instead of a single fixed look-back, so the window can adapt to market conditions. The per-bar periods often come from an adaptor such as the DominantCycle.

Included formula

This function is one of the building blocks behind the toolbox's Adaptive Smoothed Choppiness Index indicator, which uses it for the lowest-low term of the calculation. To see that indicator, open the Charts window in AmiBroker, expand the WiseTraderToolbox group and drag Adaptive Smoothed Choppiness Index onto a chart. It plots the adaptive Choppiness Index in its own pane below price, with the adaptor (which sets the per-bar period) and the smoother set from its parameters.

The exported function

You can also call this function directly in your own formulas — it works just like AmiBroker's built-in LLV but with a look-back that can change on every bar.

VariablePeriodLLV(DataArray, PeriodsArray)
ParameterDescription
DataArray The array to find the lowest value of.
PeriodsArray An array (or value) giving the look-back to use at each bar when calculating the lowest low value.

Usage

periods = DominantCycle( Close );
lower = VariablePeriodLLV( Low, periods );
Plot( Close, "Price", colorDefault, styleBar );
Plot( lower, "Adaptive LLV", colorRed );