Trading with HaasScript

HaasScript supports 2 different styles of trading. Managed trading and Unmanaged trading. Managed trading is an easy but restricted way of trading. Unmanaged is unrestricted but requires more attention to open, canceled or partially filled orders and the bot's position and exposure.


Managed Trading

Unmanaged Trading




Trade amount



Build in order handling



Build in position handling



Trade markets per script



Open positions per script



Shorting on spot



Partial filled orders



Managed Trading

Managed trading provides a controlled and easy way of trading in HaasScript. The command will perform all the necessary checks before executing a trade. They will block execution when there are open orders and make sure the size of the open position doesn't exceed the current trade amount. The collection contains 5 commands.


The DoLong command is where we request to buy an asset on spot or open a long position on leverage. If the bot is already in a long position, no trades will be executed.


The DoShort command is where we request to sell an asset on spot or open a short position on leverage. No trades will be executed if we are already in a short position.


The DoExitPosition command will exit any position that the bot might be in. If it is long, we will close the long and vice versa.

Support Commands

Those 3 commands are the basic managed trading commands. HaasScript also has an extra set of commands who will execute the basic commands but only when certain conditions are met.

DoSignal works in combination with signal constants like SignalLong, SignalShort or SignalExitPosition which are returned by the easy indicators amount others. Respectively it will execute DoLong, DoShort or DoExitPosition depending on the input.

The DoFlipPosition command can be used if we want to flip sides. It can be useful if we, for example, want to change position when our take profit level has reached. The command will execute DoLong if we are short and DoShort if we are long.

pageTrade Actions (Managed)

Order Handling

Although script using the managed trading command don't have to check for open orders, there are commands available for that kind of information and actions. Have a look at the Order Handling command here.

pageOrder Handling

Order Persistance

Order persistance can be enabled with the EnableOrderPersistence() command. The following orders are allowed to be executed again:

  • Orders that are rejected due to maker templates

  • Orders that have reached their timeouts

  • Orders that never made it to the exchange due to connection issues or exchange overloads.

Failed orders due to the following reasons are not executed again:

  • Insufficient funds.

  • Unknown account ID.

  • Unknown market.


Unmanaged Trading

With unmanaged trading, there are no restrictions. The script has freedom over the price and amount, order type, timeout, and much more. The unmanaged trading command will not block orders based on current open orders, position direction or size. Before executing an order the script must perform the necessary checks himself. The commands are trading type-specific and can only be used when having the same trading type selected.

Learn more about trading, orders and positions here

pageTradingpageOrder HandlingpagePositions Handling

Executing Trades

Executing trades can be done with 1 of 6 commands. PlaceBuyOrder & PlaceSellOrder for spot trading and PlaceGoLongOrder, PlaceExitLongOrder, PlaceGoShortOrder & PlaceGoLongOrder for margin/leverage trading. Each command will return a unique identifier we can use to retrieve information about the order.

Support Commands

Additionally, there are 2 extra commands which can be used. The PlaceCancelledOrder will execute a cancelled order with the remaining amount and return a new order identifier. PlaceExitPosition order can be used to place exit orders for a specific bot position. The command takes a positionId which would be the same as the one specified in the place order commands.

pageUnmanaged Trading GuidepageTrade Actions (Unmanaged)

Monitoring Orders

With the return value of the place order command we can monitor the order status or cancel the order. We can use both the specific and the generic command to monitor and cancel the order.

pageOrder Handling

Order Information

Specific information about the orders such as open time, filled or cancelled amount and others are available with the following commands. The OrderContainer will return a collection of every detail about the order in a result object.

pageOrder Information

Position Information

Once orders are filled, the HaasScript engine will create and maintain information about the position. All the details about this position such as price, amount and price, can be requested with the following commands.

pagePosition Information

Last updated