国境を越えた短期的な突破の逆転 5EMA戦略

作者: リン・ハーンチャオチャン開催日:2024年1月30日15時30分19秒
タグ:

img

この記事では,5EMA指標に基づいた短期逆転取引戦略を紹介します.この戦略は主に5EMA指標を使用して,価格傾向を判断し,価格がEMAを突破すると逆転取引を行います.

戦略の概要

この戦略は,短期的な定量戦略であり,主に高周波取引に使用される.この戦略は,同時に上昇信号と下落信号を判断し,両方向に取引することができます.価格が5EMA指標を突破すると取引信号が生成され,突破方向に応じてロングまたはショートポジションが入力されます.

この戦略の利点は,短期的な価格逆転の機会を把握し,迅速に市場に参入することです.主なリスクは,偽のブレイクによる損失から生じるものです.パラメータを最適化することでリスクを軽減することができます.

戦略原則

  1. 短期的な価格動向を決定するために5期間のEMA指標を使用する

  2. 価格がEMA指標を突破するかどうかを判断する

  3. 価格がEMAを上から下へと突破すると 売り信号が生成されます

  4. 価格が EMA を下から上へと突破すると 買い信号が生成されます

  5. 単一の損失を制限するためにストップ・ロスを設定し,利益を取ります.

EMA指標は,短期的な傾向を効果的に決定できるため,価格が著しい逆転を示したときに取引機会を迅速に把握することができる. 5EMAパラメータは比較的柔軟で,市場に迅速に対応し,高周波取引に適している.

戦略 の 利点

  • 短期間の取引機会の高周波捕捉に適した迅速な応答
  • 両方向の取引は,同時に長途と短途の取引も可能です
  • 合理的なストップ・ロースと得益の設定,単一の損失限定
  • シンプルなパラメータ設定,戦略の最適化が簡単

戦略のリスクと解決策

  • 誤った脱出リスクによる不必要な損失
    • 指標の安定性を確保するために,EMAサイクルパラメータを最適化
  • 過剰な取引頻度は,簡単に高値を追いかけて低値を殺すことができます
    • 取引の最大日数

戦略の最適化方向性

  • 最適なサイクルポートフォリオを見つけるために EMA 指標のパラメータを最適化
  • 誤ったブレイクの可能性を減らすためにフィルターを増やす
  • 取引の最大日数
  • 傾向の方向性を決定するために他の指標を組み合わせる

概要

一般的には,これは非常に実用的な短期的なブレイクアウト戦略である.価格逆転を決定するためにEMA指標を使用することは非常にシンプルで有効であり,定量的な取引のための重要なツールである.パラメータ最適化とリスク管理設定を通じて,戦略の勝利率は大幅に改善され,非常に推奨される.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © samscripter

//@version=5
strategy("5 ema strategy",overlay = true,process_orders_on_close = true)

// Choose trade direction

t_dir = input.string("Both", title="Trade Direction",options=["Long", "Short", "Both"],group = 'Trade Direction Set')

long_side  = t_dir == "Long" or t_dir == "Both"
short_side = t_dir == "Short" or t_dir == "Both"

// number of trade
mx_num =input.int(4,title = 'number Of trade',group = 'Maximum Number Of Trade')
var hi =0.0
var lo =0.0

var group_ma1="Ema Set"

//Ema 1
on_ma=input.bool(true,"Enable EMa 1 Plot On/Off"  ,group =group_ma1)
ma_len= input.int(5, minval=1, title="Ema Length",group =group_ma1)
ma_src = input.source(close, title="Ema Source"   ,group = group_ma1)
ma_out = ta.ema(ma_src, ma_len)

// buy and sell ema condition  
plot(on_ma?ma_out:na, color=color.white, title="MA")


if close>ma_out and open>ma_out and low>ma_out and high>ma_out
    lo:=low

if close<ma_out and open<ma_out and low<ma_out and high<ma_out
    hi:=high
    
// condition when price is crossunder lo take sell and when price crossoing hi take buy 
var buyp_sl =float(na)
var sellp_sl =float(na)

//count number trade since day stra
var count_buysell=0

if  close>hi[1] 
    if strategy.position_size==0 and count_buysell<mx_num and long_side
        strategy.entry('El',strategy.long,comment = 'Long')
        count_buysell:=count_buysell+1
        buyp_sl:=math.min(low,low[1])
    hi:=na
if  close<lo[1]
    if strategy.position_size==0 and count_buysell<mx_num and short_side
        strategy.entry('Es',strategy.short,comment = 'short')
        count_buysell:=count_buysell+1
        sellp_sl:=math.max(high,high[1])
    lo:=na

//take profit multiply 

tpnew = input.float(title="take profit", step=0.1, defval=1.5, group='Tp/SL')


//stop loss previous candle high and previous candle low
buy_sl = ta.valuewhen(strategy.position_size != 0 and strategy.position_size[1] == 0,buyp_sl , 0)
sell_sl= ta.valuewhen(strategy.position_size != 0 and strategy.position_size[1] == 0,sellp_sl, 0)

//take profit
takeProfit_buy = strategy.position_avg_price - ((buy_sl - strategy.position_avg_price) *tpnew)
takeProfit_sell = strategy.position_avg_price - ((sell_sl - strategy.position_avg_price) *tpnew)


//  Submit exit orders
if strategy.position_size > 0
    strategy.exit(id='XL', stop=buy_sl,limit=takeProfit_buy,comment_loss = 'Long Sl',comment_profit = 'Long Tp')

if strategy.position_size < 0
    strategy.exit(id='XS', stop=sell_sl,limit=takeProfit_sell,comment_loss = 'Short Sl',comment_profit = 'Short Tp')
    
//plot data
plot(series=strategy.position_size < 0 ?sell_sl : na, style=plot.style_circles, color=color.red, linewidth=2, title="St red Stop")
plot(series=strategy.position_size > 0 ?buy_sl  : na, style=plot.style_circles, color=color.green, linewidth=2, title="St green Stop")


// plot take profit
plot(series=strategy.position_size < 0 ? takeProfit_sell : na, style=plot.style_circles, color=color.orange, linewidth=2, title="take profit sell")
plot(series=strategy.position_size > 0 ? takeProfit_buy: na, style=plot.style_circles, color=color.blue, linewidth=2, title="take profit buy")

if ta.change(time('D'))
    count_buysell:=0

もっと