OPEN-SOURCE SCRIPT

Candle Color Confirmation Strategy

88
// 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

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.