
トリプルSMA戦略は,3つの異なる周期の単純な移動平均に基づいてトレンド判断とエントリーを行う戦略である.それは自動的にトレンドを追跡し,トレンドの逆転を利用してポジションを上げることができる.
この戦略は,3つの異なる周期のSMAを主要トレンド判断指標として使用し,200周期,400周期,600周期のSMAを含みます.価格が3つのSMAの上位で上昇傾向と判断され,逆には空頭傾向と判断されます.
エントリー指標として,戦略は,close価格とStochClose振動器を使用する. 価格が三重SMAの方向と一致するときにのみ信号を発する.StochClose指標は,過剰または超売れかどうかを判断するために使用され,StochCloseが95を突破すると多額で,下部5を突破すると空いている.
ストップ・スタンダードとは,価格が最も遅いSMAに達したときにストップするものです.
戦略は,最大10回の加減を行うことができる。そして,それぞれ1%,2%および6%の3つの異なる比率のストップを設定する。
三重SMA戦略の最大の利点は,3つの異なる周期のSMAを組み合わせて使用することで,トレンドの方向と強さをよりよく判断できることです.単一のSMAよりも偽信号をフィルターする能力があります.
さらに,StochClose指標と組み合わせて,過買過落の判断を行うことで,トレンドの逆転点の近くで入場を避ける事が可能になり,誤ったエントリーを減らすことができる.
ストップ基準はシンプルで直接的で,最も遅い周期のSMAをストップラインとして使用し,早すぎるストップを最大限に防ぐことができます.
株価上昇を許容することで,トレンドを継続的に追跡し,利益を得ることができます.
この戦略の主なリスクは,3つのSMAがすべての偽信号を完全にフィルターできないことであり,価格が突破した後にトレンドが形成されなければ,再び逆戻りが起こると,損失を引き起こす可能性があります.これは通常,重要なサポート抵抗の近くで行われます.
さらに,StochClose指数自体も誤信号を生じ,不適切なエントリーを引き起こします.これは通常,価格の揺れ帯の間に起こります.
これらのリスクを軽減するために,SMAの周期を適切に調整したり,KDJ,MACDなどの他の指標を組み合わせて判断したり,入る信号の質を保証することができます.
この戦略は以下の点で最適化できます.
SMAの周期数を増やしたり調整したりして,特定の品種に適した周期パラメータを見つける
KDJ,MACDなどの他の指標を追加して,エントリの質を向上させる
ストップ・ストップ・損失基準の最適化,市場の波動範囲に適した設定
貯蓄の回数と割合を最適化して,より適切な貯蓄戦略を見つける
異なる品種のパラメータをテストし,より多くの品種に戦略パラメータを全面的に適用します.
三重SMA策略は,全体として非常に実用的なトレンド追跡策策である.それは,3つの異なる周期のSMAとStochClose指標を組み合わせて適用することにより,より良いトレンド判断効果を実現し,誤信号を効果的に回避することができる.適切な加仓を許可しながら,常にトレンドを追跡することができる.パラメータを調整し,最適化することで,この策略は,強力なトレンド追跡マシンになることができます.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="Tripla Sma with entries based on sma price closes ", shorttitle="TRIPLE SMA STRATEGY", overlay=true) ////resolution=""
len = input(200, minval=1, title="sma 1 length")
len1 = input(400, minval=1, title="sma 2 length")
len2 = input(600, minval=1, title="sma 3 length")
src = input(close, title="Source")
////////////////////////////////////////////
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
up = smma > smma [1]
down =smma < smma[1]
mycolor = up ? #64b5f6 : down ? #d32f2f : na
fastma = sma(hl2, 1)
fastplot = plot(fastma, color=#000000, transp=100, title='sma on candle')
slowplot = plot(smma, color=mycolor, transp=55, title='sma1')
////////////////////////////////////////////
smma1 = 0.0
smma1 := na(smma1[1]) ? sma(src, len1) : (smma1[1] * (len1 - 1) + src) / len1
up2 = smma1 > smma1 [1]
down2 =smma1 < smma1[1]
mycolor2 = up2 ? #64b5f6 : down2 ? #d32f2f : na
slowplot2 = plot(smma1, color=mycolor2, transp=45, title='sma2')
////////////////////////////////////////////
smma2 = 0.0
smma2 := na(smma2[1]) ? sma(src, len2) : (smma2[1] * (len2 - 1) + src) / len2
up3 = smma2 > smma2 [1]
down3 =smma2 < smma2[1]
mycolor3 = up3 ? #64b5f6 : down3 ? #d32f2f : na
slowplot3 = plot(smma2, color=mycolor3, transp=35, title='sma3')
////////////////////////////////////////////////////////////////////////////////////////
//Fill gaps
fillData = smma > fastma
fillData2 = smma < fastma
fillDtat = smma1 > smma
fillDtat2 = smma1 < smma
fillDat = smma2 > smma1
fillDat2 = smma2 < smma1
fillCol1 = fillData ? #ef5350 : fillData2 ? #64b5f6 : na
fillCol2 = fillDtat ? #ef5350 : fillDtat2 ? #64b5f6 : na
fillCol3 = fillDat ? #ef5350 : fillDat2 ? #64b5f6 : na
fill(slowplot, fastplot, color=fillCol1, transp=90, title="sma1 fill")
fill(slowplot, slowplot2, color=fillCol2, transp=80, title="sma2 fill")
fill(slowplot2, slowplot3, color=fillCol3, transp=60, title="sma3 fill")
uc = (close > smma) and (close > smma1)
dc = (close < smma) and (close < smma1)
barColor = uc ? #64b5f6 : dc ? #e91e63 : #b2b5be
barcolor(color=barColor)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//StochClose from @trendinvestpro
periods = input(50, minval=1, title="length for the oscillator")
smooth = input(5, minval=1, title="oscillator smoothing")
hhc=highest(close,periods)
llc=lowest(close,periods)
StochClose = sma((close-llc)/(hhc-llc)*100, smooth)
shortline = input(95, minval=0, title="signal when oscillator crosses above")
longline = input(5, minval=0, title="signal when oscillator crosses below")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
longs = close > smma2
shorts = close < smma2
long = longs == true and crossunder(StochClose, longline)
short = shorts == true and crossover(StochClose, shortline)
stoplong = close < smma and close < smma1 and close < smma2
stopshort = close > smma and close > smma1 and close > smma2
p1 = strategy.position_avg_price / 100 / syminfo.mintick
maxx = input(2500, title="max orders filled on a day", minval=0)
takeprofit1 = input(1, title="take profit level 1", minval=0)
takeprofit2 = input(2, title="take profit level 2", minval=0)
takeprofit3 = input(6, title="take profit level 3", minval=0)
takeprofitqt1 = input(30, title="take profit quantity first", minval=0)
takeprofitqt2 = input(30, title="take profit quantity second", minval=0)
takeprofitqt3 = input(30, title="take profit quantity third", minval=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////Strategy entries/////////////////////////////////////////////////////////////////////////////////////////
// strategy.risk.max_intraday_filled_orders(maxx)
strategy.entry("long", strategy.long, when=long)
strategy.exit("tpl1", "long", qty_percent = takeprofitqt1, profit = takeprofit1 * p1)
strategy.exit("tpl2", "long", qty_percent = takeprofitqt2, profit = takeprofit2 * p1)
strategy.exit("tpl3", "long", qty_percent = takeprofitqt3, profit = takeprofit3 * p1)
strategy.close("long", when=stoplong == true)
strategy.entry("short", strategy.short, when=short)
strategy.exit("tpl1", "short", qty_percent = takeprofitqt1, profit = takeprofit1 * p1)
strategy.exit("tpl2", "short", qty_percent = takeprofitqt2, profit = takeprofit2 * p1)
strategy.exit("tpl3", "short", qty_percent = takeprofitqt3, profit = takeprofit3 * p1)
strategy.close("short", when=stopshort == true)