Skip to main content

How to Create and Run a Custom Trading Bot Strategy in Gunbot

Creating a custom trading strategy in Gunbot allows for an individualized approach to automated trading. This guide provides a step-by-step process for setting up and running a custom strategy.

Preparation​

To begin, create a JavaScript file (e.g., awesomeStrategy.js) for your custom strategy and save it in the ./customStrategies folder within your Gunbot installation directory. You can use the built-in code editor in the Gunbot interface or any code editor of your choice.

Info

A custom strategy in Gunbot is a user-defined set of rules and logic, written in JavaScript, that dictates how the trading bot will operate for a specific trading pair.

Creating a Custom Strategy​

Follow these steps to write and set up your custom strategy:

1. Writing the Strategy​

Start by writing your custom strategy logic in the JavaScript file you created. You can leverage the built-in code editor in Gunbot for this purpose.

Custom Strategy Code Editor

2. Selecting the Strategy for a Trading Pair​

When adding or modifying a trading pair in Gunbot, choose "Custom" as your strategy type.

Selecting Custom Strategy

3. Choosing the Strategy File​

In the "Filename" field that appears after selecting "Custom", select the JavaScript file containing your custom strategy.

Choosing Strategy File

Setting Up Indicators​

The "Indicators" tab in the Gunbot strategy settings allows you to control how pre-calculated indicator data is generated. These indicators are then accessible within your custom strategy script. Remember, you are not limited to using only these pre-calculated indicators; your custom strategy can calculate its own or use raw market data.

Indicators Tab

tip

It is recommended to disable the global "Cancel Orders" option when running a custom strategy, as your strategy script should ideally manage its own order lifecycle.

Running the Custom Strategy​

After completing the above steps, your custom strategy is ready to be executed. Ensure all settings align with your trading objectives and enable the strategy for your selected trading pair.

Conclusion​

Custom strategies offer a significant degree of flexibility and control in Gunbot. By following these steps, you can effectively create and implement a trading strategy that aligns with your specific trading goals.