ストーカスティック・インディケーターをベースにした短期取引戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-28 10:45:41
タグ:

概要

この戦略は,ストコストティックオシレーター指標を使用して,短期取引のオーバーカップとオーバーセール市場状況を決定します.ストコストティック指標に黄金十字があるとき,ロングになり,リスクを制御しながら利益を確保するために,以前のピボットポイントに基づいて弾性ストップロスをベースに,デスクロスでショートします.

戦略の論理

エントリー論理

ストコスタスティックオシレーター指標は,%K線と%D線で構成される. %K線が%D線を越えると,ゴールデンクロス買い信号が生成される. %K線が%D線を下に越えると,デスクロスセール信号が起動する.この戦略は,エントリを決定するためにストコスタスティック指標のクロスオーバーを単にフォローする.

具体的には,ストカストティック指標に金色のクロスがある場合,%K値が80未満 (過買いではない) の場合,ロングポジションが取られる.ストカストティックデスクロスでは,%K値が20以上 (過売りではない) の場合,ショートポジションが開始される.

GoLong=crossover(k,d) and k<80
GoShort=crossunder(k,d) and k>20

損失の論理を止める

この戦略は,前回のピボットポイントに基づいてストップ価格を設定する,弾性ストップ損失アプローチを使用します.

piv_high = pivothigh(high,1,1)
piv_low = pivotlow(low,1,1)

stoploss_long=valuewhen(piv_low,piv_low,0)
stoploss_short=valuewhen(piv_high,piv_high,0) 

ピボットは重要なサポートとレジスタンスのレベルを表します.価格がピボットレベルを突破した場合,ポジションは閉鎖され,ストップロスはピボットポイントの変化を弾性的にします.

さらに,ストップ価格は,さらなる最適化のために,現在の期間の最高値と最低値も考慮します.

if GoLong
    stoploss_long := low<pl ? low : pl
if GoShort
    stoploss_short := high>ph ? high : ph

利点

  1. ストカスティックを使って 上下を追わないようにする

  2. 弾性ストップ損失は市場の変化に合わせてストップ価格を最適化します

  3. ストップ・ロスは,ピボット・ポイント・ブレイクアウトに基づく方が有効です.

  4. 現在の最高値と最低値を使用してストップ価格の最適化は,ストップをより正確にします.

リスク と 解決策

  1. ストカスティックの誤った信号のリスク

    • 解決策: 誤った信号を避けるため,信号を他の指標で確認する
  2. ストップ・ロスのリスクが上昇し,ストップ・ロスのリスクが上昇する

    • 解決法: 止まる距離を減らすか,シャンデリア出口のような方法を使うか
  3. 取引頻度と手数料の高さによるリスク

    • 解決策: 取引数を減らすために入国規則を緩和する

オプティマイゼーションの方向性

  1. ストップ損失を最適化します. チェンデリア出口,トレーリングストップ,振動ストップ損失などの方法を使用します.

  2. ストカスティックの誤った信号を避けるために,他の指標とエントリールールを最適化します.

  3. 利潤率を上げるため,後続利潤目標,振動利潤目標などを使用して利潤を最適化する

  4. 取引ごとに固定量,固定リスクパーセントなど,ポジションのサイズを取引リスクのコントロールに追加する.

  5. 異なる市場に基づいて,K,D期間のようにパラメータを最適化

概要

この戦略はストカスティックオーバーバイト/オーバーセールに基づいて入力し,弾性ストップ損失でリスクを管理する. 勢いを追いかけるのを避け,効果的なストップをするという利点がありますが,いくつかの誤った信号リスクもあります. エントリー,ストップ,出口,リスク管理などで将来の改善ができます.


/*backtest
start: 2023-08-28 00:00:00
end: 2023-09-27 00:00:00
period: 2h
basePeriod: 15m
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/
// © Peter_O

//@version=4
//strategy(title="TradingView Alerts to MT4 MT5 example with cancelling pending orders", commission_type=strategy.commission.cash_per_order, commission_value=0.00003, overlay=true, default_qty_value=100000, initial_capital=1000)

// This script was created for educational purposes only.
// It is showing how to create pending orders and cancel them
// Together with syntax to send these events through TradingView alerts system
// All the way to brokers for execution

TakeProfitLevel=input(400)

// **** Entries logic **** {
periodK = 13 //input(13, title="K", minval=1)
periodD = 3 //input(3, title="D", minval=1)
smoothK = 4 //input(4, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
// plot(k, title="%K", color=color.blue)
// plot(d, title="%D", color=color.orange)
// h0 = hline(80)
// h1 = hline(20)
// fill(h0, h1, color=color.purple, transp=75)

GoLong=crossover(k,d) and k<80
GoShort=crossunder(k,d) and k>20
// } End of entries logic

// **** Pivot-points and stop-loss logic **** {
piv_high = pivothigh(high,1,1)
piv_low = pivotlow(low,1,1)
var float stoploss_long=low
var float stoploss_short=high

pl=valuewhen(piv_low,piv_low,0)
ph=valuewhen(piv_high,piv_high,0)

if GoLong 
    stoploss_long := low<pl ? low : pl
if GoShort 
    stoploss_short := high>ph ? high : ph
plot(stoploss_long, color=color.lime, title="stoploss_long")
plot(stoploss_short, color=color.red, title="stoploss_short")
// } End of Pivot-points and stop-loss logic

CancelLong=crossunder(low,stoploss_long) and strategy.position_size[1]<=0 and strategy.position_size<=0
CancelShort=crossover(high,stoploss_short) and strategy.position_size[1]>=0 and strategy.position_size>=0
entry_distance=input(10, title="Entry distance for stop orders")

plotshape(CancelLong ? stoploss_long[1]-10*syminfo.mintick : na, location=location.absolute, style=shape.labelup, color=color.gray, textcolor=color.white, text="cancel\nlong", size=size.tiny)
plotshape(CancelShort ? stoploss_short[1]+10*syminfo.mintick : na, location=location.absolute, style=shape.labeldown, color=color.gray, textcolor=color.white, text="cancel\nshort", size=size.tiny)

strategy.entry("Long", strategy.long, when=GoLong, stop=close+entry_distance*syminfo.mintick)
strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)
strategy.cancel("Long", when = CancelLong)
strategy.entry("Short", strategy.short, when=GoShort, stop=close-entry_distance*syminfo.mintick)
strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)
strategy.cancel("Short", when = CancelShort)

if GoLong
    alertsyntax_golong='long offset=' + tostring(entry_distance) + ' slprice=' + tostring(stoploss_long) + ' tp=' + tostring(TakeProfitLevel)
    alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)
if GoShort
    alertsyntax_goshort='short offset=' + tostring(-entry_distance) + ' slprice=' + tostring(stoploss_short) + ' tp=' + tostring(TakeProfitLevel)
    alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)
if CancelLong
    alertsyntax_cancellong='cancel long'
    alert(message=alertsyntax_cancellong, freq=alert.freq_once_per_bar_close)
if CancelShort
    alertsyntax_cancelshort='cancel short'
    alert(message=alertsyntax_cancelshort, freq=alert.freq_once_per_bar_close)
    


もっと