이 전략은 빠른 이동 평균과 느린 이동 평균의 교차 원리를 적용하여 시장 추세 방향을 판단하여 구매 및 판매 신호를 발송합니다. 전략은 간단하고 이해하기 쉽고 실행하기 쉽고 중단 거래에 적합합니다.
이 전략은 두 개의 이동 평균을 사용하며, 하나는 빠른 선과 하나는 느린 선이다. 빠른 선의 매개 변수는 3일 EMA이고, 느린 선의 매개 변수는 15일 EMA이다. 전략은 빠른 선이 하향에서 느린 선을 뚫을 때 현재 상승 추세에 있다고 판단하고, 그 순간을 구매 신호라고 본다. 반대로, 빠른 선이 위로부터 하향으로 내려가 느린 선을 뚫을 때 현재 하향 추세에 있다고 판단하고, 그 순간을 판매 신호라고 본다.
전략은 또한 3일 EMA를 빠른 출구선으로 설정한다. 가격이 빠른 출구선 아래로 떨어지면, 동향이 반전되고, 원래의 다목적 지점을 탈퇴해야 한다. 마찬가지로, 가격이 다시 출구선을 돌파하면, 다시 승부로 돌아가서, 따라서 재입장 신호이다.
특정 동작 신호 설정은 다음과 같습니다:
빠른 선은 아래에서 위로 느린 선을 뚫고, 더 많은 일을 합니다.
빠른 선은 위로 내려가 느린 선을 깨고 공백을 만듭니다.
가격 하락, 급격한 퇴출선, 청산
가격이 다시 급격한 퇴출선을 넘어서 더 많은 일을 하게 됩니다.
사용이 간단하고, 두 개의 이동 평균의 변수만 잘 설정해야 합니다. 매우 쉽게 실행할 수 있습니다.
데이터의 충분한 회귀, 사용 된 지표는 전략의 효과를 평가 할 수 있습니다
더 많은 구성 가능한 매개 변수, 매개 변수를 조정하여 전략을 최적화 할 수 있습니다.
급속한 평균 이동 설정으로 스톱 로즈를 사용하여 위험을 더 잘 제어할 수 있습니다.
전략적 사고가 명확하고, 매매 지점을 판단하는 신호가 매우 명확하다.
거래 빈도가 적당하고, 거래 빈도가 너무 높지 않도록 하세요.
트렌드 추적 전략으로, 추세가 보이지 않을 때 더 많은 가짜 신호를 생성합니다.
이동 평균은 그 자체로 지연성이 있으며, 전환점을 놓칠 수 있습니다.
고정된 매개 변수 설정은 시장 변화에 적응할 수 없으며, 매개 변수 최적화 사용과 함께 사용해야 한다.
손해 중지 설정이 너무 약해서 시간 내에 손해 중지되지 않을 수 있습니다.
전략적 신호가 자주 발생하고 거래 비용이 더 높을 수 있습니다.
거래 신호의 이탈이 발생할 수 있으며, 다른 지표와 함께 확인해야 합니다.
매개 변수를 최적화하고, 다른 지표로 보조하여 확인하고, 적절히 느슨한 스탠다드, 적시에 매개 변수를 업데이트하는 등의 방법을 통해 위험을 제어할 수 있다.
현재 시장 특성에 맞게 이동 평균 변수를 최적화하는 테스트가 가능합니다.
더 많은 지표를 도입하여 더 강력한 전략 시스템을 구성할 수 있습니다.
시장에 따라 실시간으로 변수를 조정하는 사용자 정의 변수 설정을 설정할 수 있습니다.
기계 학습 알고리즘을 도입하여 보다 지능적인 전략 최적화를 구현할 수 있습니다.
다이내믹 스톱을 설정하고 스톱을 추적하여 위험을 더 잘 제어할 수 있습니다.
양에너지 지표와 결합하여 오차가 발생하지 않도록 함
이 전략은 전체적으로 비교적 간단한 쌍 이동 평균 가로 전략이다. 그것은 빠른 평균선과 느린 평균선 사이의 교차 관계를 사용하여 시장 추세와 구매 시기를 판단한다. 전략의 장점은 아이디어가 명확하고, 실행하기 쉽고, 매개 변수를 최적화하여 다른 시장에 적응할 수 있다. 그러나 또한 더 많은 지표를 도입하여 검증하고, 위험을 잘 제어해야 하는 위험도 있다.
/*backtest
start: 2023-01-01 00:00:00
end: 2023-02-03 00:00:00
period: 1d
basePeriod: 1h
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/
// © ehaarjee, ECHKAY, JackBauer007
//@version=4
//study(title="Tale_indicators", overlay=true)
strategy("Tale Indicators Strategy", overlay=true, precision=8, max_bars_back=200, pyramiding=0, initial_capital=20000, commission_type="percent", commission_value=0.1)
len_fast = input(3, minval=1, title="FAST EMA")
src_fast = input(close, title="Source for Fast")
fastMA = ema(src_fast, len_fast)
plot(fastMA, title="Slow EMA", color=color.orange)
len_slow = input(15, minval=1, title="SLOW EMA")
src_slow = input(close, title="Source for Slow")
slowMA = ema(src_slow, len_slow)
plot(slowMA, title="Fast EMA", color=color.blue)
len_fast_exit = input(3, minval=1, title="FAST EMA Exit")
src_fast_exit = input(close, title="Source for Fast Exit")
fastMAE = ema(src_fast_exit, len_fast_exit)
plot(fastMAE, title="Fast EMA Ex", color=color.red)
src_slow_enter_short = input(low, title="Source for Short Entry")
slowMASEn = ema(src_slow_enter_short, len_slow)
src_slow_enter_long = input(high, title="Source for Long Entry")
slowMALEn = ema(src_slow_enter_long, len_slow)
src_slow_exit_short = input(low, title="Source for Short Exit")
slowMASEx = ema(src_slow_enter_short, len_slow)
src_slow_exit_long = input(high, title="Source for Long Exit")
slowMALEx = ema(src_slow_enter_long, len_slow)
enter_long = crossover(fastMA, slowMALEn)
enter_short = crossunder(fastMA, slowMASEn)
exit_long = crossunder(fastMAE, slowMALEx)
exit_short = crossover(fastMAE, slowMALEx)
out_enter = iff(enter_long == true, 1, iff(enter_short == true, -1, 0))
plotarrow(out_enter, "Plot Enter Points", colorup=color.green, colordown=color.red, maxheight = 30)
bull = fastMA > slowMALEn
bear = fastMA < slowMASEn
c = bull ? color.green : bear ? color.red : color.white
bgcolor(c)
exit_tuner = input(0.005, title="Exit Tuner to touch slowEMA")
bull_exit = (bull and (low>(fastMAE*(1+exit_tuner)))) or exit_long or (not(bear) and (fastMAE>high))
bear_exit = (bear and ((fastMAE*(1-exit_tuner))>high)) or exit_short or (not(bull) and (low>fastMAE))
bull_r = (bull and ((bull_exit[1]) or (bull_exit[2] and bull_exit[1])) and (low<=fastMAE))
bear_r = (bear and ((bear_exit[1]) or (bull_exit[2] and bull_exit[1])) and (fastMAE<=high))
bull_re = (bull and (low<slowMALEn)) and not(enter_long)
bear_re = (bear and (high>slowMASEn)) and not(enter_short)
bull_ree = (bull and ((low<slowMALEn) and not(bull_re[1] or enter_long[1])))
bear_ree = (bear and ((high>slowMASEn) and not(bear_re[1] or enter_short[1])))
bull_reenter = (bull_r) and not(enter_long)
bear_reenter = (bear_r) and not(enter_short)
plotshape(bull_exit, "Plot Bull Exit", style = shape.arrowdown, color=color.green, size=size.small, text="ExL", location=location.abovebar)
plotshape(bear_exit, "Plot Bear Exit", style = shape.arrowup, color=color.red, size=size.small, text="ExS", location=location.belowbar)
plotshape(bull_reenter, "Plot Bull ReEnter", style = shape.arrowup, color=color.green, size=size.small, text="ReL", location=location.belowbar)
plotshape(bear_reenter, "Plot Bear ReEnter", style = shape.arrowdown, color=color.red, size=size.small, text="ReS", location=location.abovebar)
run_strategy = input(true, title="Run Strategy")
// === INPUT BACKTEST RANGE ===
fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)
fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)
fromYear = input(defval = 2020, title = "From Year", type = input.integer, minval = 2000)
thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)
thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)
thruYear = input(defval = 2100, title = "Thru Year", type = input.integer, minval = 2000)
// === INPUT SHOW PLOT ===
showDate = input(defval = true, title = "Show Date Range", type = input.bool)
// === FUNCTION EXAMPLE ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
var long_position_open = false
var short_position_open = false
if (enter_long and not(bull_exit) and not(long_position_open))
// strategy.entry("LO", strategy.long, qty=4)
long_position_open := true
if (short_position_open)
// strategy.close("SO")
short_position_open := false
if (bull_reenter and not(long_position_open))
// strategy.entry("LO", strategy.long, qty=1)
long_position_open := true
if (bull_exit and long_position_open)
// strategy.close("LO")
long_position_open := false
if (enter_short and not(bear_exit) and not(short_position_open))
// strategy.entry("SO", strategy.short, qty=4)
short_position_open := true
if(long_position_open)
// strategy.close("LO")
long_position_open := false
if (bear_reenter and not(short_position_open))
// strategy.entry("SO", strategy.long, qty=1)
long_position_open := true
if (bear_exit and short_position_open)
// strategy.close("SO")
short_position_open := false
if(run_strategy)
strategy.entry("LO", strategy.long, when=(window() and enter_long), qty=4)
strategy.entry("LO", strategy.long, when=(window() and bull_reenter and not(long_position_open)), qty=1)
strategy.close("LO", when=(window() and bull_exit and long_position_open))
strategy.entry("SO", strategy.short, when=(window() and enter_short), qty=4)
strategy.entry("SO", strategy.short, when=(window() and bear_reenter and not(short_position_open)), qty=1)
strategy.close("SO", when=(window() and bear_exit and short_position_open))