It is possible to use custom functions in the Indicator Editor and Strategy editor.
Functions are the same as procedures except that they return a value in addition to executing statements. A function, as its name suggests, is like a little program that calculates something, returning the value to the caller.
It is important to note that we return the value from a function in a special variable called Result that ActFx secretly defines for us to be the same type as the return type of the function. We can call for it at any point in the function. When the function ends, the value held in Result is then returned to the caller.
function Average(a, b, c : Extended) : Extended;
begin
// return the average of the 3 passed numbers
Result := (a + b + c)/3;
end;