
この戦略は,8周期および21周期の指数移動平均 ((EMA) とパラパララインのSAR指標を組み合わせて,トレンドを捉え,リスクを管理することを目的としています.この戦略は,特定の交差点と価格行動条件に基づいてポジションを開き,ポジションを平和に設定し,固定ストップと特定の時間帯でポジションを強制する出場ルールを定義しています.
この戦略は,2つの異なる周期のEMA ((8サイクルと21サイクル) とパラパラ線SAR指数を使用して,ポジション開設とポジション条件を決定する.短期EMAが長期EMA上を交差し,閉盘価格がSARより高くなったとき,戦略は多頭ポジションを開設する.短期EMAが長期EMA下を交差し,閉盘価格がSARより低いとき,戦略は空頭ポジションを開設する.多頭ポジションは閉盘価格がSARより低いとき,空頭ポジションは閉盘価格がSARより高いとき,閉盘ポジションを平らにする.戦略は,単一取引のリスクを制御するために,固定ストップポイントを設定する.さらに,この戦略は,すべてのポジションを15:15で平らにするように強制する.
EMA平均線とパラパラ線SAR組み合わせ戦略は,一般的な2つの技術指標を組み合わせて,トレンドを捕捉し,リスクを制御しようとしています. この戦略は,簡単でわかりやすいので,初心者向けに学習して使用する. しかし,この戦略には,市場の変動への適応性の欠如,市場情緒や基本的要因への考慮の欠如などのいくつかの限界があります. したがって,実際のアプリケーションでは,特定の市場と取引品種に応じて戦略を最適化して改善する必要があり,その安定性と収益性を向上させる必要があります.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA and Parabolic SAR Strategy", overlay=true)
// Input parameters for EMAs and Parabolic SAR
emaShortPeriod = input.int(8, title="Short EMA Period")
emaLongPeriod = input.int(21, title="Long EMA Period")
sarStart = input.float(0.02, title="Parabolic SAR Start")
sarIncrement = input.float(0.02, title="Parabolic SAR Increment")
sarMaximum = input.float(0.2, title="Parabolic SAR Maximum")
fixedSL = input.int(83, title="Fixed Stop Loss (pts)")
// Calculate EMAs and Parabolic SAR
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
sar = ta.sar(sarStart, sarIncrement, sarMaximum)
// Entry conditions
longCondition = ta.crossover(emaShort, emaLong) and close > sar
shortCondition = ta.crossunder(emaShort, emaLong) and close < sar
// Exit conditions
longExitCondition = close < sar
shortExitCondition = close > sar
// Strategy entry and exit
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (longExitCondition)
strategy.close("Long")
if (shortExitCondition)
strategy.close("Short")
// Fixed Stop Loss
strategy.exit("Long Exit", "Long", stop=close - fixedSL * syminfo.mintick)
strategy.exit("Short Exit", "Short", stop=close + fixedSL * syminfo.mintick)
// Exit all positions at 15:15
exitHour = 15
exitMinute = 15
exitTime = timestamp(year(timenow), month(timenow), dayofmonth(timenow), exitHour, exitMinute)
if (timenow >= exitTime)
strategy.close_all()
// Plot EMAs and Parabolic SAR
plot(emaShort, color=color.blue, title="8 EMA")
plot(emaLong, color=color.red, title="21 EMA")
plot(sar, style=plot.style_cross, color=color.green, title="Parabolic SAR")