QuantScript doesn't know everything
Sometimes, when you ask QuantScript to compute something, it just... doesn't know what the result is.
When this happens, you get anvalue.
One scenario where QuantScript returns anis if you try to perform a mathematical operation which is undefined, such as dividing by zero.
Another, is when using thetime travel operator to go back more than 499 bars. Due to performance reasons, QuantScript has an imposed limit and cannot resolve a value that's more than 499 bars in the past - so it just returns an value.
This explains why our Debugging strategy failed to open any positions. Its code was:
We know now thatresolves to . But what happens when we compare to ?
Let's sayis equal to 1.1234. Does equal or ?
The answer is - neither. When you ask QuantScript to compare a number to an, it doesn't know how to compare them, so it returns again.
As a matter of fact, any operator which receives anas one of its values(operands), returns an value as its result. There is only one exception to this rule, but more on that in a bit.
Let's look at some expressions which result in anvalue:
Checking for unknown values
The following expression returns, too:
How are we supposed to check if something is, then?
Easy - we have a special operator for this and that operator is the one exception to the rule mentioned earlier - it's called.
You use the operatorto check if a value is known. Makes sense, right?
To do that, you simply write, followed by some value. If the value is known, the result is , otherwise the result is .
Let's look at some examples:
This pretty much wraps upvalues.
Next, we will see why time travelling works just fine, even on the very first bar of a strategy's backtest.