
이 전략은 주로 주류 암호화폐를 대상으로 거래하고, 매일 거래 빈도 제한과 동적 스톱 로즈를 설정하여 위험을 제어합니다. 전략은 9주기, 20주기 및 50주기 3개 지수 이동 평균 (EMA) 을 사용하여 트렌드 방향을 판단하고, 상대적으로 강한 지수 (RSI) 와 평균 실제 파도 (ATR) 를 보조 지수로 사용하여 거래 필터링을 수행합니다.
이 전략의 핵심 거래 논리는 다음과 같은 핵심 요소를 포함합니다.
이 전략은 다중 기술 지표의 종합적인 사용으로 비교적 안정적인 암호화폐 거래 시스템을 달성한다. 차별화된 위험 매개 변수 설정과 엄격한 거래 주파수 제어로 수익과 위험을 더 잘 균형 잡는다. 전략의 핵심 장점은 역동적인 위험 관리 장치와 완벽한 필터링 시스템이지만, 암호화폐 시장에 특유의 높은 변동성과 유동성 위험을 고려해야합니다. 지속적인 최적화와 개선으로, 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 예상된다.
/*backtest
start: 2015-02-22 00:00:00
end: 2025-02-18 17:23:25
period: 1h
basePeriod: 1h
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © buffalobillcody
//@version=6
strategy("Backtest Last 2880 Baars Filers and Exits", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2, backtest_fill_limits_assumption=0)
// Define EMAs
shortEMA = ta.ema(close, 9)
longEMA = ta.ema(close, 20)
refEMA = ta.ema(close, 50)
// **Force Strategy to Trade on Historical Bars**
barLimit = bar_index > 10 // Allow trading on past bars
allowTrade = strategy.opentrades == 0 or barLimit // Enable first trade on history
// **Define ATR for Stop-Loss & Take-Profit**
atrLength = 14
atrValue = ta.atr(atrLength)
atr50 = ta.sma(atrValue, 50) // 50-period ATR average
// **Relaxed RSI Filters (More Trades Allowed)**
rsi = ta.rsi(close, 14)
rsiFilterBuy = rsi > 45 and rsi < 70
rsiFilterSell = rsi < 55 and rsi > 30
// **Reduce Trend Filter - Allow Smaller Price Movement**
minDistance = atrValue * 1.1
isTrending = math.abs(close - refEMA) > minDistance
// **Allow Trading in All Conditions (No ATR Filter)**
atrFilter = true
// **Allow Flat EMA Slopes - Increase Trade Frequency**
emaSlope = ta.linreg(refEMA, 5, 0) > -0.2
emaSlopeSell = ta.linreg(refEMA, 5, 0) < 0.2
// **Trade Counter: Allow 1 Trade Per Day**
var int dailyTradeCount = 0
if dayofweek != dayofweek[1]
dailyTradeCount := 0
// **ATR-Based Stop-Loss & Take-Profit Per Pair**
atrSL = switch syminfo.ticker
"EURUSD" => 3.0 * atrValue,
"USDJPY" => 2.5 * atrValue,
"GBPUSD" => 3.0 * atrValue,
"AUDUSD" => 3.2 * atrValue,
"GBPJPY" => 3.0 * atrValue,
=> 2.5 * atrValue
atrTP = switch syminfo.ticker
"EURUSD" => 3.8 * atrValue,
"USDJPY" => 3.5 * atrValue,
"GBPUSD" => 4.0 * atrValue,
"AUDUSD" => 4.0 * atrValue,
"GBPJPY" => 5.0 * atrValue,
=> 3.5 * atrValue
// **Ensure Trade Size is Not Zero**
riskPerTrade = 2
accountSize = strategy.equity
tradeSize = (accountSize * (riskPerTrade / 100)) / atrSL
tradeSize := tradeSize < 1 ? 1 : tradeSize // Minimum lot size of 1
// **Buy/Sell Conditions (Now More Trades Will Trigger)**
buyCondition = ta.crossover(shortEMA, longEMA) and rsiFilterBuy and close > refEMA and close > longEMA and isTrending and emaSlope and allowTrade and dailyTradeCount < 1
sellCondition = ta.crossunder(shortEMA, longEMA) and rsiFilterSell and close < refEMA and close < longEMA and isTrending and emaSlopeSell and allowTrade and dailyTradeCount < 1
// **Execute Trades**
if buyCondition
strategy.entry("Buy", strategy.long, qty=tradeSize)
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", limit=close + atrTP, stop=close - atrSL)
label.new(x=bar_index, y=low, text="BUY", color=color.green, textcolor=color.white, size=size.small, style=label.style_label_down)
alert("BUY", alert.freq_once_per_bar_close)
dailyTradeCount := dailyTradeCount + 1
if sellCondition
strategy.entry("Sell", strategy.short, qty=tradeSize)
strategy.exit("Take Profit/Stop Loss", from_entry="Sell", limit=close - atrTP, stop=close + atrSL)
label.new(x=bar_index, y=high, text="SELL", color=color.red, textcolor=color.white, size=size.small, style=label.style_label_up)
alert("SELL", alert.freq_once_per_bar_close)
dailyTradeCount := dailyTradeCount + 1
// **Plot Indicators**
plot(shortEMA, color=color.yellow, title="9 EMA")
plot(longEMA, color=color.fuchsia, title="20 EMA")
plot(refEMA, color=color.blue, title="50 EMA")