
이 전략은 평평한 이동 평균 (SMA), 상대적으로 강한 지수 (RSI), 실제 범위 (TR) 및 거래량 이동 평균 (Volume MA) 과 같은 지표를 사용하여 트렌드 필터, 거래량 및 변동률 조건과 결합하여 특정 조건이 충족될 때 거래합니다. 이 전략의 주요 아이디어는 가격이 SMA200보다 낮고 하향 추세, 낮은 거래량 및 낮은 변동률이있는 경우 구매하고 중지 손실과 중지 지점을 설정합니다.
이 전략은 트렌드 필터링과 거래량, 변동률 조건을 결합하여 여러 기술적 지표를 통합하여 특정 상황에서 거래한다. 동시에, 명확한 중단 중단 및 비정상적 퇴출 메커니즘을 설정하면 위험을 효과적으로 제어 할 수 있다. 그러나 이 전략에는 파라미터 선택, 시장 비정상적 인 요인 등이 전략의 성과에 영향을 미칠 수 있는 제한이 있습니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Strategia Stop Loss & Take Profit z Filtrem Trendu i Wyjątkiem", shorttitle="Smooth MA SL & TP with Exception", overlay=true)
// Parametry
tp_multiplier = input.float(1.5, title="Mnożnik Take Profit")
sl_percent = input.float(5, title="Procent Stop Loss")
wait_bars = input.int(3, title="Liczba Oczekiwanych Świec")
sma_period = input.int(200, title="Okres SMA")
rsi_period = input.int(14, title="Okres RSI")
vol_ma_period = input.int(20, title="Okres Średniej Wolumenu")
tr_ma_period = input.int(20, title="Okres Średniej Rzeczywistego Zakresu")
// Obliczenie Gładkiej Średniej Kroczącej
sma = ta.sma(close, sma_period)
// Obliczenie RSI
rsi = ta.rsi(close, rsi_period)
// Filtr Trendu
uptrend = close > sma
downtrend = close < sma
// Warunek konsolidacji: Niski wolumen i niska zmienność
niski_wolumen = volume < ta.sma(volume, vol_ma_period)
niska_zmienosc = ta.tr(true) < ta.sma(ta.tr(true), tr_ma_period)
// Warunek Wejścia (Long): Cena poniżej SMA 200 i filtr trendu w strefie czerwonej
warunek_wejscia = close < sma and niski_wolumen and niska_zmienosc and not uptrend
// Warunek Wyjścia ze strategii
warunek_wyjscia = downtrend and close > sma and ta.crossover(close, sma)
// Ustalanie Stop Loss i Take Profit
var float stop_loss = na
var float take_profit = na
var int indeks_wejscia = na
if (warunek_wejscia)
stop_loss := close * (1 - sl_percent / 100)
take_profit := close * (1 + tp_multiplier)
indeks_wejscia := bar_index
// Handel
if (warunek_wejscia)
strategy.entry("Long", strategy.long)
// Warunek Wyjścia: RSI w strefie wykupienia lub Stop Loss/Take Profit
if (strategy.opentrades != 0)
if (rsi > 70)
strategy.exit("Take Profit/Stop Loss", "Long", limit=take_profit)
else if (bar_index - indeks_wejscia == wait_bars)
strategy.exit("Take Profit/Stop Loss", "Long", stop=stop_loss, limit=take_profit)
// Wyjątek: Warunek Wyjścia z Longów na podstawie zmiany trendu
if (warunek_wyjscia)
strategy.close("Long")
// Rysowanie RSI
rsi_plot = plot(rsi, title="RSI", color=color.blue)
// Rysowanie Gładkiej Średniej Kroczącej
sma_plot = plot(sma, color=color.gray, title="Smooth MA", linewidth=2)
// Rysowanie Filtru Trendu
fill(sma_plot, rsi_plot, color=downtrend ? color.new(color.red, 90) : na)