OPEN-SOURCE SCRIPT
Gold Swings Peaks & Troughs

//version=5
indicator("Gold Swings Peaks & Troughs CLEAN", overlay=true, max_labels_count=500)
// ===== إعدادات المستخدم =====
len = input.int(2, "Swing Length") // عدد الشموع قبل وبعد لتحديد القمة/القاع
minDistance = input.int(5, "Min Bars Between Signals") // لتقليل الإشارات المتقاربة
buyColor = input.color(color.green, "BUY Color")
sellColor = input.color(color.red, "SELL Color")
// ===== متغير لتخزين آخر إشارة =====
var int lastBuyBar = na
var int lastSellBar = na
// ===== قمة و قاع محلية =====
localLow = low == ta.lowest(low, len*2 + 1)
localHigh = high == ta.highest(high, len*2 + 1)
// ===== رسم Labels فقط عند القمم والقيعان مع منع التكرار القريب =====
if localLow and (na(lastBuyBar) or bar_index - lastBuyBar >= minDistance)
label.new(bar_index, low, "BUY", style=label.style_label_up, color=buyColor, textcolor=color.white)
lastBuyBar := bar_index
if localHigh and (na(lastSellBar) or bar_index - lastSellBar >= minDistance)
label.new(bar_index, high, "SELL", style=label.style_label_down, color=sellColor, textcolor=color.white)
lastSellBar := bar_index
indicator("Gold Swings Peaks & Troughs CLEAN", overlay=true, max_labels_count=500)
// ===== إعدادات المستخدم =====
len = input.int(2, "Swing Length") // عدد الشموع قبل وبعد لتحديد القمة/القاع
minDistance = input.int(5, "Min Bars Between Signals") // لتقليل الإشارات المتقاربة
buyColor = input.color(color.green, "BUY Color")
sellColor = input.color(color.red, "SELL Color")
// ===== متغير لتخزين آخر إشارة =====
var int lastBuyBar = na
var int lastSellBar = na
// ===== قمة و قاع محلية =====
localLow = low == ta.lowest(low, len*2 + 1)
localHigh = high == ta.highest(high, len*2 + 1)
// ===== رسم Labels فقط عند القمم والقيعان مع منع التكرار القريب =====
if localLow and (na(lastBuyBar) or bar_index - lastBuyBar >= minDistance)
label.new(bar_index, low, "BUY", style=label.style_label_up, color=buyColor, textcolor=color.white)
lastBuyBar := bar_index
if localHigh and (na(lastSellBar) or bar_index - lastSellBar >= minDistance)
label.new(bar_index, high, "SELL", style=label.style_label_down, color=sellColor, textcolor=color.white)
lastSellBar := bar_index
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。