
これは,MACD指数に基づく量的な取引戦略で,特定の時間帯を設定して取引を行う.戦略の核心は,高速と遅い移動平均を使用してMACD値を計算し,信号線との交差で購入や売却のタイミングを決定する.戦略には,リスクを制御し,利益をロックするためのストップ・ロスとストップ・ストップのメカニズムも含まれている.
戦略は8周期と16周期のインデックス移動平均 (EMA) を使ってMACD値を計算し,11周期の簡易移動平均 (SMA) を信号線として使用する.MACD線上の信号線を横切るときに買い信号を生じ,下を通るときに売る信号を生じする.同時に,戦略は1%のストップ損失と2%のストップストップの設定を導入し,ユーザが指定した時間枠でのみ取引を行う.
これは,構造が整った,論理が明確な量化取引戦略である. MACDの交叉によって取引信号を生成し,時間フィルタリングとリスク管理を組み合わせて,実用的な取引システムを形成している. 戦略の調整性が強く,さらなる最適化と個別化調整に適している. 交易者は,実況使用の前に十分な反射を行い,特定の取引品種と市場環境に応じてパラメータを調整することを推奨している.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sergengurgen83
//@version=5
strategy(title="MACD Crossover Strategy with Date Range", shorttitle="MACD Crossover strategys.g", overlay=true)
// Kullanıcı girişleri
fastLength = input.int(8, minval=1, title="Hızlı MA Süresi")
slowLength = input.int(16, minval=1, title="Yavaş MA Süresi")
signalLength = input.int(11, minval=1, title="Sinyal MA Süresi")
stopLossPercent = input.float(1.0, title="Stop-Loss Yüzdesi") / 100
takeProfitPercent = input.float(2.0, title="Kar Al Yüzdesi") / 100
// Tarih aralığı girişleri
startDate = input(timestamp("2023-01-01 00:00"), title="Başlangıç Tarihi")
endDate = input(timestamp("2023-12-31 23:59"), title="Bitiş Tarihi")
// Tarih aralığı kontrolü
inDateRange = true
// Hareketli Ortalamalar ve MACD Hesaplamaları
fastMA = ta.ema(close, fastLength)
slowMA = ta.ema(close, slowLength)
macd = fastMA - slowMA
signal = ta.sma(macd, signalLength)
// Alım ve Satım sinyalleri
buySignal = ta.crossover(macd, signal) and inDateRange
sellSignal = ta.crossunder(macd, signal) and inDateRange
// Strateji kuralları
if (buySignal)
strategy.entry("Buy", strategy.long)
if (sellSignal)
strategy.close("Buy")
// Stop-Loss ve Kar Al seviyeleri
strategy.exit("Sell", from_entry="Buy", loss=stopLossPercent * close, profit=takeProfitPercent * close)
// Sinyallerin grafikte gösterilmesi
plot(macd, color=color.blue, title="MACD")
plot(signal, color=color.red, title="Sinyal")
hline(0, color=color.purple, linestyle=hline.style_dashed)
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Al", text="AL")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sat", text="SAT")