OPEN-SOURCE SCRIPT

Pullback & ATR Trailing Strategy

242
※日本語は英文の次に記載あります。
Overview
This indicator combines short-term RSI pullback/rebound signals with long-term RSI divergence to visualize potential buy and sell opportunities.
It also plots ATR-based trailing stops and partial take-profit lines, making it suitable for day trading and short-term trading.
Alerts are triggered when signal conditions are met.

Key Features
Detect short-term RSI pullbacks/rebounds (default 6 periods)
Detect divergences on long-term RSI
Visualize buy/sell signals with labels
Display ATR-based trailing stop and partial take-profit lines
Trigger alerts when conditions are met

Settings Explanation
Short-term RSI Length (rsiShortLen)  Period for short-term RSI used to detect pullbacks or rebounds

Pullback Threshold (levelLow) RSI level below which a buy signal is considered

Rebound Threshold (levelHigh) RSI level above which a sell signal is considered

Long-term Timeframe (longTF) Timeframe used for divergence detection

Long-term RSI Length (longRSILen) Period for RSI on the long-term timeframe, used for divergence detection

Pivot Width Left / Right (pivotLeft / pivotRight)
Determines how we detect swing highs/lows (peaks and valleys).
For example, with pivotLeft=3 and pivotRight=3, a bar is considered a swing high if it is higher than the 3 bars to its left and 3 bars to its right.
Larger numbers detect only bigger swings, smaller numbers also detect smaller swings.

ATR Length (atrLen) Period for ATR calculation for trailing stops

ATR Multiplier (atrMult) Multiplier for ATR to calculate trailing stop distance

Partial Take-Profit Multiplier (tpMult) Multiplier to calculate half-profit level based on swing amplitude

Green line (Long Trail / translucent green)
ATR-based trailing stop line for long positions.
Used as a stop-loss or trailing stop for open buy trades.
Dark green line shows partial take-profit (TP), translucent green shows trailing stop level.
Red line (Short Trail / translucent red)
ATR-based trailing stop line for short positions.
Used as a stop-loss or trailing stop for open sell trades.
Dark red line shows partial take-profit (TP), translucent red shows trailing stop level.
Note: TP lines indicate partial take-profit targets, while ATR trailing lines indicate stop-loss/trailing stop levels if the price moves against the position.

日本語説明ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
概要
このインジケーターは、短期RSIの押し目/戻りシグナルと、長期足RSIによるダイバージェンスを組み合わせて、買い・売りのチャンスを可視化します。
さらに、ATRベースのトレールストップラインや半分利確ラインも表示し、デイトレードや短期トレードに最適化しています。
シグナル条件に一致した場合にアラートも作動します。

主な機能
短期RSI(デフォルト6期間)で押し目・戻りを検出
長期足RSIでのダイバージェンスを検出
BUY/SELLラベルでシグナルを視覚化
ATRベースのトレールライン・半分利確ラインを表示
条件一致時にアラート発動

各設定の説明
短期RSI期間 (rsiShortLen)   デイトレ用の短期RSIの期間。押し目や戻りのシグナルに使用
押し目閾値 (levelLow)   RSIが下回ったら買いシグナル判定に使用
戻り閾値 (levelHigh)   RSIが上回ったら売りシグナル判定に使用
長期足 (longTF)        ダイバージェンス判定用の長期足の時間軸
長期RSI期間 (longRSILen)   長期足で計算するRSIの期間。ダイバージェンス判定に使用
左右ピボット幅 (pivotLeft / pivotRight) 高値や安値を「スイングの山・谷」として判定する時に使う幅です。
例えば pivotLeft=3, pivotRight=3 の場合、「左に3本、右に3本のローソク足より高い/低い点」をスイングの頂点や底と見なします。
数値を大きくすると大きな波だけを拾い、小さくすると小さな波も拾いやすくなります。
ATR期間 (atrLen) トレールライン計算用ATRの期間
ATR倍率 (atrMult) トレールラインの距離をATRに掛ける倍率
半分利確倍率 (tpMult) 押し目/戻り幅に対して半分利確ラインを設定する倍率

緑の線(Long Trail / 半透明緑)
ATRベースのトレールストップラインです。
買いポジション中の損切り目安やトレーリングストップとして使います。
緑の濃い線は半分利確ライン(TP)、薄い緑の線はトレールストップの位置を示します。
赤い線(Short Trail / 半透明赤)
ATRベースのトレールストップラインです。
売りポジション中の損切り目安やトレーリングストップとして使います。
赤の濃い線は半分利確ライン(TP)、薄い赤の線はトレールストップの位置を示します。
補足:TP(Take Profit)線は半分利確の目安で、ATRトレールラインはポジションが逆行した時の損切り目安です。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。