The right way to use native trailing stop loss
Hello guys.

I am trying to adapt the native traling stop loss into some open source neural net based strategies, but the same problem described at happens. I mean, when the stop loss is triggered, the conditions to buy are satisfied, and the strategy advice to buy again.

In order to avoid that, I am trying to figure out how to put an extra condition, using timeout or any other kind of logic, in order to avoid the strategy to buy again.

The problem is that I am not able to find how to register my code to be notified when the trigger loss got triggered.

Can someone please provide me some sample code for this?

The strategy I am trying to adapt right now is this one

Currently, my go long advice is defined as follows:

      if ('buy' !== this.prevAction && signal === false  && meanAlpha > this.settings.threshold_buy )

        log.debug("**** Buy - Predicted variation: ",meanAlpha);
        if (!this.settings.stoploss_enabled) {
          return this.advice('long');
        } else {
          return this.advice({
            direction: 'long',
            trigger: {
              type: 'trailingStop',
              trailPercentage: this.settings.stoploss_trailPercentage

Thank you

Forum Jump:

Users browsing this thread: