
この戦略は,多周期移動平均帯とMACD指標を組み合わせた取引システムである.戦略は,主に,短期と長期の移動平均とMACD指標の信号の交差によって,市場の傾向と取引のタイミングを決定する.この戦略は,日中の取引の再設定論理を統合し,夜間リスクを効果的に防止する.
戦略の核心的な論理は,移動平均線帯システム,MACD指標システム,および日中取引再設定機構の3つの主要な部分で構成されています.移動平均線帯は,2つの異なる周期 ((9と21) の均線で構成され,SMA,EMA,SMMA,WMA,VWMAを含む複数の均線タイプを選択できます. MACDシステムは標準の12/26/9パラメータ設定を採用し,快線と遅線の差値信号および線によってトレンドの動きを判断します.
この戦略は均線帯とMACD指標を組み合わせて,比較的完ぺきな取引システムを構築している.ある程度の遅れのリスクがあるものの,合理的なパラメータ最適化とリスク管理によって,戦略はトレンド市場で良い効果を上げることができる.トレーダーは,実況使用の前に十分な反射を行い,特定の市場の特徴に応じてパラメータ設定を調整することをお勧めする.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Daily MA Ribbon + MACD Crossover with Buy/Sell Signals", overlay=true)
// === Daily Reset Logic ===
var bool newDay = false // Initialize newDay as a boolean variable
newDay := bool(ta.change(time("D"))) // Cast the result of ta.change to boolean
// === Moving Average Ribbon ===
ma(source, length, type) =>
type == "SMA" ? ta.sma(source, length) :
type == "EMA" ? ta.ema(source, length) :
type == "SMMA (RMA)" ? ta.rma(source, length) :
type == "WMA" ? ta.wma(source, length) :
type == "VWMA" ? ta.vwma(source, length) :
na
// MA1 (Short-term MA)
show_ma1 = input(true, "MA №1", inline="MA #1")
ma1_type = input.string("EMA", "", inline="MA #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
ma1_source = input(close, "", inline="MA #1")
ma1_length = input.int(9, "", inline="MA #1", minval=1) // Short-term MA (e.g., 9-period)
ma1_color = input(color.blue, "", inline="MA #1")
ma1 = ma(ma1_source, ma1_length, ma1_type)
plot(show_ma1 ? ma1 : na, color = ma1_color, title="MA №1")
// MA2 (Long-term MA)
show_ma2 = input(true, "MA №2", inline="MA #2")
ma2_type = input.string("EMA", "", inline="MA #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
ma2_source = input(close, "", inline="MA #2")
ma2_length = input.int(21, "", inline="MA #2", minval=1) // Long-term MA (e.g., 21-period)
ma2_color = input(color.red, "", inline="MA #2")
ma2 = ma(ma2_source, ma2_length, ma2_type)
plot(show_ma2 ? ma2 : na, color = ma2_color, title="MA №2")
// === MACD ===
fast_length = input(12, "Fast Length")
slow_length = input(26, "Slow Length")
signal_length = input.int(9, "Signal Smoothing", minval=1, maxval=50)
sma_source = input.string("EMA", "Oscillator MA Type", options=["SMA", "EMA"])
sma_signal = input.string("EMA", "Signal Line MA Type", options=["SMA", "EMA"])
// Calculate MACD
fast_ma = sma_source == "SMA" ? ta.sma(close, fast_length) : ta.ema(close, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(close, slow_length) : ta.ema(close, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
// Plot MACD
hline(0, "Zero Line", color = color.new(#787B86, 50))
plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))
plot(macd, title = "MACD", color = #2962FF)
plot(signal, title = "Signal", color = #FF6D00)
// === Buy/Sell Signal Logic ===
// Condition 1: MA1 (Short-term) crosses above MA2 (Long-term)
ma_crossover = ta.crossover(ma1, ma2)
// Condition 2: MACD line crosses above Signal line
macd_crossover = ta.crossover(macd, signal)
// Buy Signal: Both conditions must be true
buy_signal = ma_crossover and macd_crossover
// Sell Signal: MA1 crosses below MA2 or MACD crosses below Signal
sell_signal = ta.crossunder(ma1, ma2) or ta.crossunder(macd, signal)
// Reset signals at the start of each new day
if (newDay)
buy_signal := false
sell_signal := false
// Plot Buy/Sell Signals
plotshape(buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Strategy Entry/Exit
if (buy_signal)
strategy.entry("Buy", strategy.long)
if (sell_signal)
strategy.close("Buy", comment="Sell")