//@version=5
indicator("Head and Shoulders", overlay=true)
// Fungsi untuk mendeteksi pola "Head and Shoulders"
headShoulders(high, low) =>
// Cari titik tertinggi dan terendah
headHigh = high
leftShoulderLow = low
rightShoulderLow = low
// Cari titik tengah
neckline = (leftShoulderLow + rightShoulderLow) / 2
// Validasi pola "Head and Shoulders"
isHead = high > high and high > high
isLeftShoulder = low < low and low < low
isRightShoulder = low < low and low < low
isNeckline = low == low
return isHead and isLeftShoulder and isRightShoulder and isNeckline
// Input dari pengguna
head_idx = input(25, "Head Index")
left_shoulder_idx = input(10, "Left Shoulder Index")
right_shoulder_idx = input(30, "Right Shoulder Index")
// Hitung titik tengah
left_neckline_idx = (head_idx + left_shoulder_idx) / 2
right_neckline_idx = (head_idx + right_shoulder_idx) / 2
// Deteksi pola "Head and Shoulders"
isHeadShoulders = headShoulders(high, low)
// Tampilkan panah di chart jika pola terdeteksi
plotshape(isHeadShoulders, style=shape.arrowup, location=location.belowbar, color=color.green, size=size.small)
indicator("Head and Shoulders", overlay=true)
// Fungsi untuk mendeteksi pola "Head and Shoulders"
headShoulders(high, low) =>
// Cari titik tertinggi dan terendah
headHigh = high
leftShoulderLow = low
rightShoulderLow = low
// Cari titik tengah
neckline = (leftShoulderLow + rightShoulderLow) / 2
// Validasi pola "Head and Shoulders"
isHead = high > high and high > high
isLeftShoulder = low < low and low < low
isRightShoulder = low < low and low < low
isNeckline = low == low
return isHead and isLeftShoulder and isRightShoulder and isNeckline
// Input dari pengguna
head_idx = input(25, "Head Index")
left_shoulder_idx = input(10, "Left Shoulder Index")
right_shoulder_idx = input(30, "Right Shoulder Index")
// Hitung titik tengah
left_neckline_idx = (head_idx + left_shoulder_idx) / 2
right_neckline_idx = (head_idx + right_shoulder_idx) / 2
// Deteksi pola "Head and Shoulders"
isHeadShoulders = headShoulders(high, low)
// Tampilkan panah di chart jika pola terdeteksi
plotshape(isHeadShoulders, style=shape.arrowup, location=location.belowbar, color=color.green, size=size.small)