How Can We Help?
Boolean Logic
The scripts shown in this first section may be linked together using Boolean logic just by adding the AND or the OR keyword, for example…
Script 1 evaluates to true when the last price is higher than the open price:
Set BUY = LAST > OPEN
Script 2 evaluates to true when volume is two times the previous day’s volume:
Set BUY =VOLUME > (REF(VOLUME, 1) * 2)
You can aggregate scripts so that your script returns results for securities that are higher than the open and with the volume two times the previous volume:
Set BUY = LAST > OPEN AND (VOLUME > REF(VOLUME, 1) * 2)
Likewise, you can change the AND into an OR to find securities that are either trading higher than the open or have a volume two times the previous volume:
Set BUY = LAST > OPEN OR VOLUME > (REF(VOLUME, 1) * 2)
Once again, the instructions are nearly is plain as the English language. The use of Boolean logic with the AND and OR keywords is a very important concept that is used extensively by Vanguard AI’s VAI Script programming language.
For more complex formulas, best practice is to break it down into multiple lines for readability and workability.
Set PREVIOUS_CLOSE = REF(VOLUME,1)*2
Set BUY = LAST > OPEN OR PREVIOUS_CLOSE