
この記事では,主にRavikant_sharmaが開発した複数の指数移動平均 ((EMA) と相対的に強い指数 ((RSI) に基づく定量取引戦略を分析しています.この戦略は,EMAの異なる周期の交差とRSIの数値判断,価格トレンドを識別し,入場と出場のタイミングを決定します.
策略は,9日線,21日線,51日線,100日線,200日線を含む5つの異なる周期のEMAを使用します. コードでは最初の4つのEMAのみが描かれています. RSIパラメータは14に設定されています.
ストラテジックは,以下のいずれかの条件を満たす場合,多額のポジションを開きます.
RSIが65を超えれば,強烈な上昇傾向を示します.
策略平仓退出は,以下のいずれかの条件を満たす場合です.
これは典型的なトレンド追跡戦略で,以下の利点があります.
この戦略にはいくつかのリスクがあります.
この戦略は以下の方向から最適化できます.
この戦略は,全体として,信頼性の高い,実行しやすいトレンド追跡戦略である.それは,多周期EMAを交叉してトレンドの方向を判断し,RSIフィルター偽信号と組み合わせて,反測効果の良い基礎でパラメータ最適化とモデル最適化を行う.安定した収益を期待する.しかし,トレーダーは,使用するときに,依然として,動きの逆転とパラメータ不適切なリスクをもたらす警戒が必要です.
/*backtest
start: 2024-01-30 00:00:00
end: 2024-02-29 00:00:00
period: 3h
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/
// © Ravikant_sharma
//@version=5
strategy('new', overlay=true)
start = timestamp(1990, 1, 1, 0, 0)
end = timestamp(2043, 12, 12, 23, 59)
ema0 = ta.ema(close, 9)
ema1 = ta.ema(close, 21)
ema2 = ta.ema(close, 51)
ema3 = ta.ema(close, 100)
ema4 = ta.ema(close, 200)
rsi2=ta.rsi(ta.sma(close,14),14)
plot(ema0, '9', color.new(color.green, 0))
plot(ema1, '21', color.new(color.black, 0))
plot(ema2, '51', color.new(color.red, 0))
plot(ema3, '200', color.new(color.blue, 0))
//plot(ema4, '100', color.new(color.gray, 0))
//LongEntry = ( ta.crossover(ema0,ema3) or ta.crossover(ema0,ema2) or ta.crossunder(ema2,ema3) ) // ta.crossover(ema0,ema1) //
LongEntry=false
if ta.crossover(ema0,ema1)
if rsi2>65
LongEntry:=true
if ta.crossover(ema1,ema2)
if rsi2>65
LongEntry:=true
LongExit = ta.crossunder(ema0,ema2) or close >(strategy.position_avg_price*1.25) or rsi2 <40 or close < (strategy.position_avg_price*0.98)
if time >= start and time <= end
if(LongEntry and rsi2>60)
strategy.entry('Long', strategy.long, 1)
if(LongExit)
strategy.close('Long')