
이 전략은 볼링거 밴드 (Bollinger Bands) 에 기반한 동력 돌파 거래 시스템으로, 주로 가격과 볼링거 밴드 (Bollinger Bands) 의 궤도에 대한 관계를 통해 트렌드적 기회를 포착한다. 이 전략은 시장의 변동 특성을 식별하기 위해 표준 차차 통로와 결합된 적응형 일률형 유형 선택 메커니즘을 채택하고 있으며, 특히 변동성이 높은 시장 환경에서 적용된다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
이것은 합리적이고 논리적으로 명확하게 설계된 트렌드 추적 전략이다. 그것은 볼링거 밴드의 역동적인 특성을 통해 시장 동력을 포착하고, 좋은 위험 제어 메커니즘을 가지고 있다. 전략은 커스터마이징성이 강하며, 매개 변수를 조정하여 서로 다른 시장 환경에 적응할 수 있다. 실장 적용 시 충분한 매개 변수 최적화 및 재검토를 수행하고, 권장된 최적화 방향과 결합하여 전략 개선을 수행하는 것이 좋습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-11 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Demo GPT - Bollinger Bands", overlay=true, initial_capital=10000, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Inputs
length = input.int(20, minval=1, title="Length")
maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
offset = input.int(0, "Offset", minval=-500, maxval=500)
// Date range inputs
startYear = input.int(2018, "Start Year", minval=1970, maxval=2100)
startMonth = input.int(1, "Start Month", minval=1, maxval=12)
startDay = input.int(1, "Start Day", minval=1, maxval=31)
endYear = input.int(2069, "End Year", minval=1970, maxval=2100)
endMonth = input.int(12, "End Month", minval=1, maxval=12)
endDay = input.int(31, "End Day", minval=1, maxval=31)
// Time range
startTime = timestamp("GMT+0", startYear, startMonth, startDay, 0, 0)
endTime = timestamp("GMT+0", endYear, endMonth, endDay, 23, 59)
// Moving average function
ma(source, length, _type) =>
switch _type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// Calculate Bollinger Bands
basis = ma(src, length, maType)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Plot
plot(basis, "Basis", color=#2962FF, offset=offset)
p1 = plot(upper, "Upper", color=#F23645, offset=offset)
p2 = plot(lower, "Lower", color=#089981, offset=offset)
fill(p1, p2, title="Background", color=color.rgb(33, 150, 243, 95))
// Strategy logic: Only go long and flat
inDateRange = time >= startTime and time <= endTime
noPosition = strategy.position_size == 0
longPosition = strategy.position_size > 0
// Buy if close is above upper band
if inDateRange and noPosition and close > upper
strategy.entry("Long", strategy.long)
// Sell/Exit if close is below lower band
if inDateRange and longPosition and close < lower
strategy.close("Long")