
이 글은 상대적으로 강한 지수 ((RSI) 와 상쇄를 기반으로 한 다중 수량 거래 전략을 소개한다. 이 전략은 RSI 지수를 사용하여 시장의 과매매와 과매매 상태를 판단하고, 과매매 할 때 다중 상점 포지션을 열고, 과매 할 때 평점 포지션을 열다. 동시에, 전략은 백분율 상쇄를 사용하여 위험을 제어한다.
이 전략의 핵심은 상대적으로 강한 약 지수 (RSI) 이다. RSI는 동적 진동 지표로, 한 기간 동안 가격의 변화를 측정하는 데 사용됩니다. 계산 공식은 다음과 같습니다.
RS = N天内上涨幅度的平均值 / N天内下跌幅度的平均值
RSI = 100 - 100 / (1 + RS)
그 중, N은 RSI를 계산하는 시간 주기이며, 일반적으로 14을 다.
이 전략의 논리는 다음과 같습니다.
이 전략은 시장에서 곰이 황소 전환 초기 포지션을 열고, 황소 시장의 마지막에 평소 포지션을 시도하여 주요 상승 추세를 잡기 위해 사용된다.
이 글은 RSI와 스톱을 기반으로 한 다자 양적 거래 전략에 대해 소개한다. 이 전략은 RSI 초과 판매 초과 구매 신호를 사용하여 포지션을 평정하고, 백분율 스톱 리스크를 사용한다. 이것은 실용적인 트렌드 추적 전략이며, 초보자 학습에 적합하다. 그러나, 그것은 또한 약간의 제한이 있습니다.
/*backtest
start: 2023-03-02 00:00:00
end: 2024-03-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Strategy (Long)", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
length = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close
vrsi = ta.rsi(price, length)
co = ta.crossover(vrsi, overSold)
cu = ta.crossunder(vrsi, overBought)
// *** Signals ***
enter_long = ta.crossover(vrsi, overSold)
enter_short = ta.crossunder(vrsi, overBought)
close_long = ta.crossunder(vrsi, overBought)
close_short = ta.crossunder(vrsi, overBought)
// *** Risk management ***
entry_price = close
percent_diff = input(5)
stop_loss_price_long = (1 - percent_diff / 100.) * entry_price
stop_loss_price_short = (1 + percent_diff / 100.) * entry_price
// *** Positions ***
if enter_long and strategy.position_size == 0
strategy.entry("Long", strategy.long)
strategy.exit("SL Long", "Long", stop = stop_loss_price_long)
if enter_short and strategy.position_size == 0
strategy.entry("Short", strategy.short, qty=.001)
strategy.exit("SL short", "Short", stop = stop_loss_price_short)
if close_long
strategy.close("Long", "Exit Long")
if close_short
strategy.close("Short", "Exit Short")