
オープン・クローズド・クロス・ムービング・アベアンド・トレンド・トラッキング・ストラテジーとは,移動平均をベースにしたトレンド・トラッキング・ストラテジーである.このストラテジーでは,開盤価格と閉盤価格の移動平均を計算して,現在の市場トレンドを判断する.閉盤価格の移動平均の上に開盤価格の移動平均を穿越するときは,多行する.閉盤価格の移動平均の下から開盤価格の移動平均を穿越するときは,空きする.このストラテジーには,利益を固定するためのトラッキング・ストップが設定され,リスクが効果的に管理される.
この戦略の核心論理は,開場価格と閉場価格の関係に基づいて現在の傾向を判断する.開場価格は,現在の市場の需要と供給の関係と取引心理を反映し,閉場価格は,当日の取引結果を反映する.一般的に,閉場価格が開場価格より高い場合は,当日の動きが強いことを示す,多頭気は良い;閉場価格が開場価格より低い場合は,当日の動きが弱いことを示す,空気気気は重い.
この戦略は,この論理を適用し,開盤価格と閉盤価格の移動平均を計算して,現在のトレンドの方向を判断する.具体的には,その決定規則は次のとおりである.
閉盘価格の移動平均に開盤価格の移動平均を穿戴する時,多頭する.これは,現在多頭気氛が強まっていることを示す.多單に入ることができる.
閉盘価格の移動平均の下から開盤価格の移動平均を穿越するとき,空空する。これは,空空の雰囲気が強化され,空券に入ることができることを示している。
逆転の合図が発生すると,元のポジションのストップ・損失が出場する.
この戦略はまた,利益をロックするためにストップ・ロスを追跡する.入場後,入場価格と現在の価格のポイント差をリアルタイムで計算する.価格が設定されたストップ・ロスの数を超えると,ストップ・ラインは上昇して利益の一部をロックする.
総じて,この戦略は,移動平均周期長さのトレンドを判断する時間帯;一度に1つの方向のみのポジションを保持する;原始ポジションのストップは,ATRのストップに似た設定がなく,直接逆行する;利益をロックするためのストップトラッキング設定があります.
この戦略には以下の利点があります.
意思決定のルールは明確でシンプルです◎ 取引開始と終了の関係に基づいてトレンドを判断し,簡単に理解し,パラメータを最適化することもできます.
移動平均の種類を柔軟に選択できます.〇 選択可能な移動平均は,より柔軟な組み合わせで,最適なパラメータを探します.
解像度が柔軟に調整される◎ 信号をより敏感でタイムリーにするために,戦略の解像度をグラフの3-4倍に設定できます.
損失を抑える仕組みがある│ 戦略に追跡ストップが設定され,単発損失と撤回を効果的に制御できます。
ポジションの時間帯を調整できます.│ 移動平均のパラメータを調整することで,波動性や持仓周期を制御できます。
リスク・リターンを柔軟に調整できる│ │ │ │ │ │ │
この戦略にはいくつかのリスクがあり,以下のような部分に重点を置いています.
逆転を逃したこの戦略の出場シグナルは,価格の反転に少し遅れ,尾張を起こす可能性があります.移動平均周期を適切に短縮することで緩和できます.
震災が激しい都市には適さない┃ 激しい震動の状況では,この戦略は頻繁にポジションを平定し,手数料が重くなります。 このとき,適切な緩解の止損ポイント数,または移動平均周期の延長を行うことができます。
単一の指標判断┃ この戦略は,一組の指標のみに基づいており,失効の影響を受けやすい。 ┃ 戦略の論理を豊かにするために,MACDのような他の指標を導入することを考えることができる。
パラメータは最適化されやすい│ 移動平均パラメータとストップダストパラメータは,過度に最適化されやすく,実際のパフォーマンスは反射よりも弱くなることがあります。パラメータの選択を慎重に検討する必要があります。
この戦略は以下の方向から最適化できます.
他の指標を組み合わせる┃ 策略論理を豊かにし,安定性を高めるために,増量指標,波動率指標などの導入を試みることができる。
パラメータ調整周期化┃ 市場タイプを組み合わせて,動的に移動平均のパラメータを調整し,トレンドの動きで周期を長くし,振動の動きで周期を短くすることができる。
リスクメーターの動態調整◎ ストップポイントと偏差は,最近の実際の変動に基づいて動的に調整できます.
ストップロジックの強化│ │ │ │ │ │ │ │ │ │ │ │
オープン・クローズ・オフの移動平均トレンド追跡戦略は,より典型的にオープン・クローズ・オフの関係に基づいてトレンドの方向を判断する戦略である.決定規則が単純で明確で,柔軟に調整可能で,リスクを制御できるなどの利点があり,また,誤転の反転点,不適した激しい揺れなどの問題もある.この戦略は,指標の基礎の豊かさ,動的パラメータの調整,ストップ・ロジックの強化などの面で最適化され,トレンドの機会をよりよく把握し,市場の変化に対応することができる.
/*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 ===