OPEN-SOURCE SCRIPT
Telah dikemas kini

H4 3-Candle Pattern (Persistent Signals)

198
Below is an example in Pine Script v5 that detects a pattern using the last three completed 4H candles and then plots a permanent arrow on the fourth candle (i.e. on the current bar) when the conditions are met. The arrow stays on that bar even after new bars form.

In this version, the pattern is evaluated as follows on each bar (when there are enough candles):

Bullish Pattern:

The candle three bars ago (oldest of the three) is bullish (its close is greater than its open).

The candle two bars ago closes above the high of that older candle.

The last completed candle (one bar ago) closes at or above the low of the candle two bars ago.

Bearish Pattern:

The candle three bars ago is bearish (its close is less than its open).

The candle two bars ago closes below the low of that older candle.

The last completed candle closes at or below the high of the candle two bars ago.

When the conditions are met the script draws a green up arrow below the current (fourth) candle for a bullish pattern and a red down arrow above the current candle for a bearish pattern. These arrows are drawn as regular plot symbols and remain on the chart permanently.

Copy and paste the code into TradingView’s Pine Script Editor:
Nota Keluaran
Below is the modified final version in Pine Script v6. In this version, we add one more check for each scenario:

For the Bullish Pattern:
The third candle (most recent completed candle, index 1) must be red (its close is lower than its open).

For the Bearish Pattern:
The third candle must be green (its close is higher than its open).

The signal arrow is plotted on the current (4th) candle when all conditions are met.

pinescript
Copy
Edit

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.