
이것은 쌍평준선을 기반으로 한 간단한 일일 거래 전략이다. 그것은 두 개의 다른 주기의 간단한 이동평준을 사용하여, 평준선이 교차할 때 구매 또는 판매한다. 신호가 변경될 때, 두 배의 수를 사용하여 평정 포지션을 사용하고 역으로 포지션을 개설한다.
이 전략은 10일과 40일 두 개의 간단한 이동 평균선을 사용한다. 단기 평균선 위에 장기 평균선을 통과할 때, 더 많이 한다. 단기 평균선 아래에 장기 평균선을 통과할 때, 공백을 한다. 신호가 변할 때, 이중수 손으로 평점을 하고 역으로 포지션을 개설한다. 정의된 일간 거래 시간 동안, 평점 신호를 따라 거래한다.
이 전략은 주로 단기평균선 위에 장기평균선을 뚫을 때 단기평균선이 상승하기 시작하면 이 트렌드를 잡을 수 있음을 나타냅니다. 단기평균선 아래로 단기평균선이 하락하기 시작하면 이 트렌드를 잡을 수 있습니다. 이중수 역으로 포지션을 개설하는 디자인은 포지션을 증가시키고 수익 공간을 확장 할 수 있습니다.
위험과 대응하는 방법:
평균선 변수를 최적화한다. 더 많은 조합을 테스트하여 최적의 변수를 찾는다.
다른 기술 지표 필터링을 추가하십시오. 예를 들어 MACD 지표 확인을 추가하면 잘못된 신호 비율을 줄일 수 있습니다.
역으로 포지션 개설 배수를 최적화한다. 다양한 배수 크기를 테스트하여 최적의 매개 변수를 찾는다.
다양한 거래 시간대를 테스트하세요. 적절한 연장 시간대는 더 나은 수익을 얻을 수 있습니다.
이 전략의 전체적인 아이디어는 간단하며, 쌍평평선 교차로 형성되는 단기 트렌드를 포착하여 이윤의 공간을 확장하고, 쌍배수 역으로 포지션을 개시하고, 마지막으로 일일 시간대 거래와 함께 야간 위험을 피한다. 일일 단선 거래에 적합한 효과적인 전략이다. 파라미터를 조정하고 다른 기술 지표 필터를 추가함으로써 더 나은 전략 효과를 얻을 수 있는 추가 최적화 공간이 있다.
/*backtest
start: 2024-02-19 00:00:00
end: 2024-02-26 00:00:00
period: 1m
basePeriod: 1m
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/
// © Pritesh-StocksDeveloper
//@version=4
strategy("Moving Average - Intraday", shorttitle = "MA - Intraday",
overlay=true, calc_on_every_tick = true)
// Used for intraday handling
// Session value should be from market start to the time you want to square-off
// your intraday strategy
var i_marketSession = input(title="Market session", type=input.session,
defval="0915-1455", confirm=true)
// Short & Long moving avg. period
var int i_shortPeriod = input(title = "Short MA Period", type = input.integer,
defval = 10, minval = 2, maxval = 20, confirm=true)
var int i_longPeriod = input(title = "Long MA Period", type = input.integer,
defval = 40, minval = 3, maxval = 120, confirm=true)
// A function to check whether the bar is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0
// Calculate moving averages
shortAvg = sma(close, i_shortPeriod)
longAvg = sma(close, i_longPeriod)
// Plot moving averages
plot(series = shortAvg, color = color.red, title = "Short MA",
linewidth = 2)
plot(series = longAvg, color = color.blue, title = "Long MA",
linewidth = 2)
// Long/short condition
longCondition = crossover(shortAvg, longAvg)
shortCondition = crossunder(shortAvg, longAvg)
// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)
// Trade only if intraday session is active
// Long position
strategy.entry(id = "Long", long = strategy.long,
when = longCondition and intradaySession)
// Short position
strategy.entry(id = "Short", long = strategy.short,
when = shortCondition and intradaySession)
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")