OPEN-SOURCE SCRIPT

Arpoom

165
//version=5
indicator("Volume & Body Spike Multiplier", overlay=true)

// 1. คำนวณค่าเฉลี่ย 20 แท่ง
avgVol = ta.sma(volume, 20)
currentBody = math.abs(close - open) // ใช้ math.abs เพื่อให้ค่าเป็นบวกเสมอ
avgBody = ta.sma(currentBody, 20)

// 2. คำนวณ Multipliers
volMultiplier = volume / avgVol
bodyMultiplier = currentBody / avgBody

// 3. กำหนดเงื่อนไข
// วอลุ่มมากกว่า 2 เท่า และ เนื้อเทียนยาวกว่าค่าเฉลี่ยเนื้อเทียน 20 แท่ง
volCondition = volume > (avgVol * 2)
bodyCondition = currentBody > avgBody

longCondition = volCondition and bodyCondition and close > open
shortCondition = volCondition and bodyCondition and close <= open

// 4. วาดลูกศร
plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Long Body Spike")
plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Short Body Spike")

// 5. แสดงตัวเลขบน Label (V = Volume x, B = Body x)
if longCondition
label.new(bar_index, low, str.format("V: {0,number,#.#}x\nB: {1,number,#.#}x", volMultiplier, bodyMultiplier), yloc=yloc.belowbar, color=color.new(color.green, 20), textcolor=color.white, style=label.style_label_up, size=size.small)

if shortCondition
label.new(bar_index, high, str.format("V: {0,number,#.#}x\nB: {1,number,#.#}x", volMultiplier, bodyMultiplier), yloc=yloc.abovebar, color=color.new(color.red, 20), textcolor=color.white, style=label.style_label_down, size=size.small)

// 6. ระบบแจ้งเตือน (Alerts)
alertcondition(longCondition, title="Buy Spike (Vol & Body)", message="Body Spike Up! Vol: {{plot_0}}x, Body: {{plot_1}}x")
alertcondition(shortCondition, title="Sell Spike (Vol & Body)", message="Body Spike Down! Vol: {{plot_0}}x, Body: {{plot_1}}x")

// ส่งค่าออกเพื่อให้ Alert ดึงไปใช้
plot(volMultiplier, "Vol Mult", display=display.none)
plot(bodyMultiplier, "Body Mult", display=display.none)

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.