Scripts vs Commands

In HaasScript, you can create two types of scripts: trade bot scripts and custom commands. Trade bot scripts are used to create automated trading strategies, while custom commands are used to create reusable functions that can be called from trade bot scripts or other custom commands.

Trade bot scripts

Trade bot scripts are used to create automated trading strategies that can be run on exchanges. A trade bot script consists of a set of rules that define how the trade bot should buy and sell assets. By default, the trade bot script is executed on a 1-minute basis, and the trade bot will place orders based on the rules defined in the script.

Trade bot scripts cannot be triggered by various events, such as the occurrence of a specific price pattern or the execution of a trade, but will instead be run based a predetermined schedule. Trade bot scripts (or sections of it) can also be set to run on a higher than 1 minute timeframe (such as every 5 minutes or once per day) or lower than 1 minute (10-15 seconds in Cloud, 5-10 seconds in Enterprise).

Trade bot scripts have access to a variety of data and functions that can be used to analyze the market and make trading decisions. For example, trade bot scripts can access real-time price data, order book data, and historical price data. They can also use built-in functions to calculate indicators, such as moving averages and Bollinger bands.

Trade bot scripts can also be used to generate signals that are then provided to other bots and even users. They are also able to read external signals using web-hooks.

Custom commands

Custom commands are used to create reusable functions that can be called from trade bot scripts or other custom commands. Custom commands are created using the DefineCommand function, which takes a name and a description as arguments.

Custom commands can have input parameters and output values. Input parameters are defined using the DefineParameter function, which takes a type, a name, a description, a flag indicating whether the parameter is required, a default value, and an optional list of input suggestions as arguments. Output values are defined using the DefineOutput function, which takes a type, an optional value, an optional description, and an optional list of output suggestions as arguments.

Custom commands are executed when they are called from a trade bot script or another custom command. They can perform a variety of tasks, such as calculating custom indicators, generating trade signals, or formatting data.

Differences between trade bot scripts and custom commands

There are several key differences between trade bot scripts and custom commands:

  • Purpose: Trade bot scripts are used to create automated trading strategies, while custom commands are used to create reusable functions. Trade bot scripts can also be used to generate trade signals for other bots or even users.
  • Execution: Trade bot scripts are executed on a periodic basis, while custom commands are executed when they are called from a trade bot script or another custom command.
  • Access to data and functions: Both trade bot scripts and custom commands have access to all available built-in commands and other custom commands. But custom commands cannot access information in a trade bot script, unless they are passed to them as input parameters. For a trade bot script to get a piece of information from the custom command it uses, the custom command must pass this via its output.

Conclusion

In HaasScript, trade bot scripts and custom commands are two different types of scripts that serve different purposes. Trade bot scripts are used to create automated trading strategies, while custom commands are used to create reusable functions. Understanding the differences between these two types of scripts can help you choose the right tool for your specific needs.

Back to: HaasScript Fundamentals > Getting Started