// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator("Börsenampel", shorttitle = 'Börsenampel v2', overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_polylines_count = 100, max_bars_back = 5000) // Einstellbare Parameter sym_ma_length = input.int(21, minval=1, title="Tages-Länge des gleitenden Durchschnitts (Preis)") spx_ma_length = input.int(50, minval=1, title="Tages-Länge des gleitenden Durchschnitts (SPX)") // Colors color NONE = color(na) color LIME = color.green color LIME_LT = color.new(LIME, 75) color MAROON = color.maroon color MAROON_LT = color.new(MAROON, 60) color YELLOW = color.yellow color YELLOW_LT = color.new(YELLOW, 80) // Tagesdaten unabhängig der angezeigten Zeiteinheit lesen (Achtung bei Woche / Monat falsche Anzeige) price_day = request.security(syminfo.tickerid, "D", close) volume_day = request.security(syminfo.tickerid, "D", volume) volume_day_ixic = request.security("TVOLQ", "D", close) volume_day_nya = request.security("TVOL", "D", close) spx_day = request.security("SP:SPX", "D", close) // Berechnung der gleitenden Durchschnitte price_sma = ta.sma(price_day, sym_ma_length) spx_sma = ta.sma(spx_day, spx_ma_length) // Preise und Preisänderung price_today = price_day[0] price_yesterday = price_day[1] price_change = (price_today - price_yesterday) / price_yesterday * 100 spx_today = spx_day[0] spx_yesterday = spx_day[1] // Berechnung des Volumens volume_today = volume_day[0] volume_yesterday = volume_day[1] if ticker.standard() == "TVC:IXIC" or ticker.standard() == "NASDAQ_DLY:IXIC" volume_today := volume_day_ixic[0] volume_yesterday := volume_day_ixic[1] if ticker.standard() == "TVC:NYA" or ticker.standard() == "NYSE:NYA" volume_today := volume_day_nya[0] volume_yesterday := volume_day_nya[1] // Logik für die Hintergrundfarbe isPriceBelowMA = price_today < price_sma isSPXBelowMA = spx_today < spx_sma isPriceFalling = price_change <= -0.5 bgcolor(isSPXBelowMA ? MAROON_LT : (isPriceBelowMA and isPriceFalling ? YELLOW_LT : na)) // "Follow Through Day"-Signal isFollowThroughDay = price_change > 1.25 and volume_today > volume_yesterday plotshape(series = isFollowThroughDay, location = location.belowbar, color = LIME, style = shape.triangledown, text = "FTD", textcolor = LIME) // "Distribution Day"-Signal isDistributionDay = price_change < -0.2 and volume_today > volume_yesterday plotshape(series = isDistributionDay, location = location.abovebar, color = MAROON, style = shape.triangledown, text = "DD", textcolor = MAROON)