The Variation function in ProBuilder language is used to calculate the percentage change between the closing prices of two consecutive bars on a chart. This function is particularly useful for identifying how much the price has varied from one period to the next in percentage terms, which can be a critical indicator in trading strategies.
Variation(price)
// Calculate the variation in the high prices
var = Variation(high)
// Calculate a moving average of the variation and apply a standard deviation
averagingvar = 3 * STD[20](exponentialaverage[20](var))
RETURN var, averagingvar
This example demonstrates how to use the Variation function to compute the percentage change in the high prices of the bars. It also shows how to smooth this variation data using an exponential moving average and then scale it by three times the standard deviation over 20 periods. This can help in identifying significant changes or anomalies in price movements.
This function is essential for traders who focus on volatility and price changes, providing a straightforward metric to gauge market dynamics.