双指数コンボ クレイジー・イントラデイ・スカルピング戦略

作者: リン・ハーンチャオチャン開催日:2023年12月1日 14:47:57
タグ:

img

概要

この戦略は,LuxAlgoのTMOとAMAインジケーターからの購入・売却信号を組み合わせ,レンジ限定統合中のトレンドの始まりを捕捉する.TMO信号,AMA極限,キャンドルボディサイズ増加の条件を満たしたときに,長または短くなります.ストップロスは最近のバーに基づいて最新のスイング高/低に設定されます.

戦略の論理

TMOインジケーターは価格の勢いを反映する.オシレーターインジケータータイプに属し,ダイバージェンスが発生すると取引信号を生成することができる.AMAインジケーターはスムーズ移動平均値である.価格変動の範囲を示し,価格が上位/下位帯に近づくと過買い/過売状態を示します.

この戦略の背後にある主な論理は:TMOはトレンドディバージェンスを検出し,トレード信号を生成することができる.AMAは価格逆転ゾーンを特定することができる.キャンドルボディサイズを増やすことの確認とともに,トレンド開始の正確性を改善することができる.したがって,戦略は:

  1. TMOは買いシグナル,つまり上昇差を示し AMAは最大極限を示します
  2. TMOは売り信号を表示します.つまり,下落差とAMAは最小端を示します.
  3. また,最大3キャンドルのボディを拡張する必要があります.

これは単一指標の誤った信号問題を解決します.最近のバー最高最高/最低最低値に基づくストップロスはリスクを効果的に制御できます.

利点

この戦略の利点は以下の通りです.

  1. インディケーターコンボは信号の精度を向上させる.TMOとAMAは互いに検証し,偽信号を減少させ,精度を向上させる.

  2. 複数の条件がトレンド開始を捕捉する.TMO信号,AMA端末,キャンドルサイズ増加の組み合わせにより,スキルピング戦略が追求するトレンド開始を効果的に特定することができます.

  3. キャンドルベースのストップ・ロスはリスクを管理します.最近のバー最高/最低価格をストップ・ロスとして使用することで,インジケーター再計算による遅れリスクを回避しながら,各取引のリスクを制御します.

  4. 簡潔で効果的な論理. たった2つの指標で,この戦略は,明確で単純な論理を持つ完全なスカルピングシステムを実装しました.バックテストの結果も利益に見えます.

リスク

戦略の主なリスクは

  1. 短期間の保有期間を狙ったスカルピング戦略であるため,高い取引コストが収益性に影響を与える可能性があります.

  2. 攻撃的なストップ・ロスのリスク.ストップ・ロスの最近の極端な価格を使用することで,市場の騒音に脆弱になり,ストップ・ロスの誘発の可能性を増やす可能性があります.

  3. パラメータ最適化リスク. 戦略には複数のパラメータが含まれます. 最適なパラメータの組み合わせを見つけるのは困難です.

最適化

この戦略は,次の分野においてさらに最適化できます.

  1. ボリュームなどのフィルターインジケーターを追加して 偽信号を削除し 信号の質をさらに改善します

  2. ストップ・ロスの規則を修正し,攻撃性が軽減します.例えば,ストップ・ロスを起動する前に確認バーを追加します.

  3. パラメータ最適化を行い,インディケーターに最適なパラメータ組み合わせを見つけ,より多くのノイズをフィルターし,勝利率を増加させるのに役立ちます.主にTMO長さ,AMA長さおよび倍数者を最適化します.

  4. この戦略の論理に最も適した市場条件を見つけるために 異なる製品とタイムフレームを介してバックテストし 取引します

結論

この戦略は,初期トレンド動きを捕捉することで,TMOとAMAからのトレード信号をレンジバインド市場での頭皮に組み合わせます.この戦略は,高い信号精度,早期トレンド捕捉,効果的なリスク制御の利点があります.パラメータと戦略規則のさらなる最適化により,非常に実用的なイントラデイスカルピング戦略になります.


