
この戦略は,日本の技術分析における三線突破形状のトレンド追跡取引システムである.指数移動平均 ((EMA) をトレンドフィルターとして実波幅指標 ((ATR) と組み合わせて動的リスク管理を行うことで,従来の三線突破モデルの信頼性を高めている.この戦略は,市場のトレンド転換点を捕捉するだけでなく,リスクを効果的に管理し,中長期のトレンド取引に適している.
戦略の核心的な論理は,以下のいくつかの重要な要素に基づいています. まず,三線突破形状を識別します.つまり,連続した3つの同じ色の線に続いて大きな反転の吞食が生じます. 次に,トレンドフィルターとしてEMAを使用し,価格がEMAの上にある場合にのみ多信号を考慮し,EMAの下にある場合にのみ空信号を考慮します.最後に,ATR指標の動態を使用してストップロスの位置を設定します.
これは,技術分析の古典的理論と近代的な量化取引の理念を融合した戦略システムである.伝統的な三線突破形状をトレンド追跡とリスク管理と組み合わせることで,比較的完全な取引システムを構築している.一定の限界があるものの,提供された最適化方向によって,戦略の安定性と適応性をさらに向上させることができる.戦略の成功した適用には,トレーダーが市場の特性を深く理解し,具体的状況に応じてパラメータを調整する必要がある.
/*backtest
start: 2025-01-18 00:00:00
end: 2025-02-17 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// Copyright ...
// Based on the TMA Overlay by Arty, converted to a simple strategy example.
// Pine Script v5
//@version=5
strategy(title='3 Line Strike [TTF] - Strategy with ATR and EMA Filter',
shorttitle='3LS Strategy [TTF]',
overlay=true,
initial_capital=100000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
pyramiding=0)
// -----------------------------------------------------------------------------
// INPUTS
// -----------------------------------------------------------------------------
// ATR and EMA Inputs
atrLength = input.int(title='ATR Length', defval=14, group='ATR & EMA')
emaLength = input.int(title='EMA Length', defval=200, group='ATR & EMA')
// ### 3 Line Strike
showBear3LS = input.bool(title='Show Bearish 3 Line Strike', defval=true, group='3 Line Strike',
tooltip="Bearish 3 Line Strike (3LS-Bear) = 3 zelené sviečky, potom veľká červená sviečka (engulfing).")
showBull3LS = input.bool(title='Show Bullish 3 Line Strike', defval=true, group='3 Line Strike',
tooltip="Bullish 3 Line Strike (3LS-Bull) = 3 červené sviečky, potom veľká zelená sviečka (engulfing).")
// -----------------------------------------------------------------------------
// CALCULATIONS
// -----------------------------------------------------------------------------
// Calculate ATR
atr = ta.atr(atrLength)
// Calculate EMA
ema = ta.ema(close, emaLength)
// Helper Functions
getCandleColorIndex(barIndex) =>
int ret = na
if (close[barIndex] > open[barIndex])
ret := 1
else if (close[barIndex] < open[barIndex])
ret := -1
else
ret := 0
ret
isEngulfing(checkBearish) =>
sizePrevCandle = close[1] - open[1]
sizeCurrentCandle = close - open
isCurrentLargerThanPrevious = math.abs(sizeCurrentCandle) > math.abs(sizePrevCandle)
if checkBearish
isGreenToRed = (getCandleColorIndex(0) < 0) and (getCandleColorIndex(1) > 0)
isCurrentLargerThanPrevious and isGreenToRed
else
isRedToGreen = (getCandleColorIndex(0) > 0) and (getCandleColorIndex(1) < 0)
isCurrentLargerThanPrevious and isRedToGreen
isBearishEngulfing() => isEngulfing(true)
isBullishEngulfing() => isEngulfing(false)
is3LSBear() =>
is3LineSetup = (getCandleColorIndex(1) > 0) and (getCandleColorIndex(2) > 0) and (getCandleColorIndex(3) > 0)
is3LineSetup and isBearishEngulfing()
is3LSBull() =>
is3LineSetup = (getCandleColorIndex(1) < 0) and (getCandleColorIndex(2) < 0) and (getCandleColorIndex(3) < 0)
is3LineSetup and isBullishEngulfing()
// Signals
is3LSBearSig = is3LSBear() and close < ema
is3LSBullSig = is3LSBull() and close > ema
// Take Profit and Stop Loss
longTP = close + 2 * atr
longSL = close - 1 * atr
shortTP = close - 2 * atr
shortSL = close + 1 * atr
// -----------------------------------------------------------------------------
// STRATEGY ENTRY PRÍKAZY
// -----------------------------------------------------------------------------
if (showBull3LS and is3LSBullSig)
strategy.entry("3LS_Bull", strategy.long, comment="3LS Bullish")
strategy.exit("Exit Bull", from_entry="3LS_Bull", limit=longTP, stop=longSL)
if (showBear3LS and is3LSBearSig)
strategy.entry("3LS_Bear", strategy.short, comment="3LS Bearish")
strategy.exit("Exit Bear", from_entry="3LS_Bear", limit=shortTP, stop=shortSL)