The Unset function in ProBuilder language is used to reset or clear the contents of an array. This function is particularly useful when you need to reinitialize an array during the execution of a script, effectively removing all previously stored values.
Unset($var)
Suppose you have an array that stores moving average values and you want to clear this array under certain conditions:
For i = 0 To 19
$Array1[i] = average[i]
EndFor
// Condition to reset the array
If close crosses under low[20] Then
Unset($Array1)
EndIf
In this example, $Array1 is initially filled with the moving average values of the closing prices. If the closing price crosses under the low of the past 20 periods, the Unset function is called to clear all values in $Array1, allowing it to be repopulated with new data as needed.
Unset function only affects the array specified and does not delete the array itself. The array can still be used after being unset by reassigning values.