平均足非再描画トレンド確認戦略

HA NRTS TCS EQTY MGMT
作成日: 2025-03-28 17:35:26 最終変更日: 2025-03-28 17:35:26
コピー: 2 クリック数: 416
2
フォロー
319
フォロワー

平均足非再描画トレンド確認戦略 平均足非再描画トレンド確認戦略

概要

これは,ハイカナシ・アシ (Heikin-Ashi) の非再描画トレンド確認戦略であり,従来の取引ビュー (TradingView) においてハイカナシ戦略が存在する再描画問題を解決することを目的としている.ハイカナシ・アシと複数のトレンド確認メカニズムを手動で計算することによって,この戦略はより信頼性の高い透明な取引方法を提供します.

戦略原則

戦略の核心には3つの重要なステップが含まれています.

  1. ハイカナシンの計算は,手動で描くのではなく,

    • 閉店価格,開店価格,最高価格,最低価格を計算するユニークな公式
    • Kラインの更新に際して,歴史的価格データの安定性を確保する
    • ハイカナシの伝統的戦略でよく見られる再描画を避ける
  2. 複数の傾向が確認されています.

    • 継続的な多根がトレンドの方向性を確認することを要求
    • 長い入場シグナル: 連続したX根のチェックが必要
    • 空中入場シグナル:連続したX根の下落が必要
    • マルチコンファインデーションで偽信号をフィルターし,戦略の信頼性を高めます.
  3. フレキシブルな取引方法

    • 伝統的なトレンドフォローモデルを支持する
    • トレンドを逆転する取引オプションを提供
    • 取引モードをカスタマイズできます (全部,多,空)

戦略的優位性

  1. 復刻の問題の排除: 履歴データは安定し,復刻結果は実盤の実行と高度に一致する
  2. 多重トレンド確認:不必要な取引を連続的にフィルタリングする
  3. 高さで調整できます.
    • フレキシブルな入場と出場の値設定
    • トレンドフォローと反転取引のサポート
    • 標準のK線を隠し,明確な可視化を提供します
  4. 中長期の取引に適しています.特に浮動取引やトレンドフォローに適しています.

戦略リスク

  1. 機能の限界:

    • 高周波スカルピングには適さない
    • トレンドがはっきりしない震動市場では,より悪い結果が出る可能性がある
    • パラメータは時間枠によって調整する必要があります.
  2. 潜在的リスク管理:

    • 適切な止措置を講じること
    • 異なる市場条件における継続的な最適化パラメータ
    • 他の技術指標と組み合わせたクロス検証

戦略最適化の方向性

  1. パラメータの動的調整:

    • 適応型入場・出場値アルゴリズムの開発
    • 市場変動に応じて連続数をリアルタイムで調整する
    • パラメータ選択を最適化する機械学習アルゴリズムの導入
  2. リスク管理の強化:

    • 統合されたダイナミックポジション管理
    • 関連性フィルターを追加する
    • よりスマートな止損システム開発
  3. パッケージ:

    • 他の技術指標 (RSI,MACDなど) と組み合わせた
    • 多指標認証システムを開発
    • 信号の正確性と信頼性を向上させる

要約する

ハイカンの西アフリカ再描画トレンド確認戦略は,革新的な計算と多重トレンド確認方法によって,トレーダーにより信頼性の高い,透明な取引ツールを提供します.この戦略は,再描画の問題を取り除き,偽信号をフィルターし,柔軟な取引モデルを提供することによって,定量取引における技術革新の潜在性を示しています.

