
이 전략은 CCI 지표, RSI 지표, 두 개의 이동 평균을 결합한 복합 거래 시스템입니다. 이 시스템은 일반적인 트렌드를 캡처 할 수 있으며, RSI 지표의 교차를 사용하여 입문 시기를 추가 확인하여 약간의 소음을 필터링 할 수 있습니다.
이 전략은 주로 CCI 지표에 기반하여 트렌드 방향을 판단한다. CCI 지표 값이 100 이상이면 다단계 시장이며, 100 이하이면 공단계 시장이다. 시스템은 두 개의 이동 평균의 교차를 사용하여 트렌드 방향을 판단한다. 빠른 이동 평균에서 느린 이동 평균을 통과하면 구매 신호로, 반대로 판매 신호이다.
다중 하공 트렌드를 확인한 후, 시스템은 두 개의 변수 길이가 다른 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")