Back to Community
Trailing Stop, How to refill stop orders?

Hi Quants,

Got my algorithm working, but I want to add more. I am looking at Benjamin Graham Fundamentals, and trying to find value in the mkt. I buy on the 3rd day of the month 10 stocks.

I have a function trail_stop, and this contains my trailing stop for the stocks. The stop works well, but when I lose too many orders I lose my leverage, since I only buy at the start of the month. This gives too much time for no return.

My goal would, obviously, be to refill those orders with either other stocks in my pipeline, or some kind of hedge system. Right now, I am shorting the VXX on a moving average.

If the leverage is calculated everyday in the function count_positions, then why can I not
hedge=1-(current_leverage)
And find the hedge that makes my algorithm 1.0?

Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 58a50dd1b3d39a5e0dde2aac
There was a runtime error.
1 response

Hello Quantdog,
Every time a position is added or liquidated your hedge is going to change. You may be better off trying to stay within an acceptable range. You could also add another schedule_function that could calculate your hedge before it is needed or something to that effect.
Hope that helps.