STOCH をベースにした自動取引戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-28 11:38:44
タグ:

この戦略は,STOCH指標に基づいた単純な自動取引システムを設計しています. これは,Forex,株式指数,商品に適しており,株式および暗号市場に拡張することができます.

戦略の概要

この戦略は,STOCH指標とPIVOTポイントを組み合わせて,ストップ損失ポジションを設定し,トレンドをフォローする.STOCH指標がオーバー買いまたはオーバーセールシグナルを示すとき,ロングまたはショートになります.ストップ損失ポイントは,リスクを効果的に制御するために,日のPIVOTポイントに近い位置に設定されます.部分的な取利益ポイントは,特定の利益レベル後に部分的なポジションを閉じます.

戦略の論理

この戦略は,STOCH インジケーターの %K と %D の線を交差して長線と短線信号を生成する.特に,%K の線が %D の線を越えると,長線になります.%K の線が %D の線を下に越えると,短線になります.これは過買いと過売りの状態を把握します.

リスクを制御するために,ロングストップ・ロスは PIVOT 最低点近く,ショートストップ・ロスは PIVOT 最高点近くに設定されます. これによりリスクが効果的にロックされます.

部分的な利益を得るには,ポジションを開設後一定の利益レベルに達した後,ポジションの50%を閉じる.これは資本利用効率を最適化する.

概要すると,この戦略は,過剰購入と過剰売却ポイントを適切にキャプチャし,ストップロスを使用してリスクを制御し,資本利用効率を最適化します.それはオーガニックにキャプチャ,コントロール,最適化を組み合わせます.

戦略 の 強み

  • STOCH インディケーターを使用すると,過剰購入と過剰販売の状況が効果的に把握されます.PIVOT ポイントを使用して,リスクを包括的に制御します.

  • 部分的利益のメカニズムは,資本の利用効率を最適化します.部分的な閉鎖は,さらなる利益のための余地を維持しながら,一定の利益を確保します.

  • パーソナライズ可能なパラメータは,市場状況とリスク優先順位に基づいて柔軟性を可能にします.

  • シンプルで明快な論理,すべてのトレーダーが簡単に理解し,マスターする. クリーンなコードは修正と保守を容易にする.

戦略リスク

  • トレンドフォローする戦略として レンジ・バインド市場に閉じ込められ 利益を得ることができません

  • STOCH は 偽信号 を 生み出し,不必要な 取引 を 引き起こす こと が あり ます.不必要な 取引 を 避ける ため に,適切な 信号 フィルタリング が 必要 です.

  • ストップ・ロスは,ブレイクアウト後,ピボット・ポイントの近くで 近づいてしまうことがあります.ストップ・ロスの距離を適切に広げてください.

  • 期間などのパラメータは 異なる市場に合わせて調整が必要で 戦略の業績に影響します

  • バックテストは過去データだけに 基づいており 将来のパフォーマンスは保証できません

  • 自動取引システムでは,取引実行上の問題を回避するために安定した接続が必要です.

戦略の最適化

  • 明確なトレンドのない取引を避けるためにトレンドフィルターを追加します.例えば,トレンド方向を決定するためにMAを使用します.

  • 偽のブレイクを検出し罠を避けるためにボリューム分析を追加します.例えば,上昇/下落ボリューム.

  • 性能を最適化するために 異なる製品とタイムフレームに基づいて STOCH 入力などのパラメータを調整します

  • マシン学習アルゴリズムを考慮して 大量のデータを使ってモデルを訓練し パラメータを自動最適化します

  • リスク管理を導入し 巨額の損失を回避するために 利益因子比を設定します

  • 勝率を向上させるための 基本要素のような フィルターを追加します

結論

この戦略は,過剰購入/過剰売却のポイントを特定するためにSTOCH指標に基づくシンプルで直感的なトレンドフォローアプローチを採用している.PIVOTストップ損失を使用してリスクを制御し,資本効率を最適化するために部分的な利益を得ている.デザインはキャプチャ,コントロール,最適化を含む.論理はシンプルでカスタマイズ可能である.しかし,いくつかのリスクも伴い,さらに最適化することができる.ライブ取引における継続的なテストと改善は安定した収益性にとって重要です.


/*backtest
start: 2022-09-21 00:00:00
end: 2023-09-27 00:00:00
period: 1d
basePeriod: 1h
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 - Forex, indices, commodities, stocks, crypto", commission_type=strategy.commission.cash_per_contract, commission_value=0.00003, overlay=false, default_qty_value=20000, initial_capital=1000)
//
// This script was created for educational purposes only.
// It is showing how to use Alerts-Straight-From-Strategies and
// dynamic variables in TradingView alerts.
// And how to auto-execute them in Forex, indices, commodities markets
// 
// (This method will also work with stocks and crypto - anything your 
// broker is offering via their MT4/MT5 platform).
 
TakeProfitLevel=input(400)
TakePartialProfitLevel=input(150)

// **** Entries logic **** {
periodK = input(13, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = 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 and year>2009
GoShort=crossunder(k,d) and k>20 and year>2009

AlertTest=open>close or open<close or open==close
// } 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
// } End of Pivot-points and stop-loss logic

// **** Trade counter and partial closing mechanism **** {
var int trade_id=0
if GoLong or GoShort
    trade_id:=trade_id+1

TakePartialProfitLong = barssince(GoLong)<barssince(GoShort) and crossover(high,(valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))
TakePartialProfitShort = barssince(GoLong)>barssince(GoShort) and crossunder(low,(valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))
// } End of Trade counter and partial closing mechanism

strategy.entry("Long", strategy.long, when=GoLong)
strategy.exit("XPartLong", from_entry="Long", qty_percent=50, profit=TakePartialProfitLevel)
strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)
strategy.entry("Short", strategy.short, when=GoShort)
strategy.exit("XPartShort", from_entry="Short", qty_percent=50, profit=TakePartialProfitLevel)
strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)

if GoLong
    alertsyntax_golong='long slprice=' + tostring(stoploss_long) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)
    alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)
if GoShort
    alertsyntax_goshort='short slprice=' + tostring(stoploss_short) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)
    alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)
if TakePartialProfitLong
    alertsyntax_closepartlong='closepart tradeid=' + tostring(trade_id) + ' part=0.5'
    alert(message=alertsyntax_closepartlong, freq=alert.freq_once_per_bar_close)
if TakePartialProfitShort
    alertsyntax_closepartshort='closepart tradeid=' + tostring(trade_id) + ' part=0.5'
    alert(message=alertsyntax_closepartshort, freq=alert.freq_once_per_bar_close)


もっと