Poc_candle

Poc_candle

//@version=5
indicator("POC-Candle - EMA -ATR - Long Shadow - 50per Candle", overlay=true)
//Dev by : @mk8813
//
// --------------------------
// General Settings
// --------------------------
res = input.timeframe(title="Resolution", defval="60", group="General Settings")

// --------------------------
// EMA Settings
// --------------------------
enableEMA = input.bool(true, title="Enable EMA", group="EMA Settings")
emaLength = input.int(200, title="EMA Length", group="EMA Settings")

// --------------------------
// Donchian Channel Settings
// --------------------------
enableDonchian = input.bool(true, title="Enable Donchian Channel", group="Donchian Settings")
donchianLength = input.int(13, title="Donchian Channel Length", group="Donchian Settings")
enableDonchianLines = input.bool(true, title="Enable Donchian Lines", group="Donchian Settings")

// --------------------------
// High Volume Candle Settings
// --------------------------
enableHighVolume = input.bool(true, title="Enable High Volume Candle", group="High Volume Candle Settings")
hvLength = input.int(10, title="Period Length", group="High Volume Candle Settings")

// --------------------------
// POC Settings
// --------------------------
enablePOC = input.bool(true, title="Enable POC", group="POC Settings")

// --------------------------
// ATR Settings
// --------------------------
enableATR = input.bool(true, title="Enable ATR", group="ATR Settings")
atr_length = input.int(title="ATR Length", defval=14, minval=1, group="ATR Settings")
smoothing = input.string(title="Smoothing", defval="RMA", options= , group="ATR Settings")
candle_ATR_ratio = input.float(2, title="Candle ATR Ratio", group="ATR Settings")

// --------------------------
// Long Shadow Settings
// --------------------------
enableLongShadow = input.bool(true, title="Enable Long Shadow", group="Long Shadow Settings")
pipThreshold = input.int(title="Shadow Threshold (Points)", defval=380, group="Long Shadow Settings")

// --------------------------
// White 50-Candle Settings (50-per body)
// --------------------------
enableWhiteShadow = input.bool(true, title="Enable 50-Percent body Candle", group="50-per Candle Settings")

// --------------------------
// Data Input (for current symbol)
// --------------------------
my_close = request.security(syminfo.tickerid, res, close)
my_open = request.security(syminfo.tickerid, res, open)
my_low = request.security(syminfo.tickerid, res, low)
my_high = request.security(syminfo.tickerid, res, high)
my_volume = request.security(syminfo.tickerid, res, volume)
my_atr = request.security(syminfo.tickerid, res, ta.atr(atr_length))

// --------------------------
// Long Shadow Calculation (Using shadow threshold input)
// --------------------------
// ورودی آستانه سایه (به پیپ)


// تشخیص اینکه آیا نماد جاری مربوط به طلا (XAU) است یا خیر
isGold = str.contains(syminfo.tickerid, "XAU")

// اگر نماد مربوط به طلا باشد، pipSize را 0.01 در نظر می‌گیریم، در غیر این صورت از syminfo.mintick استفاده می‌شود
pipsize = isGold ? 0.01 : syminfo.mintick

// تبدیل آستانه پیپ به مقدار واقعی قیمت
shadowThreshold = pipThreshold * pipsize

// محاسبه سایه‌های بالایی و پایینی کندل
upperShadow = high - math.max(open, close)
lowerShadow = math.min(open, close) - low

// بررسی اینکه آیا سایه‌ها از آستانه تعیین شده بزرگتر هستند
isLongUpperShadow = upperShadow >= shadowThreshold
isLongLowerShadow = lowerShadow >= shadowThreshold

// رسم علامت‌ها بر اساس نتیجه
plotshape(isLongUpperShadow, title="Long Upper Shadow", style=shape.circle, location=location.abovebar, color=color.purple, size=size.tiny)
plotshape(isLongLowerShadow, title="Long Lower Shadow", style=shape.circle, location=location.belowbar, color=color.purple, size=size.tiny)
// --------------------------
// EMA Calculation
// --------------------------
emaValue = ta.ema(my_close, emaLength)
plot(enableEMA ? emaValue : na, title="EMA", color=color.red, linewidth=2)

// --------------------------
// Donchian Channel Calculation
// --------------------------
donchianHigh = ta.highest(my_high, donchianLength)
donchianLow = ta.lowest(my_low, donchianLength)
donchianMid = (donchianHigh + donchianLow) / 2
plot(enableDonchian and enableDonchianLines ? donchianHigh : na, title="Donchian High", color=color.blue, linewidth=2)
plot(enableDonchian and enableDonchianLines ? donchianLow : na, title="Donchian Low", color=color.blue, linewidth=2)
plot(enableDonchian ? donchianMid : na, title="Donchian Mid", color=color.gray, linewidth=2)

// --------------------------
// ATR Calculation (using my_* data)
// --------------------------
trueChange = math.abs(my_close - my_open)
true_range_condition = trueChange >= candle_ATR_ratio * my_atr
barcolor(enableATR and true_range_condition ? color.blue : na)
plotcandle(enableATR and true_range_condition ? my_open : na, my_high, my_low, my_close, color=color.yellow)

// --------------------------
// 50-per Candle Calculation
// --------------------------
candleRange = my_high - my_low
upperShadowCalc = my_high - math.max(my_open, my_close)
lowerShadowCalc = math.min(my_open, my_close) - my_low
totalShadow = upperShadowCalc + lowerShadowCalc
whiteCandleCondition = candleRange > 0 and (totalShadow >= 0.5 * candleRange)
finalBarColor = enableWhiteShadow and whiteCandleCondition ? color.white : (enableATR and true_range_condition ? color.blue : na)
barcolor(finalBarColor)

// --------------------------
// High Volume Candle Calculation
// --------------------------
highestVolume = ta.highest(my_volume, hvLength)
isHighestVolume = my_volume == highestVolume
isGreenCandle = my_close > my_open
isRedCandle = my_close < my_open
longcondition = isHighestVolume and isGreenCandle
shortcondition = isHighestVolume and isRedCandle
plotshape(enableHighVolume and isHighestVolume and isGreenCandle, title="Highest Volume Green", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(enableHighVolume and isHighestVolume and isRedCandle, title="Highest Volume Red", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
alertcondition(enableHighVolume and longcondition, title="Long High Volume", message="Long High Volume")
alertcondition(enableHighVolume and shortcondition, title="Short High Volume", message="Short High Volume")
alertcondition(enableHighVolume and (longcondition or shortcondition), title="Short or Long High Volume", message="Short or Long High Volume")

// --------------------------
// POC Calculation (Typical Price using my_* data)
// --------------------------
pocPrice = (my_high + my_low + my_close) / 3
plotshape(enablePOC ? pocPrice : na, title="POC", location=location.absolute, color=color.yellow, style=shape.square, size=size.tiny)

Read More

Share:

Latest News