PulseHub
OPEN-SOURCE SCRIPT

MA ribbon NMF

838
MA ribbon plots four moving averages and fills two separate ribbons between them, so short-term and long-term trend structure can be read at the same time. The fast moving average is coloured by its own slope in three states, using a tick-normalised tolerance band for "flat".

--- WHAT IT DOES ---

Two nested ribbons are drawn:

- Fast ribbon: MA1 (default 20) and MA2 (default 40 SMA). Filled pink when MA1 is above MA2, light blue when below. Drawn at low transparency so it reads as the active layer.
- Slow ribbon: MA3 (default 75 EMA) and MA4 (default 200 SMA). Filled translucent yellow when MA3 is above MA4, translucent green when below. Drawn at high transparency so it reads as background context.

The opacity difference is intentional: the slow ribbon is meant to be seen as regime context behind price, not as a competing signal.

--- THREE-STATE SLOPE COLOURING ---

MA1 is not coloured by its position relative to other averages, but by its own bar-to-bar slope, in three states:

- Rising (default red)
- Falling (default blue)
- Treated as flat (default yellow)

"Flat" is not an exact-equality test. MA1 is treated as flat when the absolute bar-to-bar change is within a threshold of (input value x syminfo.mintick x 10). Because the threshold is expressed in ticks rather than in price units, the same input value behaves consistently across symbols with different price scales: 0.3 means the same thing on a 3-decimal FX pair as on a 5-decimal one. The default of 0.3 corresponds to 3 ticks of change per bar; 1.0 corresponds to 10 ticks.

The reason for the tolerance band is that a moving average almost never has an exactly zero slope. Without it, a ranging market produces rapid alternation between the rising and falling colours, which reads as noise. The flat state isolates periods where MA1 has no meaningful direction.

Default colours follow the Japanese charting convention (red = up, blue = down) rather than the Western one. Every colour is an input and can be changed.

--- BAR-CLOSE EVALUATION ---

All averages are computed from (barstate.isconfirmed ? close : close[1]). The lines therefore do not move while the current bar is forming, and advance only when a bar closes. This is deliberate: it removes intrabar flicker in the slope colour, which would otherwise change several times within a single bar.

--- HOW TO USE ---

Read the slow ribbon first to establish the prevailing regime, then use the fast ribbon and the MA1 slope colour for timing within that regime. A fast-ribbon flip in the same direction as the slow ribbon is the aligned case. A flip against it is either a pullback or an early regime change, and the two are not distinguishable in advance.

--- LIMITATIONS AND CAUTIONS ---

- Because of the bar-close evaluation described above, the line drawn on the currently forming bar reflects data up to the previous close. On the live bar the values are effectively one bar behind. Historical bars are not affected.
- This is a moving average tool. Like all moving averages it lags, and it will whipsaw in ranging markets. The flat state reduces visual noise but does not remove the underlying lag.
- No signals, alerts, or backtest results are included, and none are implied. This is a visualisation aid, not a trading system.
- Plot names in the Data Window are fixed labels ("20 MA", "40 SMA", "75 EMA", "200 SMA") and do not change if you edit the period inputs.

--- SETTINGS (the input UI is in Japanese; English translations below) ---

Group "MA 1":
期間 = Length
上昇 = Colour when MA1 is rising
下降 = Colour when MA1 is falling
見なし平行 = Colour when MA1 is treated as flat
太さ = Line width
MA種類 = MA type (SMA / WMA / HMA)
見なし平行閾値 = Flat threshold (1.0 = 10 ticks)

Groups "MA 2", "MA 3", "MA 4":
期間 = Length
色 = Colour
太さ = Line width

Group "MA 1/MA 2 リボン" = Fast ribbon
Group "MA 3/MA 4 リボン" = Slow ribbon
上昇 = Fill colour when the faster average is above
下降 = Fill colour when the faster average is below

MA1 type is selectable (SMA / WMA / HMA). MA2 is SMA, MA3 is EMA, MA4 is SMA; these three are fixed.

============================================================

MA ribbon は4本の移動平均線を描画し、その間に2つのリボンを塗り分けることで、短期と長期のトレンド構造を同時に読み取れるようにするインジケーターです。短期MAは位置ではなく「自身の傾き」で3状態に色分けされ、平行判定にはtick単位で正規化した許容幅を使います。

■ 描画内容

- 短期リボン:MA1(初期値20)とMA2(初期値40 SMA)。MA1が上ならピンク、下なら水色。低透明度で描画し、主レイヤーとして扱います。
- 長期リボン:MA3(初期値75 EMA)とMA4(初期値200 SMA)。MA3が上なら薄い黄色、下なら薄い緑。高透明度で描画し、背景のレジーム情報として扱います。

透明度の差は意図的なものです。長期リボンは価格の背後にある地合いとして見えるべきで、短期リボンと競合するシグナルであってはならないためです。

■ 3状態の傾き色分け

MA1は他の平均線との位置関係ではなく、自身の1本前との差分(傾き)で色を切り替えます。

- 上昇(初期値:赤)
- 下降(初期値:青)
- 見なし平行(初期値:黄)

「平行」は完全一致の判定ではありません。MA1の1本あたりの変化量の絶対値が「入力値 × syminfo.mintick × 10」以内のとき、平行とみなします。閾値を価格単位ではなくtick単位で表現しているため、価格スケールの異なる銘柄でも同じ入力値が同じ意味を持ちます。小数3桁の通貨ペアでも5桁の通貨ペアでも 0.3 は同じ挙動になります。初期値 0.3 は1本あたり3tickの変化に相当し、1.0 なら10tickです。

許容幅を設けている理由は、移動平均の傾きが厳密にゼロになることはほぼないためです。許容幅がないとレンジ相場で上昇色と下降色が高速に入れ替わり、ノイズとしてしか読めなくなります。平行状態を分離することで、MA1に有意な方向がない局面を切り出しています。

初期配色は欧米式ではなく日本式(赤=上昇、青=下降)に従っています。全ての色は入力項目として変更可能です。

■ 確定足での評価

全ての移動平均は (barstate.isconfirmed ? close : close[1]) を入力として計算しています。そのため形成中の足の間はラインが動かず、足が確定したときにのみ更新されます。これは意図的な設計で、足の中で傾き色が何度も切り替わるチラつきを排除するためです。

■ 使い方

まず長期リボンで地合いを確認し、その地合いの中で短期リボンとMA1の傾き色をタイミングの判断に使います。長期リボンと同じ方向への短期リボンの反転が順張り局面です。逆方向への反転は押し目・戻り目である場合とレジーム転換の初動である場合があり、事前に区別することはできません。

■ 制約と注意点

- 上記の確定足評価のため、形成中の足に描画されるラインは1本前の終値までのデータを反映しています。リアルタイム足では実質1本遅れになります。過去の足には影響ありません。
- 本インジケーターは移動平均ツールです。全ての移動平均と同様に遅行性があり、レンジ相場ではダマシが発生します。平行状態は視覚的なノイズを減らしますが、遅行性そのものを解消するものではありません。
- シグナル・アラート・バックテスト結果は一切含んでおらず、それらを示唆するものでもありません。これは可視化の補助ツールであり、売買システムではありません。
- データウィンドウ上のプロット名は固定ラベル("20 MA" 等)であり、期間の入力値を変更しても変わりません。

■ 設定項目

入力UIは日本語表記です。英訳は上記英語セクションの SETTINGS を参照してください。MA1のみ種類を選択でき(SMA / WMA / HMA)、MA2はSMA、MA3はEMA、MA4はSMAで固定です。

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.