polakowo / vectorbt

Find your trading edge, using the fastest engine for backtesting, algorithmic trading, and research.

Home Page:https://vectorbt.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specific values for stop loss BUT DIFFERENT FOR LONG/SHORT STOP

Headloss opened this issue · comments

  1. How does it work for strategies with fixed long and stop prices at same time? I imagine it could only be the same percents not separate ones for long and short.
  2. Are the sl_stop percents only a signal or a "ffill_ed" stops persisting from the signals? I assume it should be the latter.
  3. Could one add a fixed stop to exit as a signal, to solve problem 1 if problem 2 statement is a "one-time signal"?

 

Discussed in #338

Originally posted by ironstone05 January 18, 2022
Hi, I have just started with algo trading and use this library to backtest my strategies. Its really great. However, I am having trouble with one specific thing.
I am trying to set the stop loss (and profit) to an exact value instead of a percentage. For eg., for the particular scalping strategy I am testing, I want to set the stoploss to the low of the previous candle and take profit at 1.5 times the risk. Since the margins are low, I want to have better control over the stop loss. Is there a way to set it in such a manner? I went through the documentation and think that either the adjust_sl_func_nb or the stop_exit_price functions are to be used maybe. However, I am unsure on the implementation. It would be great if I could get some help.
Currently, this is the code I am using to backtest:
pf = vbt.Portfolio.from_signals(price, entries, sl_stop= 0.0001, tp_stop= 0.0002, init_cash=10000)

Thanks a lot and kudos on this wonderful implementation! The feature set is so very deep and I am sure I have a long way to go before I understand everything about the library.