
이 전략은 동적 RSI 지표, CCI 지표, 그리고 다중 MA 평균선을 결합하여 다중 요소에 의해 구동되는 양적 거래 전략을 구현합니다. 이 전략은 종합적으로 추세, 과매, 과매 등 여러 차원을 고려하여 판단하고 거래 신호를 생성합니다.
구매 신호: MA12에서 MA26을, CCI는 100보다 낮아 (오버셀), Stoch KDJ는 80보다 낮아 (오버셀)
팔기 신호: RSI 아래의 동적 하락, Stoch KDJ 80 이상 (오버 바이)
이 전략은 여러 가지 기술 지표와 다중 요인 주도 판단을 종합적으로 적용하여 변수 조정과 엄격한 통계적 검증을 통해 최적의 변수를 찾아서 더 나은 전략 효과를 얻을 수 있습니다. 그러나 복잡도가 높기 때문에 과도한 적합성을 방지하고 포지션 및 스톱 손실을 제어하여 최대 회수량을 줄여야합니다. 이 전략은 다른 품종 및 시간 주기에서 최적화 테스트를 위해 추가로 확장 할 수 있습니다.
/*backtest
start: 2023-11-19 00:00:00
end: 2023-11-26 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="ATOM2.0", shorttitle="ATOM V2.0", overlay=false, default_qty_type=strategy.cash, currency=currency.USD, initial_capital=200, default_qty_type=strategy.cash, default_qty_value=100, pyramiding=10)
// Set Parameter MA12
len12 = input(12, minval=1, title="Length")
src12 = input(close, title="Source")
ma12 = sma(src12, len12)
//plot(ma12, color=color.blue, title="MA12")
// Set Parameter MA26
len26 = input(26, minval=1, title="Length")
src26 = input(close, title="Source")
ma26 = sma(src26, len26)
//plot(ma26, color=color.orange, title="MA12")
//Stochastic RSI 14,3,3
smoothK_1 = input(3, minval=1)
smoothD_1 = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src_1 = input(close, title="RSI Source_1")
rsi1 = rsi(src_1, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK_1)
d = sma(k, smoothD_1)
//plot(k, color=color.red)
//plot(d, color=color.yellow)
//Stochastic RSI 5,4,3
smoothK_2 = input(4, minval=1)
smoothD_2 = input(3, minval=1)
lengthRSI_2 = input(5, minval=1)
lengthStoch_2 = input(5, minval=1)
src_2 = input(close, title="RSI Source_2")
rsi2 = rsi(src_2, lengthRSI_2)
k_2 = sma(stoch(rsi2, rsi2, rsi2, lengthStoch_2), smoothK_2)
d_2 = sma(k_2, smoothD_2)
//plot(k_2, color=color.white)
//plot(d_2, color=color.green)
// CCI
cci = cci(close,26)
//plot(cci,color=color.blue)
// Dynamic RSI
DZbuy = 0.1
DZsell = 0.1
Period = 14
Lb = 60
RSILine = rsi(close,Period)
jh = highest(RSILine, Lb)
jl = lowest(RSILine, Lb)
jc = (wma((jh-jl)*0.5,Period) + wma(jl,Period))
Hiline = jh - jc * DZbuy
Loline = jl + jc * DZsell
R = (4 * RSILine + 3 * RSILine[1] + 2 * RSILine[2] + RSILine[3] ) / 10
plot(R, title='R', color=color.white, linewidth=1, transp=0)
plot(Hiline, title='Hiline', color=color.yellow, linewidth=1, transp=0)
plot(Loline, title='Loline', color=color.yellow, linewidth=1, transp=0)
plot(jc, title='Jc', color=color.purple, linewidth=1, transp=50)
col_1 = R > Hiline ? color.red:na
col_2 = R < Loline ? color.green:na
fill(plot(R, title='R', color=color.white, linewidth=1, transp=0), plot(Hiline, title='Hiline', color=color.yellow, linewidth=1, transp=0), color=col_1,transp=0)
fill(plot(R, title='R', color=color.white, linewidth=1, transp=0), plot(Loline, title='Loline', color=color.yellow, linewidth=1, transp=0), color=col_2,transp=0)
//------------------------------------------------------------------------------
// Calculate qty
// Parameter
fund = 10 // Fund per Contract in USD
leverage = 100 // Leverage
// Buy Condition
buyCondition = (ma12>ma26 and cci<100 and k<80 and d<80 and k_2<80 and d_2<80 and crossover(k_2, d_2))
buy = (buyCondition == input(1))
alertcondition(buy, title='time to Long', message='Long!!!')
//closeBuy = (cci>100 and cci<cci[1] and cci<cci[2])
closeBuy = (crossunder(R, Hiline) and k>80)
alertcondition(closeBuy, title='Time to Close', message='Close Long')
// Submit Orders
strategy.entry(id="Long", qty=(fund*leverage)/close, long=true, when=buyCondition)
strategy.close(id="Long", when=closeBuy)