오픈 클로즈 크로스 이동 평균 트렌드 추적 전략은 이동 평균에 기반한 트렌드 추적 전략이다. 이 전략은 오픈 클로즈 가격의 이동 평균과 클로즈 가격의 이동 평균을 계산하여 현재 시장의 흐름을 판단한다. 클로즈 가격의 이동 평균 위에 오픈 클로즈 가격의 이동 평균을 뚫을 때, 더 많이 한다. 클로즈 가격의 이동 평균 아래에 오픈 클로즈 가격의 이동 평균을 뚫을 때, 공백한다. 이 전략은 동시에 수익을 고정하기 위해 손실을 추적하는 스톱을 설정하고, 위험을 효과적으로 제어한다.
이 전략의 핵심 논리는 오픈 가격과 클로징 가격의 관계를 기반으로 현재 트렌드를 판단한다. 오픈 가격은 현재 시장의 수요 공급 관계와 거래 심리를 반영하고, 클로징 가격은 당일 거래의 결과를 반영한다. 일반적으로, 클로징 가격이 오픈 가격보다 높으면 당일 동향이 강하다는 것을 나타냅니다.
이 전략은 이 논리를 사용하여 개시 가격과 폐시 가격의 이동 평균을 계산하여 현재 추세를 판단합니다. 구체적으로, 그것의 결정 규칙은 다음과 같습니다:
클로징 가격의 이동 평균에 클로징 가격의 이동 평균을 씌우면 더 한다. 이것은 현재 멀티 헤드 분위기가 강화되고 있으며, 멀티 명령에 들어갈 수 있다는 것을 의미한다.
닫기 가격의 이동 평균 아래로 열기 가격의 이동 평균을 뚫을 때, 공백한다. 이것은 현재 공백 분위기가 강화되고 있다는 것을 의미하며, 공백 티켓에 들어갈 수 있다.
역전 신호가 발생했을 때, 원래의 포지션이 손실을 입게 됩니다.
이 전략은 또한 수익을 잠금하기 위해 손실을 추적하는 스톱을 설정합니다. 입찰 후, 입찰 가격과 현재 가격의 점차를 실시간으로 계산합니다. 가격이 설정된 스톱 포인트를 초과하면 스톱 라인이 상향으로 올라서 수익을 잠금합니다.
전체적으로, 이 전략은 트렌드를 판단하는 기간은 이동 평균의 주기 길이입니다. 매번 한 방향의 포지션을만 보유하고 있습니다. 원래 포지션의 상쇄는 ATR 상쇄와 유사한 설정이 없으며, 수익을 고정하기 위해 스톱 트래킹 설정이 있습니다.
이 전략에는 다음과 같은 장점이 있습니다.
의사결정 규칙이 명확하고 간단합니다.│ 오픈 오프닝 관계를 기반으로 트렌드를 판단하기 쉽고, 이해가 쉽고, 또한 매개 변수를 최적화하기 쉽다.
이동 평균의 종류를 유연하게 선택하세요.12가지의 이동 평균을 선택할 수 있으며, 최적의 변수를 찾기 위해 유연하게 조합할 수 있다.
사용 해상도를 유연하게 조정할 수 있다신호를 더 민감하고 적시에 맞추기 위해 전략의 해상도를 차트의 3-4배로 설정할 수 있다.
손해배상 장치가 있습니다.│ 전략에 추적 스톱로스가 설정되어 단편 손실과 철수를 효과적으로 제어할 수 있습니다.
포지션 기간을 조정할 수 있습니다.이동 평균 파라미터를 조정하여 변동성과 포지션 주기를 제어할 수 있다.
유연하게 조정할 수 있는 위험수익스톱포인트와 오차를 조정하여 위험도를 조절할 수 있다.
이 전략에는 다음과 같은 몇 가지 측면에 초점을 맞춘 몇 가지 위험도 있습니다.
트렌드 전환점을 놓친 것이 전략의 출전 신호는 가격 반전보다 약간 늦어질 수 있으며, 이로 인해 꼬리가 잡히게 됩니다. 이동 평균 주기를 적절히 줄임으로써 이를 완화할 수 있습니다.
이 지역은 강진 시에 적합하지 않습니다.극심한 변동 상황에서는 이 전략이 빈번하게 상쇄 포지션을 열고 수수료가 무겁습니다. 이 때 스톱포인트 수를 적절히 완화하거나 이동 평균 주기를 연장 할 수 있습니다.
단일 지표 판단이 전략은 단지 한 집합의 지표에 기초하여 실패의 영향을 받기 쉽다. 전략 논리를 풍부하게 하는 MACD와 같은 다른 지표를 도입하는 것을 고려할 수 있다.
변수는 너무 최적화이동 평균 변수와 정지 변수 모두 지나치게 최적화되기 쉽고 실제적인 성능은 회수보다 약할 수 있다. 변수 선택에 신중하게 봐야 한다.
이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.
다른 지표들을 조합해서ᄂ. 전략적 논리를 풍부하게 하고 안정성을 높이기 위해 증가 지표, 변동률 지표 등을 도입할 수 있다.
매개 변수 조정 주기시장 유형과 결합하여 이동 평균 변수를 동적으로 조정할 수 있으며, 트렌드 상황에서는 주기를 연장하고, 변동 상황에서는 주기를 단축할 수 있다.
리스크 메터스 동적 조정◎ 최근 기간 동안의 실제 변동에 따라 스톱 포인트 및 오차를 동적으로 조정할 수 있습니다.
제약 논리 강화현재는 가격과 점수를 기준으로 하는 스톱로즈가 존재하지만, ATR과 같은 더 풍부한 스톱로즈의 도입을 고려할 수 있다.
개방된 상장 교차 이동 평균 트렌드 추적 전략은 개방된 상장 상장 관계를 기반으로 트렌드 방향을 판단하는 전형적인 전략이다. 그것은 의사 결정 규칙이 간단하고 명확하고, 유연하게 조정할 수 있으며, 위험을 제어할 수 있는 장점이 있으며, 실수 반전점, 부적절한 급격한 흔들림과 같은 문제도 있다. 이 전략은 풍부한 지표 기반, 동적 파라미터 조정, 강화된 중지 손실 논리 등의 측면에서 최적화 될 수 있으므로, 트렌드 기회를 더 잘 파악하고, 시장 변화에 대응할 수 있다.
/*backtest
start: 2023-01-08 00:00:00
end: 2024-01-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title = "Open Close Cross Strategy (PineScript=v4)", shorttitle = "OCC Strategy", overlay = true )
// Revision: 1
// Author: @JayRogers
//
// Description:
// - Strategy based around Open-Close Crossovers.
// Setup:
// - I have generally found that setting the strategy resolution to 3-4x that of the chart you are viewing
// tends to yield the best results, regardless of which MA option you may choose (if any)
// - Don't aim for perfection. Just aim to get a reasonably snug fit with the O-C band, with good runs of
// green and red.
// - Option to either use basic open and close series data, or pick your poison with a wide array of MA types.
// - Optional trailing stop for damage mitigation if desired (can be toggled on/off)
// - Positions get taken automagically following a crossover - which is why it's better to set the resolution
// of the script greater than that of your chart, so that the trades get taken sooner rather than later.
// - If you make use of the trailing stops, be sure to take your time tweaking the values. Cutting it too fine
// will cost you profits but keep you safer, while letting them loose could lead to more drawdown than you
// can handle.
// === INPUTS ===
useRes = input(defval=true, title="Use Alternate Resolution? ( recommended )")
stratRes = input(defval="120", title="Set Resolution ( should not be lower than chart )", type=input.resolution)
useMA = input(defval=true, title="Use MA? ( otherwise use simple Open/Close data )")
basisType = input(defval="DEMA", title="MA Type: SMA, EMA, DEMA, TEMA, WMA, VWMA, SMMA, HullMA, LSMA, ALMA ( case sensitive )", type=input.string)
basisLen = input(defval=14, title="MA Period", minval=1)
offsetSigma = input(defval=6, title="Offset for LSMA / Sigma for ALMA", minval=0)
offsetALMA = input(defval=0.85, title="Offset for ALMA", minval=0, step=0.01)
useStop = input(defval=true, title="Use Trailing Stop?")
slPoints = input(defval=200, title="Stop Loss Trail Points", minval=1)
slOffset = input(defval=400, title="Stop Loss Trail Offset", minval=1)
// === /INPUTS ===
// === BASE FUNCTIONS ===
// Returns MA input selection variant, default to SMA if blank or typo.
variant(type, src, len, offSig, offALMA) =>
v1 = sma(src, len) // Simple
v2 = ema(src, len) // Exponential
v3 = 2 * v2 - ema(v2, len) // Double Exponential
v4 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential
v5 = wma(src, len) // Weighted
v6 = vwma(src, len) // Volume Weighted
sma_1 = sma(src, len) // Smoothed
v7 = na(v5[1]) ? sma_1 : (v5[1] * (len - 1) + src) / len
v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) // Hull
v9 = linreg(src, len, offSig) // Least Squares
v10 = alma(src, len, offALMA, offSig) // Arnaud Legoux
type == "EMA" ? v2 : type == "DEMA" ? v3 : type == "TEMA" ? v4 :
type == "WMA" ? v5 : type == "VWMA" ? v6 : type == "SMMA" ? v7 :
type == "HullMA" ? v8 : type == "LSMA" ? v9 : type == "ALMA" ? v10 : v1
// security wrapper for repeat calls
reso(exp, use, res) =>
security_1 = security(syminfo.tickerid, res, exp)
use ? security_1 : exp
// === /BASE FUNCTIONS ===
// === SERIES SETUP ===
// open/close
variant__1 = variant(basisType, close, basisLen, offsetSigma, offsetALMA)
reso__1 = reso(variant__1, useRes, stratRes)
reso__2 = reso(close, useRes, stratRes)
closeSeries = useMA ? reso__1 : reso__2
variant__2 = variant(basisType, open, basisLen, offsetSigma, offsetALMA)
reso__3 = reso(variant__2, useRes, stratRes)
reso__4 = reso(open, useRes, stratRes)
openSeries = useMA ? reso__3 : reso__4
trendState = bool(na)
trendState := closeSeries > openSeries ? true :
closeSeries < openSeries ? false : trendState[1]
// === /SERIES ===
// === PLOTTING ===
barcolor(color=closeSeries > openSeries ? #006600 : #990000, title="Bar Colours")
// channel outline
closePlot = plot(closeSeries, title="Close Line", color=#009900, linewidth=2, style=plot.style_line, transp=90)
openPlot = plot(openSeries, title="Open Line", color=#CC0000, linewidth=2, style=plot.style_line, transp=90)
// channel fill
closePlotU = plot(trendState ? closeSeries : na, transp=100, editable=false)
openPlotU = plot(trendState ? openSeries : na, transp=100, editable=false)
closePlotD = plot(trendState ? na : closeSeries, transp=100, editable=false)
openPlotD = plot(trendState ? na : openSeries, transp=100, editable=false)
fill(openPlotU, closePlotU, title="Up Trend Fill", color=#009900, transp=40)
fill(openPlotD, closePlotD, title="Down Trend Fill", color=#CC0000, transp=40)
// === /PLOTTING ===
// === STRATEGY ===
// conditions
longCond = crossover(closeSeries, openSeries)
shortCond = crossunder(closeSeries, openSeries)
// entries and base exit
strategy.entry("long", strategy.long, when=longCond)
strategy.entry("short", strategy.short, when=shortCond)
// if we're using the trailing stop
if useStop
strategy.exit("XL", from_entry="long", trail_points=slPoints, trail_offset=slOffset)
strategy.exit("XS", from_entry="short", trail_points=slPoints, trail_offset=slOffset)
// not sure needed, but just incase..
strategy.exit("XL", from_entry="long", when=shortCond)
strategy.exit("XS", from_entry="short", when=longCond)
// === /STRATEGY ===