该策略利用波林格带(Bollinger Bands)指标,在价格触及上轨时做空,触及下轨时做多,并设置动态止盈位,当持仓达到1%的盈利就平仓。该策略的核心思想是价格总是在波林格带内波动,具有均值回归的特性,因此可以在价格偏离移动平均线过远时进行反向操作,博取价差收益。
该策略利用波林格带构建了一个简单有效的交易系统,以价格触及上下轨为信号,同时采用动态止盈的方式控制风险。策略在趋势行情中表现较好,但在震荡市中可能面临频繁交易的问题。后续可以从趋势判断、止盈止损优化、因子组合、基本面过滤等方面对策略进行完善,以期获得更加稳健的收益。
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Future Price Prediction", overlay=true)
// Ayarlar
length = input.int(14, "Length")
mult = input.float(2.0, "Multiplier")
showBands = input.bool(true, "Show Bands")
takeProfitPercentage = 1.0
// Ortalama ve Standart Sapma Hesaplamaları
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
// Üst ve Alt Bantlar
upper = basis + dev
lower = basis - dev
// Grafikte Gösterim
plot(basis, color=color.blue, linewidth=2, title="Basis")
plot(showBands ? upper : na, color=color.red, linewidth=1, title="Upper Band")
plot(showBands ? lower : na, color=color.green, linewidth=1, title="Lower Band")
// Al-Sat Sinyalleri
longCondition = ta.crossover(close[1], lower[1]) and close[1] < open[1]
shortCondition = ta.crossunder(close[1], upper[1]) and close[1] > open[1]
// Kar al seviyeleri
float longTakeProfit = na
float shortTakeProfit = na
if longCondition
longTakeProfit := close * (1 + takeProfitPercentage / 100)
if shortCondition
shortTakeProfit := close * (1 - takeProfitPercentage / 100)
// Strateji Giriş ve Çıkış
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=longTakeProfit)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=shortTakeProfit)
// Al-Sat Sinyalleri Grafikte Gösterim
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Bilgi Tablosu
var table data = table.new(position.bottom_right, 2, 2, frame_color=color.black, frame_width=1)
if barstate.islast
table.cell(data, 0, 0, "Current Price", text_color=color.white)
table.cell(data, 1, 0, str.tostring(close))
table.cell(data, 0, 1, "Predicted Basis", text_color=color.white)
table.cell(data, 1, 1, str.tostring(basis))