OPEN-SOURCE SCRIPT

Candle Color Confirmation Strategy

89
// TradingView (Pine Script v5) Strategy
//version=5
strategy("Candle Color Confirmation Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Input: Time confirmation in seconds
confirmTime = input(5, title="Seconds to Confirm")

// Track the candle open and its color consistency
var float openPrice = na
var bool isConfirmed = false
var bool isBullish = false
var int startTime = na

if bar_index != bar_index[1] // New candle
openPrice := open
isConfirmed := false
startTime := timenow

if not isConfirmed and (timenow - startTime) >= confirmTime * 1000
if close > openPrice and high == close // Green candle stays green
isBullish := true
strategy.entry("Buy", strategy.long)
isConfirmed := true
else if close < openPrice and low == close // Red candle stays red
isBullish := false
strategy.entry("Sell", strategy.short)
isConfirmed := true

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.