
この戦略は,二均線交差に基づくトレンド追跡取引システムである.短期と長期の移動平均 (それぞれ9日と21日) の相対的な位置関係を比較することによって,市場のトレンドの転換のタイミングを捉える.この戦略は,古典的な技術分析理論を採用し,近代的な量的な取引方法と組み合わせて,完全に自動化された取引意思決定プロセスを実現する.
戦略の核心論理は,2つの異なる周期の移動平均の交差信号に基づいています.短期平均線 (第9日) が上向きに長期平均線 (第21日) を渡るとき,システムは市場の動力が上向きに転じ,複数の信号を触発します.短期平均線が下向きに長期平均線 (第21日) を渡るとき,システムは市場の動力が下向きに転じ,平仓で取引を終了します.また,戦略には,取引統計機能が含まれています.
これは,二均線交差による市場動力の変化を捕捉する,古典的で実用的トレンド追跡戦略である.ある程度の遅滞と偽信号のリスクがあるにもかかわらず,そのシンプルで安定した特性は,量化取引の分野で重要なツールにしています.提案された最適化方向によって,戦略の安定性と収益性がさらに向上する見込みがあります.
/*backtest
start: 2024-05-20 00:00:00
end: 2024-12-13 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Simple MA Crossover Strategy", overlay=true)
// Input parameters
shortMA = ta.sma(close, 9)
longMA = ta.sma(close, 21)
// Buy/Sell conditions
buyCondition = ta.crossover(shortMA, longMA)
sellCondition = ta.crossunder(shortMA, longMA)
// Plot moving averages
plot(shortMA, color=color.blue, title="Short MA")
plot(longMA, color=color.red, title="Long MA")
// Execute trades
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")
// Track trades, wins, and losses
var int totalTrades = 0
var int totalWins = 0
var int totalLosses = 0
if (strategy.opentrades > 0)
totalTrades := totalTrades + 1
if (strategy.opentrades == 0 and strategy.opentrades[1] > 0)
if (strategy.netprofit > 0)
totalWins := totalWins + 1
else
totalLosses := totalLosses + 1
// Plot trade statistics
var label tradeStats = na
if (not na(tradeStats))
label.delete(tradeStats)
tradeStats := label.new(bar_index, high, text="Trades: " + str.tostring(totalTrades) + "\nWins: " + str.tostring(totalWins) + "\nLosses: " + str.tostring(totalLosses), style=label.style_label_down, color=color.white, textcolor=color.black)