MFIとMAに基づく量的な逆転戦略

作者: リン・ハーンチャオチャン開催日:2023年12月27日 14:42:16
タグ:

img

概要

この戦略は,価格逆転方向をフィルタリングするためにMAと組み合わせて,過剰購入および過剰販売ゾーンを特定するためにMFI指標を使用します. 株式,外為,商品,暗号市場ではうまく機能します.

戦略の論理

この戦略は,市場における過買い・過売り状況を評価するために,MFI指標を活用する.MFIが過買い・過売りゾーンに20を下回ると,資産が過大評価され,底辺が形成されていることを示唆する.MFIが80を超えて過買いエリアに上昇すると,資産が過大評価され,すぐに下回り修正する可能性があり,ショート信号を誘発することを示唆する.

誤った逆転を避けるため,戦略は,傾向の方向性を決定するためにMA指標も使用します. MFIの逆転が価格突破またはMA線上にある場合にのみ取引シグナルが生成されます.

具体的な取引論理は:

  1. MFIが20を下回り 過売れ区間に突入し,閉じる値がMA線以上になると,買い信号が生成されます.

  2. MFIが80を突破してオーバー買いゾーンに突入し,閉じる値がMA線を突破すると,セールシグナルが発信されます.

双重指標の確認により,戦略は信頼性の高いエントリー信号で逆転の機会を効果的に特定することができます.

利点

  1. 二重インジケーターの確認は 偽のブレイクを回避し 高い信号信頼性を保証します

  2. 過剰購入/過剰売却の逆転を活用することは,古典的で,時間的に検証された取引技術です.

  3. 傾向フィルタリングを組み込むことで 信号はより正確で信頼性が高まります

  4. 適応性が強い様々な市場に適用可能

リスク

  1. 市場が継続的に上昇または減少傾向を持ち,ストップ・ロスを引き起こす可能性があります.

  2. 極端な市場状況で システム的なリスクに気をつけなければなりません

  3. 取引頻度が高い場合,取引コストが上昇する可能性があります.

緩和策

  1. ストップロスの幅を広げて戦略に余裕を与えます

  2. システムリスクのシグナルのために,より高い時間枠のチャートを観察しながら,ポジションのサイズを慎重に増やす.

  3. 必要のない取引を避けるためにパラメータを最適化します

増進 の 機会

  1. MAパラメータを最適化して,取引手段の特徴に合わせる.

  2. 市場情勢の変動に基づいて 過剰購入/過剰販売のレベルを調整する

  3. ポジションのサイズを決めるルールを導入して 利益をコントロールする

結論

この戦略は,古典的な分析技術と近代的な量子方法を統合している.二重指標の確認を厳格に適用することで,さまざまな機器に強い適応性を示し,一般的な短期戦略を推奨している.


/*backtest
start: 2023-12-19 00:00:00
end: 2023-12-26 00:00:00
period: 1m
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/
// © vikris

//@version=4
strategy("[VJ]Thor for MFI", overlay=true, calc_on_every_tick = false,pyramiding=0)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

// Make inputs that set the take profit % (optional)
longProfitPerc = input(title="Long Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01

shortProfitPerc = input(title="Short Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
     
// Set stop loss level with input options (optional)
longLossPerc = input(title="Long Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01

shortLossPerc = input(title="Short Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01    

i_MFI = input(3, title="MFI Length")
OB=input(100, title="Overbought Level")
OS=input(0, title="Oversold Level")
barsizeThreshold=input(.5, step=.05, minval=.1, maxval=1, title="Bar Body Size, 1=No Wicks")
i_MAFilter = input(true, title="Use MA Trend Filter")
i_MALen = input(80, title="MA Length")
// ********** Strategy inputs - End **********


// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0
// Figure out take profit price
longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)

// Determine stop loss price
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)


// ********** Supporting functions - End **********


// ********** Strategy - Start **********
// See if intraday session is active
bool intradaySession = true

// Trade only if intraday session is active

//=================Strategy logic goes in here===========================
 

MFI=mfi(close,i_MFI)
barsize=high-low
barbodysize=close>open?(open-close)*-1:(open-close)
shortwicksbar=barbodysize>barsize*barsizeThreshold
SMA=sma(close, i_MALen)
MAFilter=close > SMA



BUY = MFI[1] == OB and close > open and shortwicksbar and (i_MAFilter ? MAFilter : true)

SELL = MFI[1] == OS and close < open and shortwicksbar and (i_MAFilter ? not MAFilter : true) 

//Final Long/Short Condition
longCondition = BUY
shortCondition = SELL
 
//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
    stop_level = longStopPrice
    profit_level = longExitPrice
    strategy.entry("Buy", strategy.long)
    strategy.exit("TP/SL", "Buy", stop=stop_level, limit=profit_level)


//Short Strategy - sell condition and exits with Take profit and SL
if (shortCondition and intradaySession)
    stop_level = shortStopPrice
    profit_level = shortExitPrice
    strategy.entry("Sell", strategy.short)
    strategy.exit("TP/SL", "Sell", stop=stop_level, limit=profit_level)
 
 
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********

もっと