ストラテジーソースコード
/*backtest
start: 2025-03-15 00:00:00
end: 2025-03-27 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=5
//© PineIndicators

strategy("Heikin-Ashi Non-Repainting Strategy [PineIndicators]", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, max_boxes_count=500, max_labels_count=500, max_lines_count=500, commission_value=0.01, process_orders_on_close=true, slippage= 2, behind_chart=false)

//====================================
// INPUTS
//====================================
// Number of consecutive candles required for entry and exit
openThreshold = input.int(title="Number of Candles for Entry", defval=2, minval=1)
exitThreshold = input.int(title="Number of Candles for Exit", defval=2, minval=1)
// Trade mode selection: "Long & Short", "Only Long", or "Only Short"
tradeMode = input.string(title="Trade Mode", defval="Only Long", options=["Long & Short", "Only Long", "Only Short"])
// Option to invert the trading logic (bullish signals become short signals, and vice versa)
invertTrades = input.bool(title="Invert Trading Logic (Long ↔ Short)", defval=false)
// Option to hide the standard candles (bodies only)
hideStandard = input.bool(title="Hide Standard Candles", defval=true)
// Heikin-Ashi transparency is fixed (0 = fully opaque)
heikinTransparency = 0

//====================================
// HIDE STANDARD CANDLES
//====================================
// Hide the body of the standard candles by setting them to 100% transparent.
// Note: The wicks of the standard candles cannot be hidden via code.
barcolor(hideStandard ? color.new(color.black, 100) : na)

//====================================
// HEIKIN-ASHI CALCULATION
//====================================
// Calculate Heikin-Ashi values manually
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(high, math.max(haOpen, haClose))
haLow  = math.min(low, math.min(haOpen, haClose))

// Define colors for Heikin-Ashi candles (using fixed transparency)
bullColor = color.new(#0097a7, heikinTransparency)
bearColor = color.new(#ff195f, heikinTransparency)

//====================================
// PLOT HEIKIN-ASHI CANDLES
//====================================
// Plot the manually calculated Heikin-Ashi candles over the chart.
// The candle body, wicks, and borders will be colored based on whether the candle is bullish or bearish.
plotcandle(haOpen, haHigh, haLow, haClose, title="Heikin-Ashi", 
     color       = haClose >= haOpen ? bullColor : bearColor,
     wickcolor   = haClose >= haOpen ? bullColor : bearColor,
     bordercolor = haClose >= haOpen ? bullColor : bearColor,
     force_overlay = true)

//====================================
// COUNT CONSECUTIVE TREND CANDLES
//====================================
// Count the number of consecutive bullish or bearish Heikin-Ashi candles.
var int bullishCount = 0
var int bearishCount = 0

if haClose > haOpen
    bullishCount := bullishCount + 1
    bearishCount := 0
else if haClose < haOpen
    bearishCount := bearishCount + 1
    bullishCount := 0
else
    bullishCount := 0
    bearishCount := 0

//====================================
// DEFINE ENTRY & EXIT SIGNALS
//====================================
// The signals are based on the number of consecutive trend candles.
// In normal logic: bullish candles trigger a long entry and bearish candles trigger a short entry.
// If invertTrades is enabled, the signals are swapped.
var bool longEntrySignal  = false
var bool shortEntrySignal = false
var bool exitLongSignal   = false
var bool exitShortSignal  = false

if not invertTrades
    longEntrySignal  := bullishCount >= openThreshold
    shortEntrySignal := bearishCount >= openThreshold
    exitLongSignal   := bearishCount >= exitThreshold
    exitShortSignal  := bullishCount >= exitThreshold
else
    // Inverted logic: bullish candles trigger short entries and bearish candles trigger long entries.
    longEntrySignal  := bearishCount >= openThreshold
    shortEntrySignal := bullishCount >= openThreshold
    exitLongSignal   := bullishCount >= exitThreshold
    exitShortSignal  := bearishCount >= exitThreshold

//====================================
// APPLY TRADE MODE RESTRICTIONS
//====================================
// If the user selects "Only Long", disable short signals (and vice versa).
if tradeMode == "Only Long"
    shortEntrySignal := false
    exitShortSignal  := false
else if tradeMode == "Only Short"
    longEntrySignal  := false
    exitLongSignal   := false

//====================================
// TRADING STRATEGY LOGIC
//====================================
// Execute trades based on the calculated signals.

// If a long position is open:
if strategy.position_size > 0
    if shortEntrySignal
        strategy.close("Long", comment="Reverse Long")
        strategy.entry("Short", strategy.short, comment="Enter Short")
    else if exitLongSignal
        strategy.close("Long", comment="Exit Long")

// If a short position is open:
if strategy.position_size < 0
    if longEntrySignal
        strategy.close("Short", comment="Reverse Short")
        strategy.entry("Long", strategy.long, comment="Enter Long")
    else if exitShortSignal
        strategy.close("Short", comment="Exit Short")

// If no position is open:
if strategy.position_size == 0
    if longEntrySignal
        strategy.entry("Long", strategy.long, comment="Enter Long")
    else if shortEntrySignal
        strategy.entry("Short", strategy.short, comment="Enter Short")