Fix hardcoded SOL symbol in Pine Script alerts
- Use syminfo.ticker to dynamically get symbol name - Strip USD/USDT/PERP suffixes to get base currency - Works for ETH, SOL, BTC, and any other symbol - Alerts now correctly show 'ETH buy' for Ethereum, 'BTC buy' for Bitcoin, etc. This fixes the bug where ETH triggers sent 'SOL buy' alerts.
This commit is contained in:
@@ -187,10 +187,15 @@ lowest20 = ta.lowest(calcL, 20)
|
||||
priceRange = highest20 - lowest20
|
||||
pricePosition = priceRange == 0 ? 50.0 : ((calcC - lowest20) / priceRange) * 100
|
||||
|
||||
// Build enhanced alert messages with context
|
||||
longAlertMsg = "SOL buy .P " + str.tostring(timeframe.period) + " | ATR:" + str.tostring(atrPercent, "#.##") + " | ADX:" + str.tostring(adxVal, "#.#") + " | RSI:" + str.tostring(rsi14, "#.#") + " | VOL:" + str.tostring(volumeRatio, "#.##") + " | POS:" + str.tostring(pricePosition, "#.#")
|
||||
// Extract base currency from ticker (e.g., "ETHUSD" -> "ETH", "SOLUSD" -> "SOL")
|
||||
baseCurrency = str.replace(syminfo.ticker, "USD", "")
|
||||
baseCurrency := str.replace(baseCurrency, "USDT", "")
|
||||
baseCurrency := str.replace(baseCurrency, "PERP", "")
|
||||
|
||||
shortAlertMsg = "SOL sell .P " + str.tostring(timeframe.period) + " | ATR:" + str.tostring(atrPercent, "#.##") + " | ADX:" + str.tostring(adxVal, "#.#") + " | RSI:" + str.tostring(rsi14, "#.#") + " | VOL:" + str.tostring(volumeRatio, "#.##") + " | POS:" + str.tostring(pricePosition, "#.#")
|
||||
// Build enhanced alert messages with context
|
||||
longAlertMsg = baseCurrency + " buy .P " + str.tostring(timeframe.period) + " | ATR:" + str.tostring(atrPercent, "#.##") + " | ADX:" + str.tostring(adxVal, "#.#") + " | RSI:" + str.tostring(rsi14, "#.#") + " | VOL:" + str.tostring(volumeRatio, "#.##") + " | POS:" + str.tostring(pricePosition, "#.#")
|
||||
|
||||
shortAlertMsg = baseCurrency + " sell .P " + str.tostring(timeframe.period) + " | ATR:" + str.tostring(atrPercent, "#.##") + " | ADX:" + str.tostring(adxVal, "#.#") + " | RSI:" + str.tostring(rsi14, "#.#") + " | VOL:" + str.tostring(volumeRatio, "#.##") + " | POS:" + str.tostring(pricePosition, "#.#")
|
||||
|
||||
// Fire alerts with dynamic messages (use alert() not alertcondition() for dynamic content)
|
||||
if finalLongSignal
|
||||
|
||||
Reference in New Issue
Block a user