
この戦略は,複数の移動平均と比較的強い指数 (RSI) を組み合わせて取引シグナルを生成する. 9日,21日,25日,99日の4つの異なる周期の移動平均を使用して,それらの間の交差によってトレンドの方向を判断する. 同時に,この戦略は,RSI指標を補助判断として導入し,市場が超買いまたは超売れるときに追加の取引シグナルを提供する.
この戦略の主な構想は,異なる周期的な移動平均のトレンド特性を利用し,それらの多頭並びと空頭並びによって市場の主要なトレンドを判断することです.短期平均線を上向きに長期平均線を横切ることは,看板信号とみなされ,逆に,下向きの信号とみなされます.RSI指数は,市場情勢を判断するために使用され,市場が過買または過売りしているときに反転信号を提供します.
この戦略は,異なる周期の移動平均とRSI指標を組み合わせて,傾向を追跡し,感情判断する取引戦略を形成する.その優点は,論理が明確で,適応性が強いこと,多均等な配合により,市場の傾向をよりよく把握するということです.しかし,同時に,パラメータに敏感であり,トレンド認識の遅れ,振動市場の不良なパフォーマンスなどのリスクもあります.将来,パラメータ最適化,シグナルフィルタリング,ポジション管理,ストップダウズアップなどの改善によって,戦略の性能と安定性をさらに向上させることができます.
/*backtest
start: 2023-04-24 00:00:00
end: 2024-04-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estratégia de Médias Móveis e RSI (por Svitorino_trade)", shorttitle="Estratégia-Médias Móveis", overlay=true)
len1 = input.int(9, minval=1, title="Length 1")
len2 = input.int(21, minval=1, title="Length 2")
len3 = input.int(25, minval=1, title="Length 3")
len4 = input.int(99, minval=1, title="Length 4")
rsi_length = input.int(14, minval=1, title="RSI Length")
rsi_oversold = input.float(30, minval=0, maxval=100, title="RSI Oversold Level")
rsi_overbought = input.float(70, minval=0, maxval=100, title="RSI Overbought Level")
src = input(close, title="Source")
ama(src, length) =>
sum = 0.0
for i = 0 to length - 1
sum := sum + src[i]
sum / length
avg1 = ama(src, len1)
avg2 = ama(src, len2)
avg3 = ama(src, len3)
avg4 = ama(src, len4)
rsi_value = ta.rsi(src, rsi_length)
// Condições de entrada e saída para períodos de 9 e 21
cruzamento_9_21_acima = avg1 > avg2 and avg1[1] <= avg2[1]
cruzamento_9_21_abaixo = avg1 < avg2 and avg1[1] >= avg2[1]
// Condições de entrada e saída para períodos de 25 e 99
cruzamento_25_99_acima = avg3 > avg4 and avg3[1] <= avg4[1]
cruzamento_25_99_abaixo = avg3 < avg4 and avg3[1] >= avg4[1]
// Plotando os sinais de entrada e saída
plotshape(series=cruzamento_9_21_acima, style=shape.triangleup, color=color.green, size=size.small, location=location.belowbar)
plotshape(series=cruzamento_9_21_abaixo, style=shape.triangledown, color=color.red, size=size.small, location=location.abovebar)
plotshape(series=cruzamento_25_99_acima, style=shape.triangleup, color=color.green, size=size.small, location=location.belowbar)
plotshape(series=cruzamento_25_99_abaixo, style=shape.triangledown, color=color.red, size=size.small, location=location.abovebar)
// Entradas e saídas para períodos de 9 e 21
if cruzamento_9_21_acima and rsi_value > rsi_overbought
strategy.entry("Venda Curta", strategy.short)
if cruzamento_9_21_abaixo and rsi_value < rsi_oversold
strategy.entry("Compra Curta", strategy.long)
if cruzamento_9_21_acima
strategy.close("Compra Curta")
if cruzamento_9_21_abaixo
strategy.close("Venda Curta")
// Entradas e saídas para períodos de 25 e 99
if cruzamento_25_99_acima and rsi_value > rsi_overbought
strategy.entry("Compra Forte", strategy.long)
if cruzamento_25_99_abaixo and rsi_value < rsi_oversold
strategy.entry("Venda Forte", strategy.short)
if cruzamento_25_99_acima
strategy.close("Venda Forte")
if cruzamento_25_99_abaixo
strategy.close("Compra Forte")