
この戦略は,ATR指標の動的ストップとATR指標の動的ストップを組み合わせた,トレンドフォロー戦略に基づいています.
この戦略は20周期の長さの唐津通路指標を使用し,通路の中央線は最高価格と最低価格の平均値である.価格が通路の中央線を上越すときに多し,価格が通路の中央線を下越すときに空きをする.平仓条件は,価格がダイナミックストップラインに触れた場合であり,ストップラインは,最近3K線の最低価格減算ATR指標の値の3分の1を多しストップとして計算し,最近3K線の最高価格加算ATR指標の値の3分の1を空きストップとして計算する.
この戦略の利点は以下の通りです.
この戦略には以下のリスクがあります.
この戦略は以下の点で最適化できます.
この戦略は,全体的に見ると,シンプルで実用的なタイプのトレンドフォロー戦略であり,トレンドの方向を判断し,ダイナミックなストップロスを使用して利益をロックし,トレンドキャプチャリングを効果的に追跡することができる.戦略は実用性が強いが,さらに複数の方法で最適化され,戦略は,より複雑な市場環境でも安定した収益を維持することができる.
/*backtest
start: 2023-11-29 00:00:00
end: 2023-12-06 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title = "dc", overlay = true)
atrLength = input(title="ATR Length:", defval=20, minval=1)
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testEndYear = input(2018, "Backtest Start Year")
testEndMonth = input(12)
testEndDay = input(31, "Backtest Start Day")
testPeriodEnd = timestamp(testEndYear,testEndMonth,testEndDay,0,0)
testPeriod() =>
true
//time >= testPeriodStart ? true : false
dcPeriod = input(20, "Period")
dcUpper = highest(close, dcPeriod)[1]
dcLower = lowest(close, dcPeriod)[1]
dcAverage = (dcUpper + dcLower) / 2
atrValue=atr(atrLength)
useTakeProfit = na
useStopLoss = na
useTrailStop = na
useTrailOffset = na
//@version=1
Buy_stop = lowest(low[1],3) - atr(20)[1] / 3
plot(Buy_stop, color=red, title="buy_stoploss")
Sell_stop = highest(high[1],3) + atr(20)[1] / 3
plot(Sell_stop, color=green, title="sell_stoploss")
plot(dcLower, style=line, linewidth=3, color=red, offset=1)
plot(dcUpper, style=line, linewidth=3, color=aqua, offset=1)
plot(dcAverage, color=black, style=line, linewidth=3, title="Mid-Line Average")
strategy.entry("simpleBuy", strategy.long, when=(close > dcAverage) and cross(close,dcAverage))
strategy.close("simpleBuy",when= ( close< Buy_stop))
strategy.entry("simpleSell", strategy.short,when=(close < dcAverage) and cross(close,dcAverage) )
strategy.close("simpleSell",when=( close > Sell_stop))
//strategy.exit("Exit simpleBuy", from_entry = "simpleBuy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
//strategy.exit("Exit simpleSell", from_entry = "simpleSell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)