
これは、複数期間のローソク足パターン分析に基づいた取引戦略であり、主に強気エングルフィング、弱気エングルフィング、ドジなどの典型的なローソク足パターンを識別することで取引シグナルを生成します。この戦略は日次サイクルで実行され、複数のテクニカル指標とパターン特性を組み合わせて市場トレンドの転換点を決定し、理想的な取引開始時間を見つけます。
この戦略の核となるロジックは、3 つの古典的なローソク足パターンをプログラムで識別することです。
強気エングルフィングパターンが特定されると、Kラインの下に買いシグナルが表示されます。弱気エングルフィングパターンが特定されると、Kラインの上に売りシグナルが表示されます。ドジパターンが特定されると、 Kラインの最上部。この戦略は、label.new() 関数を通じて信号のラベル付けを実装し、plotshape() 関数を通じて信号の視覚化を強化します。
この戦略は、古典的な K ライン パターン分析をプログラム的に実装し、優れた操作性とスケーラビリティを備えています。合理的なパラメータ設定とリスク管理を通じて、取引の決定に貴重な参考資料を提供できます。将来的には、より多くのテクニカル指標を追加し、シグナル確認メカニズムを最適化することで、戦略の安定性と信頼性を向上させることができます。
/*backtest
start: 2024-01-06 00:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Sensex Option Buy/Sell Signals", overlay=true)
// Input parameters
bullishColor = color.new(color.green, 0)
bearishColor = color.new(color.red, 0)
dojiColor = color.new(color.yellow, 0)
// Candlestick pattern identification
isBullishEngulfing = close[1] < open[1] and close > open and close > high[1] and open < low[1]
isBearishEngulfing = close[1] > open[1] and close < open and close < low[1] and open > high[1]
isDoji = math.abs(close - open) <= (high - low) * 0.1
// Plot buy/sell signals
buySignal = isBullishEngulfing
sellSignal = isBearishEngulfing
timeframeCondition = input.timeframe("D", title="Timeframe for signals")
// Buy Signal
if buySignal
label.new(bar_index, high, "Buy", style=label.style_label_up, color=bullishColor, textcolor=color.white)
strategy.entry("Buy", strategy.long)
// Sell Signal
if sellSignal
label.new(bar_index, low, "Sell", style=label.style_label_down, color=bearishColor, textcolor=color.white)
strategy.entry("Sell", strategy.short)
// Highlight Doji candles
if isDoji
label.new(bar_index, high, "Doji", style=label.style_circle, color=dojiColor, textcolor=color.black)
// Alerts
alertcondition(buySignal, title="Buy Alert", message="Bullish Engulfing Pattern Detected")
alertcondition(sellSignal, title="Sell Alert", message="Bearish Engulfing Pattern Detected")
// Add plot shapes for visibility
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=bullishColor, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=bearishColor, style=shape.labeldown, text="SELL")