Use a custom trailing stop within your trading strategy

Ekliptor

Administrator
Staff member
Requirements:

Getting started:

WolfBot has 2 way to place stops. The first and easier way is to simply add an appropriate strategy to your configuration.
This has the following advantages:
  • 0 coding skills required
  • configurable parameters for every stop strategy
  • many well-tested stop and take profit strategies available that work independently of your new code being tested/developed
Examples of such strategies are:

However, you may want to place a stop that is controlled by your own code to be further customizable. For this use case, WolfBot offers an abstract strategy wich you can easily integrate into your own trading strategy. The class is called AbstractTrailingStop.
You can extend this class and to easily control your own trailing stop. The strategy is called TrailingStop, but you may actually also increase or cancel the stop again.

To place the first stop simply call (within your trading strategy):
JavaScript:
this.updateStop(true);
This places the first stop. To update a stop (a stop price must already be set with a previous call) you can use the same function with "false" as parameter: this.updateStop(false);

The stop price comes from additional configuration properties which are automatically available in your strategy config:
JSON:
        "MyStrategy": {
          "closePosition": "profit", // close at profit|loss|always
          "trailingStopPerc": 0.5, // the trailing stop percentage
          "time": 0, // wait x seconds after the trailing stop price has been reached before closing the position
          "enableLog": true
        },
That's all! You don't have to call buy/sell functions etc.. WolfBot automatically keeps track of your position and executes the stop once you initiated it with this.updateStop(true); in your strategy.
 
Last edited: