この戦略は,速い移動平均と遅い移動平均の組み合わせを使用して,トレンドの方向を判断し,速いラインが遅いラインを突破すると取引信号を生成し,二重移動平均取引システムに属します.
この戦略は,短い長さの急速移動平均と長い長さのゆっくり移動平均を使用する.
スローペースMAは主動トレンドの方向を判断するために使用される.価格がMA上にあるとき,上昇トレンドとして判断し,価格がMA下にあるとき,下降トレンドとして判断する.
上昇傾向では,高速MA上から緩慢MAを通過すると,買入シグナルが生じます. 下降傾向では,高速MA下から緩慢MAを通過すると,売り出せシグナルが生じます.
取引シグナルが発生した後に,ストップ・ロスを設定するか,ストップ・ロスを追跡し続けるかを選択できます.
速やかにMAの組み合わせはトレンドを効果的に識別する.
速MAはより敏感な取引信号を生成する.
市場騒音を消去し,偽突破を防ぐために,ゆっくりとMAを行ってください.
EMA,DEMAなど,複数のMAアルゴリズムを選択できます.
ストップ・ロスを追跡するストップ・ロスの戦略を有効にします.
MAには遅延の問題があり,信号の遅延を引き起こす可能性がある.より敏感なパラメータをテストすることができる.
止損点は,突破によって損失が生じる可能性がある.適正に波動の余地を残さなければならない.
取引量にかかわらず,価格操作のリスクがあります. 取引量確認を追加できます.
偽信号を発生させる可能性の指標のみに基づいている.他の要因を追加して確認することができる.
参数最適化の難しさ. ステップアップ最適化または遺伝的アルゴリズムを使用して最適な参数を探す.
異なるMAアルゴリズムのパラメータをテストし,最適なパラメータを探します.
移動平均を自律的に調整して 感受性を高める研究
信号フィルタリングを最適化するために,他の指標や要素を追加します.
ダイナミック・ストップ・メカニズムの構築により,ストップ・損失を柔軟に処理できます.
ATRの動向に応じてポジションの調整など,資金管理戦略の最適化
この戦略は,双MAの交叉判断トレンドを利用して取引信号を生成し,ストップロスを制限するリスクを設定できます.この戦略の取引論理はシンプルで明確ですが,パラメータ選択の難しさなどの問題があります.パラメータ最適化,指標フィルタリング,ストップロスの策略などによって改善され,戦略をより安定して信頼性のあるものにすることができます.
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy(title = "Noro's Trend MAs Strategy v1.7", shorttitle = "Trend MAs str 1.7", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)
//Settings
needlong = input(true, "long")
needshort = input(true, "short")
needstops = input(false, "stops")
stoppercent = input(5, defval = 5, minval = 1, maxval = 50, title = "Stop, %")
type = input(7, defval = 7, minval = 1, maxval = 7, title = "Type of Slow MA")
src = input(close, defval = close, title = "Source of Slow MA")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")
needbg = input(false, defval = false, title = "Need trend Background?")
needarr = input(false, defval = false, title = "Need entry arrows?")
fastsma = ema(src, fastlen)
//DEMA
dema = 2 * ema(src, len) - ema(ema(close, len), len)
//TEMA
xPrice = close
xEMA1 = ema(src, len)
xEMA2 = ema(xEMA1, len)
xEMA3 = ema(xEMA2, len)
tema = 3 * xEMA1 - 3 * xEMA2 + xEMA3
//KAMA
xvnoise = abs(src - src[1])
nfastend = 0.20
nslowend = 0.05
nsignal = abs(src - src[len])
nnoise = sum(xvnoise, len)
nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2)
kama = nz(kama[1]) + nsmooth * (src - nz(kama[1]))
//PriceChannel
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2
//Trend
ma = type == 1 ? sma(src, len) : type == 2 ? ema(src, len) : type == 3 ? vwma(src, len) : type == 4 ? dema : type == 5 ? tema : type == 6 ? kama : type == 7 ? center : 0
trend = low > ma and low[1] > ma[1] and low[2] > ma[2] ? 1 : high < ma and high[1] < ma[1] ? -1 : trend[1]
//Bars
bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0
//Signals
min = min(open, close)
max = max(open, close)
up = trend == 1 and (low < fastsma or usefastsma == false) and redbars == 1 ? 1 : 0
dn = trend == -1 and (high > fastsma or usefastsma == false) and greenbars == 1 ? 1 : 0
//Lines
colorfastsma = usefastsma == true ? red : na
plot(fastsma, color = colorfastsma, title = "Fast MA")
plot(ma, color = blue, linewidth = 3, transp = 0, title = "Slow MA")
//Arrows
plotarrow(up == 1 and needarr == true ? 1 : 0, colorup = black, colordown = black, transp = 0)
plotarrow(dn == 1 and needarr == true ? -1 : 0, colorup = black, colordown = black, transp = 0)
//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)
//Alerts
alertcondition(up == 1, title='buy', message='Uptrend')
alertcondition(dn == 1, title='sell', message='Downtrend')
//Trading
stoplong = up == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]
longCondition = up == 1
if (longCondition)
strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
strategy.exit("Stop Long", "Long", stop = stoplong)
shortCondition = dn == 1
if (shortCondition)
strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
strategy.exit("Stop Short", "Short", stop = stopshort)