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

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