
이 전략은 브린을 기반으로 한 거래 전략이다. 그것은 브린을 사용하여 구매 및 판매 신호를 생성하고, 동적으로 중지 및 중지 수준을 설정한다. 가격이 하향 경로를 통과 할 때 구매 신호를 생성하고, 경로를 통과 할 때 판매 신호를 생성한다.
이 전략은 브린 띠를 통과하여 매매 신호를 생성하고 동적으로 중지 및 중지 수준을 설정하는 브린 띠 기반의 거래 전략입니다. 전략 논리는 명확하고 구현하기 쉽고 다양한 시장 조건에 적응 할 수 있습니다. 그러나 불안한 시장에서 과도한 거래가 발생할 수 있으며 추세 방향에 대한 판단이 부족합니다.
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands Strategy", overlay=true)
// Bollinger Bands settings
length = 20
src = close
mult = 2.0
// Calculate Bollinger Bands
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Plot Bollinger Bands
plot(basis, color=color.blue, title="Middle Band")
plot(upper, color=color.red, title="Upper Band")
plot(lower, color=color.green, title="Lower Band")
// Trade logic
// Buy when the price crosses below the lower Bollinger Band
buySignal = ta.crossover(lower, src)
// Sell when the price crosses above the upper Bollinger Band
sellSignal = ta.crossover(src, upper)
// Define stop loss and take profit levels
var float stopLoss = na
var float takeProfit = na
// Calculate stop loss and take profit levels
if (buySignal)
stopLoss := ta.lowest(low, length)
takeProfit := na
if (sellSignal)
stopLoss := ta.highest(high, length)
takeProfit := na
// Update take profit on new signals
if (buySignal)
takeProfit := na
if (sellSignal)
takeProfit := na
// Execute trades
if (buySignal)
strategy.entry("Buy", strategy.long, stop=stopLoss, limit=takeProfit)
if (sellSignal)
strategy.entry("Sell", strategy.short, stop=stopLoss, limit=takeProfit)
// Plot signals on chart
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy", title="Buy Signal")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell", title="Sell Signal")
// Alert conditions
alertcondition(buySignal, title="Buy Alert", message="Buy Signal detected")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal detected")