Custom strategies
While Gunbot comes with pre-built strategies, it also provides the flexibility to run your own JavaScript code using custom strategies. This feature is particularly useful for developers who want to customize their trading algorithms and take advantage of Gunbot's exchange connectivity and market data collection features.
📄️ Code examples for custom strategies
Coding a strategy can be as difficult as you want it to be.
Easy trading methods
While writing your own code may seem intimidating, Gunbot provides easy-to-use methods for common tasks like placing orders and requesting additional candle data. Additionally, all the collected market data is easily accessible, so you can focus on implementing your trading strategy rather than worrying about collecting data from multiple exchanges.
📄️ Trading methods
In a custom strategy, you can place or cancel orders and fetch additional OHLCV data using various methods. These methods can be called as functions without waiting for a return value. Alternatively, you can wait for the Promise to resolve when calling a method. This allows you to create a promise chain using the then() method.
📄️ Readily available data
Custom strategies can leverage all available pair data through unique property names. The list below contains pre-calculated indicators based on your strategy's settings. While some indicators use standard inputs without configurable parameters, others offer customization options.
No artificial constraints
Custom strategies in Gunbot allow you to run any JavaScript code that you write, without any artificial constraints on execution time or other limitations. This means that you have complete control over the logic of your trading algorithm, and can implement even the most complex strategies. Furthermore, you can use any external modules or libraries, which significantly extends the functionality of your code.
Visualization options
Custom strategies have access to a range of visualization options that can help you make better trading decisions. These options allow you to display additional data in the Gunbot interface in various ways, depending on your specific needs and preferences.
One of the most popular visualization options is drawing lines on the chart. This can be particularly useful for identifying trends or support and resistance levels. You can also change the color, label and style of the lines to suit your needs. Another option for displaying data is sending notifications to the Gunbot interface, for example to inform about a particular strategy event. If you prefer to keep track of time-based events, you can use markers on the time axis. These markers can be placed at specific points in time,
Finally, if you have specific statistics you want to monitor, you can create your own custom statistics that will show in a sidebar of the chart. This can be particularly useful if you have unique trading strategies or if you want to track specific metrics that aren't available by default in Gunbot
📄️ Visual strategy targets
To easily monitor a custom strategy, trading targets can be visualized as lines on the chart in the GUI.
📄️ Show custom statistics
To add more information to your custom strategies, you can display additional fields on the overview sidebar next to the chart. This is useful for showing your own statistics or other data that's relevant to your strategy.
Connect to third parties
Connecting to third-party services is also possible in a custom strategy. For example, you could connect to a weather API in order to incorporate weather data into your trading algorithm. The possibilities are endless, and custom strategies open up new avenues for traders to explore and experiment with their trading strategies.