Using HaasScript
Last updated
Last updated
HaasScript is a custom scripting language developed by HaasOnline that offers everything you need to create your custom script. With over 600 built-in commands, it gives you access to (historical) price data, math & TA-calculations, charting, indicator signals, open orders, positions, wallet data and much more.
We offer two IDE's in which you can design scripts: a script editor and visual editor. Both are built on top of HaasScript and have equal functionality but they each offer their own unique way of writing a script.
The script editor is a Lua based IDE for HaasScript. This feature-rich IDE has multiple tabs, an advanced Intelli-sense & cheat-sheet for commands, extensive log, interactive chart, a resizable layout, and much more.
The visual editor is a "node" based IDE for HaasScript. By connecting the result of each command to parameters of the next one you can create a decision-based flow of your script. The visual editor requires little to no coding skills and can be as simple as connecting the dots. The IDE has a built-in Intelli-sense for continuation suggestions, a page-height list of all the commands, multiple tabs, extensive log, interactive chart, a resizable layout and much more.
Besides creating a custom script, HaasScript also allows you to create custom commands. These are reusable scripts written in one of the two editors and are usable in both. These custom commands enable you to move repeating logic into a single command without needing to copy and paste the logic into every script that needs it.
HaasScript offers two styles of trading. Managed and unmanaged trading.
With managed trading, HaasScript will check the bots current position, handle open and partially filled orders, compare the trade amount with the wallet content, exchange specification, and every other aspect of a trade before executing an order. Executing, or rather requesting, signals is as simple as using one of the three basic commands: DoLong, DoShort or DoExitPosition. Read more about managed trading here.
Unmanaged trading gives you the power to execute any order, at any given time and price, with any amount, as well as other specifications. HaasScript will not block orders unless the wallet has insufficient funds to support the order. This freedom allows for very creative entry and exit strategies, dynamic position size, and much more. With this freedom also comes responsibility. A script will need to handle all situations where there are open, canceled, or partially filled orders while also maintaining the bots position direction and exposure. Read more about unmanaged trading here.
HaasScripts offers two sets of TA commands. With the commands in the Technical Analysis category, you can make use of over 50 low-level indicator calculations such as RSI, SMA, IchimokuCloud, and MACD. The source data and parameters are fully customizable, which gives great flexibility and allows you to, for example, smooth the RSI result with an SMA and create a custom chart with the output.
The other set of commands HaasScript offers are the Easy Indicators. This set of commands are plug and play. Once the input fields are rendered, the indicator is calculated and plotted. The command will return a long, short, or no signal. This signal can be executed directly or be combined with other indicators for a unanimous consensus or weighted consensus result. Very easy to use but limited in customization.
Protecting your investment and taking profit are key parts of any strategy. HaasScript offers a wide range of built-in commands to do just that. The so-called Easy Safeties are designed to protect your investment or to take your profits. The commands include, among others, a stop loss, take profit and four different trailing stops.
With HaasScript, you can separate and maintain several positions in a single script. This functionality allows for very creative concepts such as a market-making script where it handles the entry and exit of multiple positions. For each position, you can request information such as entry price, profit, and p/l ratio.