
この戦略は,CCI指標,RSI指標,移動平均の2つを組み合わせた複合取引システムである. このシステムは,通常のトレンドを捕捉し,同時に,RSI指標の交差を,入場時の追加確認として利用し,いくつかのノイズをフィルターします.
この戦略は,主にCCI指標に基づいてトレンドの方向を判断する.CCI指標値は100を超えると多頭市場であり,100を下ると空頭市場である.システムは,2つの移動平均の交差を活用してトレンドの方向を判断する.速い移動平均で遅い移動平均を横断すると買入信号であり,逆に,売り出し信号である.
多空のトレンドを特定した後,システムは2つのパラメータ長さの異なるRSI指標の交差を入場検証として使用する.例えば,多頭市場では,短周期RSI指標に長周期RSI指標を穿越すると,最終的な買い信号となる.この設計は,主に,トレンドに現れる短期的な調整を誤取引に誘導することを避けるために,ノイズをフィルターするために設計されている.
この戦略は,指定された取引時間のみでポジションを開き,閉じる15分前に全ポジションを積極的に平にする,一夜間のリスクを避ける.ポジションを開いた後,移動のストップを活用して利益をロックする.
この戦略は,トレンド判断と指標のクロス検証を総合的に考慮し,リスクを制御しながら,取引シグナルの有効性を確保しています.パラメータの最適化と論理的調整により,この戦略は,さらに利益の余地を増やし,逃亡の機会を減らすことができます.これは非常に潜在的な取引理念です.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
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/
// © rwestbrookjr
//@version=5
strategy("EMA with RSI Cross Strategy", overlay=true)
//EMA
fastLen = input(title='Fast EMA Length', defval=9)
slowLen = input(title='Slow EMA Length', defval=20)
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
fema = plot(fastEMA, title='FastEMA', color=color.new(color.green, 0), linewidth=1, style=plot.style_line)
sema = plot(slowEMA, title='SlowEMA', color=color.new(color.red, 0), linewidth=1, style=plot.style_line)
fill(fema, sema, color=fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title='Cloud')
// Bull and Bear Alerts
//Bull = ta.crossover(fastEMA, slowEMA)
Bull = fastEMA > slowEMA
//Bear = ta.crossunder(fastEMA, slowEMA)
Bear = fastEMA < slowEMA
//RSIs
rsiLength1Input = input.int(9, minval=1, title="RSI Length", group="RSI Settings")
rsiSource1Input = input.source(close, "Source", group="RSI Settings")
rsiLength2Input = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
rsiSource2Input = input.source(close, "Source", group="RSI Settings")
up1 = ta.rma(math.max(ta.change(rsiSource1Input), 0), rsiLength1Input)
down1 = ta.rma(-math.min(ta.change(rsiSource1Input), 0), rsiLength1Input)
rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))
up2 = ta.rma(math.max(ta.change(rsiSource2Input), 0), rsiLength2Input)
down2 = ta.rma(-math.min(ta.change(rsiSource2Input), 0), rsiLength2Input)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
//CCI
cciLength = input.int(20, minval=1)
src = input(hlc3, title="Source")
ma = ta.sma(src, cciLength)
cci = (src - ma) / (0.015 * ta.dev(src, cciLength))
//Trail Stop Setup
trstp = input.float(title="Trail Loss($)", minval = 0.0, step = 0.01, defval = 0.5)
longStop = 0.0, shortStop = 0.0
longStop := if Bull
stopValue = close - trstp
math.max(stopValue, longStop[1])
else
0.0
shortStop := if Bear
stopValue = close + trstp
math.min(stopValue, shortStop[1])
else
999999
//Session Setup
open_session=input(defval="0930-1545")
session = time("1", open_session)
validSession=(na(session) ? 0 : 1)
//Trade Signals
longCondition = Bull and cci > 100 and ta.crossover(rsi,rsi2) and validSession
if (longCondition)
strategy.entry("Long", strategy.long, 1)
//longExit = close > strategy.opentrades.entry_price(0) + 1.5 or close < strategy.opentrades.entry_price(0) - 0.75
longExit = close < longStop or not validSession
if (longExit)
strategy.close("Long")
shortCondition = Bear and cci < 100 and ta.crossunder(rsi,rsi2) and validSession
if (shortCondition)
strategy.entry("Short", strategy.short, 1)
//shortExit = close < strategy.opentrades.entry_price(0) - 1.5 or close > strategy.opentrades.entry_price(0) + 0.75
shortExit = close > shortStop or not validSession
if (shortExit)
strategy.close("Short")