/*backtest
start: 2023-11-23 00:00:00
end: 2023-11-30 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Kaspricci

//@version=5
strategy("TradeIQ - Crazy Scalping Trading Strategy [Kaspricci]", overlay=true, initial_capital = 1000, currency = currency.USD)

headlineTMO = "TMO Settings"

tmoLength   = input.int(7, "TMO Length", minval = 1, group = headlineTMO)
tmoSource   = input.source(close, "TMO Source", group = headlineTMO)

// calculate values
osc         = ta.mom(ta.sma(ta.sma(tmoSource, tmoLength), tmoLength), tmoLength)

// determine color of historgram
oscColor    = osc > osc[1] and osc > 0 ? #00c42b : osc < osc[1] and osc > 0 ? #4ee567 : osc < osc[1] and osc < 0 ? #ff441f : osc > osc[1] and osc < 0 ? #c03920 : na

// plot histogram
//plot(osc, "OSC", oscColor, linewidth = 3, style = plot.style_histogram)

// conditon to find highs and lows
up          = ta.highest(tmoSource, tmoLength)
dn          = ta.lowest(tmoSource, tmoLength)

// define conditions to be used for finding divergence
phosc = ta.crossunder(ta.change(osc), 0)
plosc = ta.crossover (ta.change(osc), 0)

// test for divergence
bear = osc > 0 and phosc and ta.valuewhen(phosc,osc,0) < ta.valuewhen(phosc,osc,1) and ta.valuewhen(phosc,up,0) > ta.valuewhen(phosc,up,1) ? 1 : 0
bull = osc < 0 and plosc and ta.valuewhen(plosc,osc,0) > ta.valuewhen(plosc,osc,1) and ta.valuewhen(plosc,dn,0) < ta.valuewhen(plosc,dn,1) ? 1 : 0

// -------------------------------------------------------------------------------------------------------------

headlineAMA = "AMA Settings"

amaSource   = input.source(defval = close, title = "AMA Source", group = headlineAMA)
amaLength   = input.int(defval = 50, title = "AMA Length", minval = 2, group = headlineAMA)


amaMulti    = input.float(defval = 2.0, title = "Factor", minval = 1)

amaShowCd   = input(defval = true , title = "As Smoothed Candles")
amaShowEx   = input(defval = true,   title = "Show Alternating Extremities")

amaAlpha    = input.float(1.0, "Lag",       minval=0, step=.1, tooltip='Control the lag of the moving average (higher = more lag)', group= 'AMA Kernel Parameters')
amaBeta     = input.float(0.5, "Overshoot", minval=0, step=.1, tooltip='Control the overshoot amplitude of the moving average (higher = overshoots with an higher amplitude)', group='AMA Kernel Parameters')

// -------------------------------------------------------------------------------------------------------------

headlineSL = "Stop Loss Settings"

slLength    = input.int(defval = 10, title = "SL Period", minval = 1, group = headlineSL, tooltip = "Number of bars for swing high / low")

// -------------------------------------------------------------------------------------------------------------

var b       = array.new_float(0)
var float x = na

if barstate.isfirst
    for i = 0 to amaLength - 1
        x := i / (amaLength - 1)
        w = math.sin(2 * 3.14159 * math.pow(x, amaAlpha)) * (1 - math.pow(x, amaBeta))
        array.push(b, w)

// local function to filter the source
filter(series float x) =>
    sum = 0.

    for i = 0 to amaLength - 1
        sum := sum + x[i] * array.get(b,i)
    
    sum / array.sum(b)

// apply filter function on source series

srcFiltered = filter(amaSource)

deviation   = ta.sma(math.abs(amaSource - srcFiltered), amaLength) * amaMulti

upper       = srcFiltered + deviation
lower       = srcFiltered - deviation

//----
crossHigh   = ta.cross(high, upper)
crossLow    = ta.cross(low, lower)

var os      = 0
os          := crossHigh ? 1 : crossLow ? 0 : os[1]

ext         = os * upper + (1 - os) * lower

//----
os_css = ta.rsi(srcFiltered, amaLength) / 100

extColor    = os == 1 ? #30FF85 : #ff1100

plot(srcFiltered, "MA", amaShowCd ? na : color.black, 2, editable = false)
plot(amaShowEx ? ext : na, "Extremities", ta.change(os) ? na : extColor, 2, editable=false)

// handle smoothed candles
var float h = na
var float l = na
var float c = na
var float body = na

if amaShowCd
    h := filter(high)
    l := filter(low)
    c := filter(amaSource)
    body := math.abs(math.avg(c[1], c[2]) - c)

ohlc_os = ta.rsi(c, amaLength) / 100

plotcandle(math.avg(c[1], c[2]), h, l, c, "Smooth Candles", #434651, bordercolor = na, editable = false, display = amaShowCd ? display.all : display.none)

// -------------------------------------------------------------------------------------------------------------

plotshape(bull ? ext : na, "Bullish Circle", shape.circle,    location.absolute, color = #00c42b, size=size.tiny)
plotshape(bear ? ext : na, "Bearish Circle", shape.circle,    location.absolute, color = #ff441f, size=size.tiny)
plotshape(bull ? ext : na, "Bullish Label",  shape.labeldown, location.absolute, color = #00c42b, text="Buy", textcolor=color.white, size=size.tiny)
plotshape(bear ? ext : na, "Bearish Label",  shape.labelup,   location.absolute, color = #ff441f, text="Sell", textcolor=color.white, size=size.tiny)

// -------------------------------------------------------------------------------------------------------------

candleSizeIncreasing = body[2] < body[1] and body[1] < body[0]

longEntryCond   = os == 1 and bull
shortEntryCond  = os == 0 and bear

longEntry       = strategy.opentrades == 0 and candleSizeIncreasing and not candleSizeIncreasing[1] and ta.barssince(longEntryCond)  < ta.barssince(os == 0) and ta.barssince(longEntryCond) < ta.barssince(bear)
shortEntry      = strategy.opentrades == 0 and candleSizeIncreasing and not candleSizeIncreasing[1] and ta.barssince(shortEntryCond) < ta.barssince(os == 1) and ta.barssince(shortEntryCond) < ta.barssince(bull)

longExit        = strategy.opentrades > 0 and strategy.position_size > 0 and (bear or os == 0)
shortExit       = strategy.opentrades > 0 and strategy.position_size < 0 and (bull or os == 1)

recentSwingHigh = ta.highest(high, slLength) // highest high of last candles
recentSwingLow  = ta.lowest(low,   slLength) // lowest low of recent candles

bgcolor(longEntry  ? color.rgb(76, 175, 79, 90) : na)
bgcolor(shortEntry ? color.rgb(255, 82, 82, 90) : na)

slLong          = (close - recentSwingLow) / syminfo.mintick  // stop loss in ticks
slShort         = (recentSwingHigh - close) / syminfo.mintick // stop loss in ticks

newOrderID         = str.tostring(strategy.closedtrades + strategy.opentrades + 1)
curOrderID         = str.tostring(strategy.closedtrades + strategy.opentrades)

alertMessageForEntry = "Trade {0} - New {1} Entry at price: {2} with stop loss at: {3}"

if (longEntry)
    alertMessage = str.format(alertMessageForEntry, newOrderID, "Long", close, recentSwingLow)
    
    strategy.entry(newOrderID, strategy.long, alert_message = alertMessage)
    strategy.exit("Stop Loss Long", newOrderID, loss = slLong, alert_message = "Stop Loss for Trade " + newOrderID)

if(longExit)
    strategy.close(curOrderID, alert_message = "Close Trade " + curOrderID)

if (shortEntry)
    alertMessage = str.format(alertMessageForEntry, newOrderID, "Short", close, recentSwingLow)

    strategy.entry(newOrderID, strategy.short, alert_message = alertMessage)
    strategy.exit("Stop Loss Short", newOrderID, loss = slShort, alert_message = "Stop Loss for Trade " + newOrderID)

if(shortExit)
    strategy.close(curOrderID, alert_message = "Close Trade " + curOrderID)

もっと