
この戦略は,Parabolic SAR (パラボリック・リベラル・シフト・インジケーター),MACD (指数平滑移動平均) とRSI (相対的に強いインジケーター) の3つの指標を組み合わせて,複数のタイムフレームで自動化された多空頭取引を実現します. この戦略は,主に株式や商品の品種の1日間の取引に適用されます.
PSAR指標は,価格の方向とトレンドの逆転点を判断するために使用される.点数が下がるときは多頭信号,点数が上がるときは空頭信号である.
MACD指標は価格動力を判断する. MACD線とSIGNAL線は,上方突破は多頭信号で,下方突破は空頭信号である.
RSI指標は,超買い超売り現象を判断する.RSIは,値より高いときは多頭信号,値より低いときは空頭信号である.
この3つの指標のシグナルを統合して,最終的な多空頭決定を形成する.
チョップ・インデックスを用いてコンソリデートする市場をフィルターし,ウィップソースを避ける.
逆ピラミッド加仓の原理を採用し,ストップ・ロストとストップ・ストップの設定によってリスクと利益のダイナミックな管理を実現する.
複数の指標を組み合わせて,トレンド,動力,超買超売の特徴を総合的に判断し,意思決定の正確性を向上させる.
市場特性に適応し,Chop Indexの指標をフィルタリングして,市場を統合し,套入を避ける.
リスクと利益の動態管理,逆ピラミッド加仓原理により,主動ストップ・ストップを実現する.
カスタマイズ・最適化可能なパラメータが多く,異なる品種と市場環境に容易に調整できます.
複数のタイムフレームをサポートし,日中の短線と中距離の取引に柔軟に対応できます.
多空頭決定はパラメータ設定に依存し,不適切な設定はエラーを引き起こす可能性がある.
指標が誤った信号を発信する可能性があり,トレンドに反する決定が形成される可能性がある.
ストップダストの設定が不適切で,損失を増加させたり,利益を減少させたりする可能性があります.
パーメータを頻繁にモニタリングし,調整し,人工介入のコストが高くなります.
モデル検証モジュールを追加し,パラメータ設定と信号の有効性を評価する.
機械学習モジュールを追加し,パラメータとモデルの自動最適化を可能にします.
データの源を拡大し,機能の拡張を図り,意思決定の効果を向上させる.
自動化された監視・運用・メンテナンスシステムを開発し,人工介入コストを削減する.
テストの効果を評価し,テスト戦略の有効性を高めます.
この戦略は,複数の技術指標の組み合わせを使用して,ルールに基づく自動化された定量取引を実現しています.戦略の最適化スペースは大きく,拡張性が強く,パラメータ調整,機能拡張,機械学習などの最適化に適しており,実体取引に優れています.
/*backtest
start: 2022-12-20 00:00:00
end: 2023-12-26 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/
// © vikris
//@version=4
strategy("[VJ]Phoenix Force of PSAR +MACD +RSI", 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=3) * 0.01
shortProfitPerc = input(title="Short Take Profit (%)",
type=input.float, minval=0.0, step=0.1, defval=3) * 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=3) * 0.01
shortLossPerc = input(title="Short Stop Loss (%)",
type=input.float, minval=0.0, step=0.1, defval=3) * 0.01
// ********** 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 = barInSession(i_marketSession)
// Trade only if intraday session is active
//=================Strategy logic goes in here===========================
psar = sar(0.02,0.02,0.2)
c1a = close > psar
c1v = close < psar
malen = input(50, title="MA Length")
mm200 = sma(close, malen)
c2a = close > mm200
c2v = close < mm200
fast = input(12, title="MACD Fast EMA Length")
slow = input(26, title="MACD Slow EMA Length")
[macd,signal,hist] = macd(close, fast,slow, 9)
c3a = macd >= 0
c3v = macd <= 0
rsilen = input(7, title="RSI Length")
th = input(50, title="RSI Threshold")
rsi14 = rsi(close, rsilen)
c4a = rsi14 >= th
c4v = rsi14 <= th
chopi = input(7, title="Chop Index lenght")
ci = 100 * log10(sum(atr(1), chopi) / (highest(chopi) - lowest(chopi))) / log10(chopi)
buy = c1a and c2a and c3a and c4a ? 1 : 0
sell = c1v and c2v and c3v and c4v ? -1 : 0
//Final Long/Short Condition
longCondition = buy==1 and ci <50
shortCondition = sell==-1 and ci <50
//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
stop_level = longStopPrice
profit_level = longExitPrice
strategy.entry("My Long Entry Id", strategy.long)
strategy.exit("TP/SL", "My Long Entry Id", 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("My Short Entry Id", strategy.short)
strategy.exit("TP/SL", "My Short Entry Id", 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 **********