Custom Commands
Last updated
Last updated
A big feature in HaasScript is custom commands. You can create own your commands and reuse them in any script or command. There is also build in cross-editor support. Custom command written in the script editor can be reused in the visual editor without issues.
A custom command can be created by selected Custom Command in the dropdown when creating a new script. Every custom command required atleast 2 commands, DefineCommand() & DefineOutput() and have an option for 2 more. DefineParameter() & DefineOutputIndex()
You can recognize custom commands by the name. Every command has a prefix of CC_. This is required for Haasonline to release new command without conflicting with users custom commands.
-
This command is required and takes 2 parameters. Name & description. The name is the method name that you will use when you call the command from another script. If the name is "DemoCommand" it will be called CC_DemoCommand in other scripts. The description will be visible in the editors hover windows and tooltip information.
The DefineParameter() command is optional and will add required or optional parameters to your custom command. The command takes 6 parameters, all required.
The type of the parameter. This is important for the engine to parse the values correctly and for the Visual Editor to allow the right connections/suggestions. The value can be a string, single number, list of numbers, constant, boolean, dynamic or list of dynamics.
The name of the parameter. This value needs to unique.
A short text to explain the parameter if necessary.
If the value is set on true the parameter needs to be defined when using the command.
The default value serves 2 purposes. Obviously, its the default value for when the parameter isn't required but its also the test value for the script. When the script is run this value will be the value the command returns.
This is where you can suggest which command the caller needs to call in order to get the information. When for example the parameters in an interval we can suggest InputInterval() or CurrentInterval(). The suggest commands can be separated with ,
. The command also supports category names. If for example, our input is a signal enum, we can define Easy Indicators
as a suggestion and all the commands in that category will be suggested.
Some custom command only execute, others return data. If the command doesn't return anything we can set the type to VoidType but if our command returns data we need to define it here.
The data type of the return value. This can be a void or any of the DefineParameter() types.
The value we want the command to return when it's done executing. This value needs to match the defined type.
A short text that reminds us of what we are returning.
This value works the same as the input suggestions of DefineParameter() only with our result type.
This command is an extension to DefineOutput() and only works if our type is a list of number or list of dynamic. The command will create indexable value within your output result. When for example the command calculates 2 EMA and we want to return them both we call DefineOutputIndex() for each index.
The index on which the value is located in your result object. Keep in mind that indexes start at 1.
The type of the result. This is important for the engine to parse the values correctly and for the Visual Editor to allow the right connections/suggestions. The value can be a string, single number, list of numbers, constant, boolean, dynamic or list of dynamics.
The name of the result. This value needs to unique.
A short text to explain the parameter if necessary.
This value works the same as the input suggestions of DefineParameter() only with our result type.