How Can We Help?


You are here:
< All Topics

Vanguard AI’s VAI Script language provides many built-in functions that make programming easier. When functions are built into the core of a programming language they are referred to as primitives. The Simple Moving Average or SMA function is one example: 

set SMA30 = SMA(CLOSE, 30)

In this example, the SMA function tells VAI Script to compute for the 30 day simple moving average.

The values that are contained inside the parenthesis are called arguments. Here there are two arguments in the SMA function. Argument #1 is the closing price, and argument #2 is 30, as in “30 periods”. 

Only one of two things will occur if you use a function incorrectly… VAI Script will automatically fix the problem and the script will still run, or VAI Script will report an error, tell you what’s wrong with the script, and then allow you to fix the problem and try again. 

In other words, user input errors will never cause VAI Script to break or return erroneous results without first warning you about a potential problem.

Let’s take CLOSE out of the SMA function and then try to run the script again:

set SMA30 = SMA(30) 

The following error occurs: Error: argument of ‘SMA’ function not optional. We are given the option to fix the script and try again.

Table of Contents