Time stop losses consider time to be valuable, and if a stock returns below a set value in a given time, they consider the trade to be less than expected and choose to sell. This is a very simple stop-loss strategy, and since the stop-loss line is fixed, it is not good at reducing retracement.
This is a fake code:
if 持仓时间> X 天 and 区间涨幅 小于Y% :
卖出止损
else:
继续持有
Stop loss is a strategy that combines the two ideas of a time value hedge and a dynamic stop loss hedge. The stop loss price changes as the holding cycle changes, and once the stop loss price falls, it is sold.
止损价 =fx ( 持股周期, 期望回报率)
if 现价< 止损价:
卖出止损
阶梯次数= floor(log(1+最大涨幅%)/log(1+阶梯长度%))
止损价位=初始止损价*(1+Y%)^阶梯次数
if 现价<止损价位:
卖出止损
阶梯次数= floor (持股时间(天)/周期X(天))
止损价= 买入价*(1+阶梯次数* Y%)
if 持股时间>周期 X and 现价< 止损价:
卖出止损
else if 持股时间<周期X and 现价<买入价*预设止损比例:
在第一个周期内亏损过多, 卖出止损
else:
继续持有
Limit stop loss: The buy price is set as the benchmark price, and the stock is sold once the price rises by more than X% or falls by more than Y%. This is also a fixed stop loss/stop loss strategy, with the same problem as time stop loss: it is not possible to effectively reduce the pullback.
If the current price > ((1+X%) * Purchase price: Selling and Stopping else if current price < ((1-Y%) * purchase price: Stop loss sale Other: Continue to hold
Tracking Stop Loss The plan is to sell the stock if the retraction is greater than X% of a predetermined value. The stop-loss price of this scheme varies with the change in the highest price, which works well in stock crashes and monopolies.
X=允许最大回撤
if 现价<持股周期内最高价*(1-X %):
卖出止损
else:
继续持有
A ladder stop loss is a dynamic stop loss strategy. The stop loss price varies based on the change in the highest price of the stock during the holding cycle. Similar to the idea of tracking stops, but with a slightly different calculation of the stop loss price, it performs well during a stock catastrophe, but not as well as a ladder stop loss.
M= 初始止损比例
X= 阶梯长度
Y= 阶梯变化率 (阶梯每改变一次, 止损线上涨的幅度)
止损线改变次数=floor[log(周期内最高股价/买入价)/log(1+ X%)]
止损价= M * [1+Y%] ^ 止损线改变次数
if 现价< 止损价:
直接跌破止损价, 卖出止损。
else:
继续持有
The ATR stop-loss is calculated by an indicator called the Average True Range, and the ATR stop-loss is a strategy written based on this indicator.
Raw_ATR=max(|今日振幅|, |昨天收盘-今日最高价|,|昨天收盘-今日最低价|) # 未处理ATR = 这三个指标的最大值
ATR=moving_average (ATR ,N) #真实ATR 为 Raw_ATR 的N 日简单移动平均,默认N=22
Translated from Quantitative investing and machine learning