OPEN-SOURCE SCRIPT

Consecutive Candles Strategy

Entry Conditions:
Long Entry:
Requires two consecutive green candles (where close > open)
The second green candle must be a strong candle (not a doji)
A strong candle is defined by its body being at least 50% of its total range (adjustable via minBodyToShadowRatio)
Short Entry:
Requires two consecutive red candles (where close < open)
The second red candle must be a strong candle (not a doji)
Same body-to-shadow ratio requirement as long entries
Exit Conditions:
All positions (both long and short) are automatically closed at the next candle's close
For example:
If you enter a long position on candle #1
The position will be closed at the end of candle #2
Trade Management:
Cooldown Period:
After each trade exits, there's a 2-candle waiting period
No new trades can be entered during this cooldown
This helps avoid overtrading and gives the market time to settle
Candle Strength Measurement:
bodySize = math.abs(close - open): Measures the actual body size of the candle
totalRange = high - low: Measures the total range including shadows
bodyToShadowRatio = bodySize / totalRange: Calculates what portion of the candle is body
A candle is considered "strong" if its body is at least 50% of its total range
Visual Indicators:
Green triangles below bars: Show long entry signals
Red triangles above bars: Show short entry signals
Yellow dots: Show the cooldown period countdown
Blue dots: Show the body-to-shadow ratio of current candle
Example Trade Sequence:

Market shows two green candles, second one is strong
Strategy enters a long position
Position is closed at the end of the next candle
Strategy waits for 2 candles (cooldown)
Only then looks for new trade opportunities
You can adjust the strategy's sensitivity by modifying:

minBodyToShadowRatio: Higher values (closer to 1.0) require stronger candles
Currently set to 0.5 (50%), meaning the candle body must be at least half of the total candle range
Candlestick analysisChart patterns

Skrip open-source

Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Inggin menggunakan skrip ini pada chart?

Pernyataan Penyangkalan