ATRとT3移動平均戦略


作成日: 2023-09-17 18:30:48 最終変更日: 2023-09-17 18:30:48
コピー: 0 クリック数: 818
1
フォロー
1617
フォロワー

概要

この戦略はATR指標とT3平均線を組み合わせてトレンド判断と追跡を行う.ATRは価格通路の分割を実現し,大トレンドの方向を判断する.T3平均線は入場位置と止損出場の判断を行う.この戦略は安定した利益を追求するトレンドフォロワーに適している.

戦略原則

  1. ATR指標は価格チャネルを構成し,チャネル方向は主動トレンドの方向を判断する.

  2. T3平均線は,特定の入場時刻を判断する補助であり,価格がT3平均線を突破すると購入する.

  3. 価格が下線を突破すると止まり,平準状態;上線が上線を突破すると止まり,平準状態.

  4. 複数または双方向の取引を選択できます.

  5. パラメータを最適化して指標の性質を組み合わせ,最適な組み合わせを探します.

優位分析

  1. ATRの通路の区分は明確で,大トレンドの判断は正確である.

  2. T3平均線パラメータは調整可能で,さまざまなレベルのトレンドを柔軟に捉えます.

  3. 止損止規則の一貫性が高く,任意のvcfkkmr。を避ける

  4. 取引頻度が低く,長線保有に適しています.

リスク分析

  1. 取引の誤差を招く可能性のある指標の違い

  2. 株の変動特性が考慮されず,パラメータの拘束リスクも考慮されていない.

  3. 取引頻度が低いと,機会が失われ,利益の余地が限られている.

  4. 重仓保有による尾行滑落リスク

最適化の方向

  1. 取引の有効性を確保するために,他の指標を追加します.

  2. 異なる品種のパラメータに最適化して適応性を向上させる.

  3. ポジションの規模を最適化し,頻度とリスクをバランスさせる.

  4. 動的に移動するストップ・ストップポイントを考慮し,利益の余地を増やす.

  5. 戦略レベルでは FILTER を追加し,安定性を高めます.

要約する

この戦略はATRとT3平均線を統合して,シンプルで効果的なトレンド追跡を実現する.しかし,指標の論理とパラメータの最適化をさらに強化し,誤判の可能性を低減し,戦略をリアルディスク条件により適合させる必要がある.

ストラテジーソースコード
/*backtest
start: 2023-09-09 00:00:00
end: 2023-09-16 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
//Author - CryptoJoncis
strategy("ATR and T3 strategy", shorttitle="AT3S_CryptoJoncis", overlay=true)

shorting = input(false, title="shorts on?")
precentage_diff = input(5,title="Precantage")/100
Lengthx = input(25, title="Lenght of T3")

//For best results use 0.7 or 0.618
Vfactx = input(0.72, minval=0.01,step=0.01, title="Volume Factor of T3 with HA source")

Source_of_T3_Normal = close
Source_of_T3 =  Source_of_T3_Normal 
FirstEMAx = ema(Source_of_T3, Lengthx)
SecondEMAx = ema(FirstEMAx, Lengthx)
ThirdEMAx = ema(SecondEMAx, Lengthx)
FourthEMAx = ema(ThirdEMAx, Lengthx)
FifthEMAx = ema(FourthEMAx, Lengthx)
SixthEMAx = ema(FifthEMAx, Lengthx)

//Doing all the calculations which are from 
c1x = -Vfactx*Vfactx*Vfactx
c2x = 3*Vfactx*Vfactx + 3*Vfactx*Vfactx*Vfactx
c3x = -6*Vfactx*Vfactx -3*Vfactx -3*Vfactx*Vfactx*Vfactx
c4x = 1 + 3*Vfactx + Vfactx*Vfactx*Vfactx + 3*Vfactx*Vfactx

//Assigning EMAS to T3 Moving average
T3MAx = c1x * SixthEMAx + c2x * FifthEMAx + c3x * FourthEMAx + c4x * ThirdEMAx

color_of_Tilson_Moving_Average = T3MAx > T3MAx[1] ? lime : red
plot(T3MAx, title="Tilson Moving Average(ema)", color=color_of_Tilson_Moving_Average)

t_up = T3MAx + (T3MAx * precentage_diff)
t_dn = T3MAx - (T3MAx * precentage_diff)

x=plot(t_up, color=color_of_Tilson_Moving_Average)
z=plot(t_dn, color=color_of_Tilson_Moving_Average)
fill(x,z, color= T3MAx[1] < T3MAx ? lime : gray)

Factor=input(5, minval=1)
Pd=input(5, minval=1)
//

Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))


TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown

linecolor = Trend == 1 ? green : red
//
b=plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "")

Factor1=input(1, minval=1)
Pd1=input(1, minval=1)
//

Up1=hl2-(Factor1*atr(Pd1))
Dn1=hl2+(Factor1*atr(Pd1))


TrendUp1=close[1]>TrendUp1[1]? max(Up1,TrendUp1[1]) : Up1
TrendDown1=close[1]<TrendDown1[1]? min(Dn1,TrendDown1[1]) : Dn1

Trend1 = close > TrendDown1[1] ? 1: close< TrendUp1[1]? -1: nz(Trend1[1],1)
Tsl1 = Trend1==1? TrendUp1: TrendDown1

linecolor1 = Trend1 == 1 ? green : red
//
a=plot(Tsl1, color = linecolor1 , style = line , linewidth = 2,title = "")

long = (close > Tsl and close > Tsl1 and close > T3MAx)

short = (close < Tsl and close < Tsl1 and close < T3MAx)

if(shorting==true)
    strategy.entry("MacdSE", strategy.short, comment="Open Short", when=short)
    strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
    strategy.close("MacdLE", when=hl2 < t_dn)
    strategy.close("MacdSE", when=hl2 > t_up)
if(shorting==false)
    strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
    strategy.close("MacdLE", when=hl2 < t_dn)
fill(a,b,color=linecolor)