
この戦略は,ブリン・チャネル指標を使用してATRとフィボナッチ回帰に基づく波段を格子の価格チャネルとして描写する.双EMA均線と組み合わせて,全体的なトレンド方向を判断し,トレンド方向に選択的にブリン・バンドの価格にストップ・ローズ・グリッドを設定し,トレンド・トラッキング・スラピングを実現する.
ブリン通路の中枢軸を用いて,ATRと4つのフィボナッチ回帰線に基づいて上下軌道構造価格波段を描画する.
快線EMAと慢線SMAは,全体的なトレンド方向を判断する双均線を形成する.快線は,多頭市場である慢線を突破し,逆に空頭市場である.
多頭市場では多行のみ,ブリン下線近く価格突破通路の下沿いに多開口する.空頭市場では空行のみ,ブリン上線近く価格突破通路沿いに空開口する.
ストップ・ロスの条件を設定:K線が大幅に反転すると,現在の方向のポジションを退出する.
大規模なトレンドを判断するために双均線を使用し,逆転取引を避ける.
ブリンATRチャネルは,複数の開設価格を設定し,開設成功率を増加させた.
フィボナッチ回帰波段は,価格分散を設定し,異なる波段のポジション数によって,資金分散を実現する.
リアルタイム・ストップ・ローズ条件は,利回りを減らすため,迅速にストップ・ローズを可能にします.
大規模なトレンド判断の誤差は,逆勢の損失につながる可能性があります.平均線パラメータを適切に調整するか,または他の指標を補助判断のために追加することができます.
波動が大きすぎると,格子区間を直接突破し,ポジションを開けることができない.波段パラメータを調整して,ポジション開設の機会を増やすことができる.
止損条件は主観的で,異なるトレーダーの識別基準に誤差がある可能性があります. 止損条件のテストと最適化が推奨されます.
APO指数に二重均線傾向判断のための補助分析を追加する.
市場波動率指標を用いて,ブリン波段のパラメータを最適化して,市場の動向の変化に適したものにする.
ストップ幅を小さくし,OTHER方式のストップ条件の設定を加え,誤差を減らす.
この戦略の全体的な考え方は明確で,ブリンATR通路と双均線を組み合わせて戦略取引信号の全面的総合判断を実現し,誤判リスクを最大限に軽減する.戦略の優位性は明らかで,実用的に適用可能である.しかし,パラメータ設定やストップ・ローズ条件などの詳細点は,まだ最適化の余地があり,さらに完善される必要がある.継続的な最適化の中で,この戦略の収益レベルと安定性は,継続的に向上すると信じています.
/*backtest
start: 2023-11-12 00:00:00
end: 2023-12-12 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Aayonga
//@version=5
strategy("fib trend grid@Aa", overlay=true,initial_capital=2000, default_qty_type=strategy.fixed, default_qty_value=1)
//回测时间
useDateFilter=input.bool(true,title = "启用回测时间范围限定(backtest)", group = "回测范围(backtest)")
backtesStarDate=input(timestamp("1 Jan 2015"),title = "开始时间(Start)", group = "回测范围(backtest)")
backtestEndDate=input(timestamp("1 Jan 2040"),title = "结束时间(finish)",group = "回测范围(backtest)")
inTradeWindow=true
//入场位 entry
bolllen=input.int(defval=20,minval=1,title="布林长度,(boll length)",group = "入场位(entry)")
sma=ta.sma(close,bolllen)
avg=ta.atr(bolllen)
fib1=input(defval=1.236,title="Fib 1",group = "入场位(entry)")
fib2=input(defval=2.382,title="Fib 2",group = "入场位(entry)")
fib3=input(defval=3.618,title="fib 3",group = "入场位(entry)")
fib4=input(defval=4.236,title="Fib 4",group = "入场位(entry)")
r1=avg*fib1
r2=avg*fib2
r3=avg*fib3
r4=avg*fib4
top4=sma+r4
top3=sma+r3
top2=sma+r2
top1=sma+r1
bott1=sma-r1
bott2=sma-r2
bott3=sma-r3
bott4=sma-r4
//趋势 trend
t4=plot(top4,title="卖 (sell)4",color=color.rgb(244, 9, 9))
t3=plot(top3,title = "卖(sell) 3",color=color.rgb(211, 8, 8))
t2=plot(top2,title="卖 (sell)2",color=color.rgb(146, 13, 13))
t1=plot(top1,title="卖(sell) 1",color=color.rgb(100, 3, 3))
b1=plot(bott1,title="买(buy)1",color=color.rgb(4, 81, 40))
b2=plot(bott2,title="买(buy)2",color=color.rgb(15, 117, 46))
b3=plot(bott3,title = "买(buy)3",color =color.rgb(8, 176, 42) )
b4=plot(bott4,title="买(buy)4",color=color.rgb(15, 226, 103))
plot(sma,style=plot.style_cross,title="SMA",color=color.rgb(47, 16, 225))
//趋势
LengthF=input(defval = 25,title = "快线长度(fastlength)")
LengthS=input(defval=200,title = "慢线长度(slowlength)")
emaF=ta.ema(close,LengthF)
smaS=ta.sma(close,LengthS)
longTrend=emaF>smaS
longb=ta.crossover(emaF,smaS)
bgcolor(longb ? color.new(color.green,40):na,title = "多头强势(bull trend)")
shortTrend=smaS>emaF
shortb=ta.crossunder(emaF,smaS)
bgcolor(shortb ? color.new(#951313, 40):na,title = "空头强势(bear trend)")
//pinbar
bullPinBar = ((close > open) and ((open - low) > 0.6* (high - low))) or ((close < open) and ((close - low) > 0.9 * (high - low)))
//plotshape(bullPinBar , text ="pinbar", textcolor=color.rgb(9, 168, 144),location=location.belowbar, color=color.rgb(29, 103, 67), size=size.tiny)
bearPinBar = ((close > open) and ((high - close) > 0.7 * (high - low))) or ((close < open) and ((high - open) > 0.7 * (high - low)))
//plotshape(bearPinBar , text ="pinbar", textcolor=color.rgb(219, 12, 12),location=location.abovebar, color=color.rgb(146, 7, 7), size=size.tiny)
buy1=ta.crossunder(close,bott1) and longTrend and close>ta.ema(close,100)
buy2=ta.crossunder(close,bott2) and longTrend and close>ta.ema(close,80)
buy3=ta.crossunder(close,bott3) and longTrend and close>ta.ema(close,80)
buy4=ta.crossunder(close,bott4) and longTrend and close>ta.ema(close,80)
buyclose=bearPinBar or ta.crossunder(close,smaS)
if buy2 or buy3 or buy4 or buy1 and inTradeWindow
strategy.order("多(buy)",strategy.long)
if buyclose and inTradeWindow
strategy.close("多(buy)")
sell1=ta.crossover(close,top1) and shortTrend and close<ta.ema(close,200)
sell2=ta.crossover(close,top2) and shortTrend and close<ta.ema(close,200)
sell3=ta.crossover(close,top3) and shortTrend and close<ta.ema(close,200)
sell4=ta.crossover(close,top4) and shortTrend and close<ta.ema(close,200)
sellclose=bullPinBar or ta.crossover(close,ta.sma(close,220))
if sell1 or sell2 or sell3 or sell4 and inTradeWindow
strategy.order("空(sell)",strategy.short)
if sellclose and inTradeWindow
strategy.close("空(sell)")