スタン・ザ・マン - 二重移動平均値と波動性に基づいた高度な株式取引戦略

作者: リン・ハーンチャオチャン開催日:2023年12月20日 14:54:41
タグ:

img

概要

この戦略は,株式取引の購入・売却シグナルを自動化するために,二重移動平均システムと相対強度指数を使用している.利点は,リスクを効果的に制御するために長期および短期的技術の両方を組み合わせることです.しかし,改善の余地はまだあります.例えば,ストップ損失メカニズムを追加することができます.

戦略の論理

この戦略は150週間の移動平均値と50日間の高速移動平均値を活用してダブルMAシステムを形成する. 20日間の超高速MAも使用する.価格が150週間のMAを超えると上昇傾向が始まる.価格が50日間のMAを下回ると下落傾向が始まる.これは上向きで購入し,下向きで販売することを可能にします.

さらに,この戦略は,特定のエントリーポイントを決定するために,波動性と相対強度指数に基づく年間最高価格を使用します. 閉じる価格が波動性から計算された最大価格を超え,RSIが正である場合にのみ購入信号を送信します.

利点

  1. 二重MAシステムでは 上向きを追いかけて下向きを停止する傾向の変化を効果的に特定できます

  2. 波動性指標とRSIは 横向市場で 打ち負かされないようにします

  3. 20日間の高速MAは,より速いストップ損失を可能にします.

リスク

  1. ストップ・ロスはすぐに実現できない.

  2. ストップ・ロスは設定されていないので 大額の損失につながる可能性があります

  3. パラメータの最適化がないので,パラメータは任意に設定されます.

リスクを軽減するために,ストップ・ロスを追加したり,ストップ・ロスの割合としてATR倍数を使用したりできます.より厳格なバックテストによるパラメータ最適化も役立ちます.

増進 の 機会

  1. ストップ損失メカニズムを追加する
  2. 最適化によって最適なパラメータを見つける
  3. ボリュームなどの他のフィルターを追加することを検討します
  4. より多くの要素を持つ多因子モデルに構築できます

概要

概要すると,これはかなり保守的な株式投資戦略である.全体的なトレンドを測定するためにダブルMAシステムを使用し,時間エントリーへの変動性と強度測定と組み合わせて,偽のブレイクアウトを効果的にフィルタリングすることができます.高速MAは迅速な出口も可能にします.しかし,ストップ損失,パラメータ最適化などを追加することで戦略をさらに改善することができます.全体的には,長期株投資家に適しています.


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

//@version=4
//Relative Strength
strategy("Stan my man", overlay=true)
comparativeTickerId = input("BTC_USDT:swap",  title="Comparative Symbol")
l = input(50, type=input.integer, minval=1, title="Period")
baseSymbol = security(syminfo.tickerid, timeframe.period, close)
comparativeSymbol = security(comparativeTickerId, timeframe.period, close)
hline(0, color=color.black, linestyle=hline.style_dotted)
res = baseSymbol / baseSymbol[l] /(comparativeSymbol / comparativeSymbol[l]) - 1
plot(res, title="RS", color=#1155CC)

//volume ma
vol1 = sma(volume,20)
// 30 week ma
ema1 = ema(close, 150)
//consolidation
h1 = highest(high[1],365)

fastPeriod = input(title="Fast MA", type=input.integer, defval=50)
slowPeriod = input(title="Slow MA", type=input.integer, defval=150)
fastestperiod = input(title="Fastest MA", type=input.integer, defval=20)

fastEMA = ema(close, fastPeriod)
slowEMA = ema(close, slowPeriod)
fastestEMA = ema(close, fastestperiod)

monitorStrategy = close < close[20]


// trade conditions
buytradecondition1 = close >ema1 and res>0 and volume> 1.5*vol1 and close > h1
buytradecondition2 = close > fastEMA  and volume> 1.5* vol1 
selltradecondition1  = close< 0.95 * fastEMA 
selltradecondition2  = close< 0.90 * open

if (buytradecondition1)
    strategy.entry("long",strategy.long,alert_message ="Seems ready to Buy")
    alert("Buy Alert Price (" + tostring(close) + ") crossed over Slow moving average",alert.freq_all)
    
if (buytradecondition2)
    strategy.entry("long",strategy.long,alert_message ="Seems ready to Buy")
    alert("Buy Alert Price (" + tostring(close) + ") crossed over fast moving average",alert.freq_all)
    
if (selltradecondition1)
    strategy.close("long",alert_message ="Seems ready to Sell")
    alert("Sell Alert Price (" + tostring(close) + ") crossed down fast moving average",alert.freq_all)
    
if (selltradecondition2)
    strategy.close("long",alert_message ="Seems ready to Sell")
    alert("Sell Alert Price (" + tostring(close) + ") crossed down 10% below open price  ",alert.freq_all)

//alertcondition(buytradecondition1,title ="BuySignal", message ="Price Crossed Slow Moving EMA ")

plot(fastEMA, color=color.navy)
plot(slowEMA, color=color.fuchsia)
plot(fastestEMA, color=color.green)

もっと