Files
Croc_Vibes/indicators/croc_vibes.pine
2025-09-16 21:26:11 +02:00

462 lines
22 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// =================================================================================================
// Croc Vibes by Telgos Version 4.2.2
// Lizenz: Mozilla Public License 2.0 https://mozilla.org/MPL/2.0/
// Danksagung (Basis/Ideen): amper04, ray_duke, husky, Audidriver13
// =================================================================================================
//@version=6
indicator("Croc Vibes by Telgos v4.2.2", overlay=true, max_labels_count=500, max_lines_count=500)
// ========= Eingaben: Chart-Signale =========
wolke_Line_pink = input.source(title="Wolke Linie Pink", defval=close, group="Chart-Signale")
cloud_punkt_long = input.source(title="Cloud Punkt Long", defval=close, group="Chart-Signale")
red_devil_long = input.source(title="Red Devil Long", defval=close, group="Chart-Signale")
hellgruener_punkt_long = input.source(title="Hellgruener Punkt Long", defval=close, group="Chart-Signale")
blauer_punkt_long = input.source(title="Blauer Punkt Long", defval=close, group="Chart-Signale")
gruenes_plus = input.source(title="Grünes Plus", defval=close, group="Chart-Signale")
bb_kombi_long = input.source(title="BB Kombi long", defval=close, group="Chart-Signale")
rotes_plus = input.source(title="Rotes Plus", defval=close, group="Chart-Signale")
blauer_punkt_short = input.source(title="Blauer Punkt Short", defval=close, group="Chart-Signale")
lollipop_long = input.source(title="Lollipop long", defval=close, group="Chart-Signale")
aw_rocket_long = input.source(title="AW-Rocket long", defval=close, group="Chart-Signale")
bgrl_signal = input.source(title="Black Green Rocket Long", defval=close, group="Chart-Signale")
// ========= Eingaben: Lochstreifen / MSI =========
kerze_g = input.source(title="Kerzenfarbe (1) Gruen", defval=close, group="Lochstreifen")
kerze_s = input.source(title="Kerzenfarbe (2) Schwarz", defval=close, group="Lochstreifen")
kerze_r = input.source(title="Kerzenfarbe (3) Rot", defval=close, group="Lochstreifen")
status_r = input.source(title="Status (2) Rot", defval=close, group="Lochstreifen")
status_g = input.source(title="Status (3) Grün", defval=close, group="Lochstreifen")
wolke_g = input.source(title="Wolke (1) Grün", defval=close, group="Lochstreifen")
wolke_r = input.source(title="Wolke (3) Rot", defval=close, group="Lochstreifen")
trend_s = input.source(title="Trend (1) Schwarz", defval=close, group="Lochstreifen")
trend_r = input.source(title="Trend (2) Rot", defval=close, group="Lochstreifen")
trend_g = input.source(title="Trend (3) Grün", defval=close, group="Lochstreifen")
setter_r = input.source(title="Setter (Trend 5) Rot", defval=close, group="Lochstreifen")
setter_g = input.source(title="Setter (Trend 6) grün", defval=close, group="Lochstreifen")
welle_g = input.source(title="Welle (1) grün", defval=close, group="Lochstreifen")
welle_gg = input.source(title="Welle (2) dunkelgrün", defval=close, group="Lochstreifen")
welle_r = input.source(title="Welle (4) Rot", defval=close, group="Lochstreifen")
welle_rr = input.source(title="Welle (6) dunkelRot", defval=close, group="Lochstreifen")
src1 = input.source(close, "Day OverBought 1", group="MSI")
// ========= Darstellung =========
label_offset_mult = input.float(1.5, title="Label-Abstand (ATR x)", minval=0.1, step=0.1, group="Darstellung")
show_price_textbox = input.bool(true, "Preis-Textboxen an Blues-Level anzeigen", group="Darstellung")
show_blues_lines = input.bool(true, "Blaue Pending-Linien im Chart anzeigen", group="Darstellung")
show_ps_wolke = input.bool(true, "Wolke Linie Pink auf Preisskala", group="Darstellung")
show_ps_bluel = input.bool(true, "Blues Long-Level auf Preisskala (nur aktiv)", group="Darstellung")
show_ps_blues = input.bool(true, "Blues Short-Level auf Preisskala (nur aktiv)", group="Darstellung")
col_ps_wolke = input.color(color.new(color.fuchsia, 0), "Farbe: Wolke Pink", group="Darstellung")
col_ps_bluel = input.color(color.new(color.blue, 0), "Farbe: Blues Long", group="Darstellung")
col_ps_blues = input.color(color.new(color.blue, 0), "Farbe: Blues Short", group="Darstellung")
// ========= Helper =========
asBool(src) => nz(src) > 0
atr = ta.atr(16)
b_long = asBool(blauer_punkt_long)
b_short = asBool(blauer_punkt_short)
hgr_long = asBool(hellgruener_punkt_long)
cp_long = asBool(cloud_punkt_long)
rd_long = asBool(red_devil_long)
bb_long = asBool(bb_kombi_long)
lolli_long = asBool(lollipop_long)
awr_long = asBool(aw_rocket_long)
bgrl = asBool(bgrl_signal)
r_plus = asBool(rotes_plus)
g_plus = asBool(gruenes_plus)
st_g = asBool(status_g)
st_r = asBool(status_r)
wk_g = asBool(wolke_g)
wk_r = asBool(wolke_r)
tr_s = asBool(trend_s)
tr_r = asBool(trend_r)
tr_g = asBool(trend_g)
set_r = asBool(setter_r)
set_g = asBool(setter_g)
wl_g = asBool(welle_g)
wl_gg = asBool(welle_gg)
wl_r = asBool(welle_r)
wl_rr = asBool(welle_rr)
cz_g = asBool(kerze_g)
cz_s = asBool(kerze_s)
cz_r = asBool(kerze_r)
baerische_welle = wl_rr or wl_r
bullische_welle = wl_gg or wl_g
// ========= Kernsignale =========
allRed = st_r and cz_r and wk_r and tr_r and set_r and baerische_welle
kerzeSG_l = st_r and (cz_s or cz_g) and wk_r and tr_r and set_r and baerische_welle
isPearlLong = kerzeSG_l and allRed[1] and allRed[2]
allGreen = st_g and cz_g and wk_g and tr_g and set_g and bullische_welle
kerzeSG_s = st_g and (cz_s or cz_r) and wk_g and tr_g and set_g and bullische_welle
isPearlShort = kerzeSG_s and allGreen[1] and allGreen[2]
// --- NEU: „Rotes Plus“ (r_plus) als Zusatzbedingung aufgenommen ---
stephan_zusatzbedingung_erfuellt = cp_long or rd_long or lolli_long or bb_long or awr_long or bgrl or g_plus or r_plus
stephan_setup = not na(src1) and wk_g and tr_s and set_r and stephan_zusatzbedingung_erfuellt
Kerze_in_wolke_gr = close - wolke_Line_pink
ulti_rally = hgr_long and (Kerze_in_wolke_gr > 0) and st_r and cz_r and set_r and not baerische_welle
is_bgrl = bgrl
is_rotes_plus = r_plus and wk_g
// ========= Blues-Zonenpflege =========
g_active = wk_g
r_active = wk_r
f_rise(sig) =>
cond_now = (not na(sig)) and (sig > 0)
cond_prev = na(sig[1]) or (sig[1] <= 0)
cond_now and cond_prev
var int g_zoneStart = na
var float g_zoneHigh = na
g_switch = barstate.isfirst ? true : (g_active != g_active[1])
if bar_index == 0 or g_switch
g_zoneStart := bar_index
g_zoneHigh := na
g_inZone = g_active and bar_index >= g_zoneStart
g_zoneHigh_prev = g_zoneHigh
if g_inZone
if na(g_zoneHigh) or high > g_zoneHigh
g_zoneHigh := high
var int r_zoneStart = na
var float r_zoneLow = na
r_switch = barstate.isfirst ? true : (r_active != r_active[1])
if bar_index == 0 or r_switch
r_zoneStart := bar_index
r_zoneLow := na
r_inZone = r_active and bar_index >= r_zoneStart
r_zoneLow_prev = r_zoneLow
if r_inZone
if na(r_zoneLow) or low < r_zoneLow
r_zoneLow := low
long_blue_now = g_inZone and f_rise(blauer_punkt_short)
short_blue_now = r_inZone and f_rise(blauer_punkt_long)
long_start_ok = long_blue_now and not na(g_zoneHigh_prev)
short_start_ok = short_blue_now and not na(r_zoneLow_prev)
// --- State & Zeichnungsobjekte ---
var bool long_pending_active = false
var float long_refHigh = na
var label startLblLong = na
var line longPendingLine = na
var bool short_pending_active = false
var float short_refLow = na
var label startLblShort = na
var line shortPendingLine = na
// --- Preis-Textboxen (Labels) ---
var label priceLblLong = na
var label priceLblShort = na
// --- Events (für Alerts) ---
var bool ev_long_start = false
var bool ev_short_start = false
var bool ev_long_done = false
var bool ev_short_done = false
var bool ev_long_break = false
var bool ev_short_break = false
ev_long_start := false
ev_short_start := false
ev_long_done := false
ev_short_done := false
ev_long_break := false
ev_short_break := false
// --- Start Long ---
if long_start_ok and not long_pending_active
// Gegen-Zone beenden → immer nur 1 Zone aktiv
if short_pending_active
if not na(startLblShort)
label.delete(startLblShort)
startLblShort := na
if not na(shortPendingLine)
line.delete(shortPendingLine)
shortPendingLine := na
if not na(priceLblShort)
label.delete(priceLblShort)
priceLblShort := na
short_pending_active := false
short_refLow := na
long_pending_active := true
long_refHigh := g_zoneHigh_prev
ev_long_start := true
if high < long_refHigh
if not na(startLblLong)
label.delete(startLblLong)
startLblLong := label.new(bar_index, high + atr * label_offset_mult, "Ein Hoch kommt noch", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_down, color=color.blue, textcolor=color.white, size=size.small)
// Linie nur, wenn Haken gesetzt
if show_blues_lines
if not na(longPendingLine)
line.delete(longPendingLine)
longPendingLine := line.new(bar_index, long_refHigh, bar_index + 1, long_refHigh, xloc=xloc.bar_index, extend=extend.right, color=color.blue, width=2)
// --- Start Short ---
if short_start_ok and not short_pending_active
// Gegen-Zone beenden → immer nur 1 Zone aktiv
if long_pending_active
if not na(startLblLong)
label.delete(startLblLong)
startLblLong := na
if not na(longPendingLine)
line.delete(longPendingLine)
longPendingLine := na
if not na(priceLblLong)
label.delete(priceLblLong)
priceLblLong := na
long_pending_active := false
long_refHigh := na
short_pending_active := true
short_refLow := r_zoneLow_prev
ev_short_start := true
if low > short_refLow
if not na(startLblShort)
label.delete(startLblShort)
startLblShort := label.new(bar_index, low - atr * label_offset_mult, "Ein Tief kommt noch", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_up, color=color.blue, textcolor=color.white, size=size.small)
// Linie nur, wenn Haken gesetzt
if show_blues_lines
if not na(shortPendingLine)
line.delete(shortPendingLine)
shortPendingLine := line.new(bar_index, short_refLow, bar_index + 1, short_refLow, xloc=xloc.bar_index, extend=extend.right, color=color.blue, width=2)
// --- Fulfillment / Cloud-Break ---
long_fulfilled_now = long_pending_active and high >= long_refHigh
short_fulfilled_now = short_pending_active and low <= short_refLow
long_cloud_break = long_pending_active and not g_active
short_cloud_break = short_pending_active and not r_active
if long_fulfilled_now
ev_long_done := true
if short_fulfilled_now
ev_short_done := true
if long_cloud_break
ev_long_break := true
if short_cloud_break
ev_short_break := true
end_long = long_pending_active and (long_fulfilled_now or long_cloud_break)
end_short = short_pending_active and (short_fulfilled_now or short_cloud_break)
// --- End Long (inline) ---
if end_long
if not na(startLblLong)
label.delete(startLblLong)
startLblLong := na
if not na(longPendingLine)
line.delete(longPendingLine)
longPendingLine := na
if not na(priceLblLong)
label.delete(priceLblLong)
priceLblLong := na
long_pending_active := false
long_refHigh := na
// --- End Short (inline) ---
if end_short
if not na(startLblShort)
label.delete(startLblShort)
startLblShort := na
if not na(shortPendingLine)
line.delete(shortPendingLine)
shortPendingLine := na
if not na(priceLblShort)
label.delete(priceLblShort)
priceLblShort := na
short_pending_active := false
short_refLow := na
// --- Linien entfernen, wenn Haken aus ---
if not show_blues_lines
if not na(longPendingLine)
line.delete(longPendingLine)
longPendingLine := na
if not na(shortPendingLine)
line.delete(shortPendingLine)
shortPendingLine := na
// --- Preis-Textboxen zeichnen / aktualisieren ---
if show_price_textbox and long_pending_active
int lx = na(longPendingLine) ? bar_index : line.get_x1(longPendingLine)
float ly = long_refHigh
string t = str.tostring(ly, format.mintick)
if na(priceLblLong)
priceLblLong := label.new(lx, ly, t, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_right, textcolor=color.blue, color=color.new(color.white, 100), size=size.normal)
else
label.set_x(priceLblLong, lx)
label.set_y(priceLblLong, ly)
label.set_text(priceLblLong, t)
else
if not na(priceLblLong)
label.delete(priceLblLong)
priceLblLong := na
if show_price_textbox and short_pending_active
int sx = na(shortPendingLine) ? bar_index : line.get_x1(shortPendingLine)
float sy = short_refLow
string ts = str.tostring(sy, format.mintick)
if na(priceLblShort)
priceLblShort := label.new(sx, sy, ts, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_right, textcolor=color.blue, color=color.new(color.white, 100), size=size.normal)
else
label.set_x(priceLblShort, sx)
label.set_y(priceLblShort, sy)
label.set_text(priceLblShort, ts)
else
if not na(priceLblShort)
label.delete(priceLblShort)
priceLblShort := na
// ========= Alerts: Standard =========
alertcondition(isPearlLong, title="Pearl Long", message="Pearl Diver erkannt {{ticker}} {{interval}}")
alertcondition(isPearlShort, title="Pearl Short", message="Oyster Farmer erkannt {{ticker}} {{interval}}")
alertcondition(ulti_rally, title="Ulti Rally", message="Ulti Rally erkannt {{ticker}} {{interval}}")
alertcondition(stephan_setup,title="Stephan Setup", message="Stephan Setup erkannt {{ticker}} {{interval}}")
alertcondition(is_bgrl, title="BGRL", message="Black Green Rocket Long erkannt {{ticker}} {{interval}}")
alertcondition(is_rotes_plus,title="Rotes Kreuz bei grüner Wolke", message="Rotes Kreuz erkannt {{ticker}} {{interval}}")
alertcondition(long_pending_active, title="Blues: Ein Hoch kommt noch (aktiv)", message="Blues Long aktiv {{ticker}} {{interval}}")
alertcondition(short_pending_active, title="Blues: Ein Tief kommt noch (aktiv)", message="Blues Short aktiv {{ticker}} {{interval}}")
alertcondition(ev_long_start, title="Blues: Ein Hoch kommt noch (Start)", message="Blues Long START {{ticker}} {{interval}}")
alertcondition(ev_short_start, title="Blues: Ein Tief kommt noch (Start)", message="Blues Short START {{ticker}} {{interval}}")
alertcondition(ev_long_done, title="Blues: Ein Hoch kommt noch (Erfüllt)", message="Blues Long FULFILLED {{ticker}} {{interval}}")
alertcondition(ev_short_done, title="Blues: Ein Tief kommt noch (Erfüllt)", message="Blues Short FULFILLED {{ticker}} {{interval}}")
alertcondition(ev_long_break, title="Blues: Ein Hoch kommt noch (Wolkenbruch)", message="Blues Long INVALID (Cloud Break) {{ticker}} {{interval}}")
alertcondition(ev_short_break, title="Blues: Ein Tief kommt noch (Wolkenbruch)", message="Blues Short INVALID (Cloud Break) {{ticker}} {{interval}}")
// ========= Alert-Kombinator (UND/ODER) =========
grp = "ALERT-COMBO"
optNone = "— (keins) —"
optPearlLong = "Pearl Long"
optPearlShort = "Pearl Short"
optUlti = "Ulti Rally"
optStephan = "Stephan Setup"
optBGRL = "BGRL"
optRotesPlus = "Rotes Kreuz (grüne Wolke)"
optBlueLActive = "Blues: Ein Hoch kommt noch (aktiv)"
optBlueSActive = "Blues: Ein Tief kommt noch (aktiv)"
sel1 = input.string(optNone, "Signal-Auswahl 1", options=[optNone,optPearlLong,optPearlShort,optUlti,optStephan,optBGRL,optRotesPlus,optBlueLActive,optBlueSActive], group=grp)
sel2 = input.string(optNone, "Signal-Auswahl 2", options=[optNone,optPearlLong,optPearlShort,optUlti,optStephan,optBGRL,optRotesPlus,optBlueLActive,optBlueSActive], group=grp)
sel3 = input.string(optNone, "Signal-Auswahl 3", options=[optNone,optPearlLong,optPearlShort,optUlti,optStephan,optBGRL,optRotesPlus,optBlueLActive,optBlueSActive], group=grp)
sel4 = input.string(optNone, "Signal-Auswahl 4", options=[optNone,optPearlLong,optPearlShort,optUlti,optStephan,optBGRL,optRotesPlus,optBlueLActive,optBlueSActive], group=grp)
sel5 = input.string(optNone, "Signal-Auswahl 5", options=[optNone,optPearlLong,optPearlShort,optUlti,optStephan,optBGRL,optRotesPlus,optBlueLActive,optBlueSActive], group=grp)
noCombine = input.bool(false, "Signale nicht kombinieren", group=grp, tooltip="Aus: Alle ausgewählten Signale müssen gleichzeitig zutreffen (UND). Ein: Irgendeins reicht (ODER).")
f_pick(name) =>
bool res = false
if name == optPearlLong
res := isPearlLong
else if name == optPearlShort
res := isPearlShort
else if name == optUlti
res := ulti_rally
else if name == optStephan
res := stephan_setup
else if name == optBGRL
res := is_bgrl
else if name == optRotesPlus
res := is_rotes_plus
else if name == optBlueLActive
res := long_pending_active
else if name == optBlueSActive
res := short_pending_active
res
c1 = f_pick(sel1)
c2 = f_pick(sel2)
c3 = f_pick(sel3)
c4 = f_pick(sel4)
c5 = f_pick(sel5)
s1 = sel1 != optNone
s2 = sel2 != optNone
s3 = sel3 != optNone
s4 = sel4 != optNone
s5 = sel5 != optNone
anySel = (s1 ? c1 : false) or (s2 ? c2 : false) or (s3 ? c3 : false) or (s4 ? c4 : false) or (s5 ? c5 : false)
allSel = (s1 ? c1 : true) and (s2 ? c2 : true) and (s3 ? c3 : true) and (s4 ? c4 : true) and (s5 ? c5 : true)
hasSelection = s1 or s2 or s3 or s4 or s5
pickedBlueL = (sel1 == optBlueLActive) or (sel2 == optBlueLActive) or (sel3 == optBlueLActive) or (sel4 == optBlueLActive) or (sel5 == optBlueLActive)
pickedBlueS = (sel1 == optBlueSActive) or (sel2 == optBlueSActive) or (sel3 == optBlueSActive) or (sel4 == optBlueSActive) or (sel5 == optBlueSActive)
bothBluesSelected = pickedBlueL and pickedBlueS
useOr = noCombine or bothBluesSelected
comboCond = hasSelection ? (useOr ? anySel : allSel) : false
alertcondition(comboCond, title="ALERT-COMBO (aus Eingaben)", message="ALERT-COMBO erfüllt {{ticker}} {{interval}}")
// ========= Telgos 2-Bar-Prime =========
grpTHP = "Telgos-Filter"
require_since_start = input.bool(true, "Ein Hoch/Tief kommt noch für Filter aktiv", group=grpTHP, tooltip="Wenn aktiviert: Nur Auslöser berücksichtigen, die seit Beginn des aktuellen 'Ein Hoch/Tief kommt noch' aufgetreten sind")
ausloeser_signal = isPearlLong or ulti_rally or stephan_setup or is_bgrl or is_rotes_plus
trigger_now_or_prev = ausloeser_signal or (bar_index > 0 ? ausloeser_signal[1] : false)
since_start = ta.barssince(ev_long_start)
since_trigger = ta.barssince(ausloeser_signal)
cond_since_start = not na(since_start) and not na(since_trigger) and since_trigger <= since_start
telgos_2bar_prime_cond = long_pending_active and trigger_now_or_prev and (not require_since_start or cond_since_start)
alertcondition(telgos_2bar_prime_cond, title="Telgos 2-Bar-Prime", message="Telgos 2-Bar-Prime {{ticker}} {{interval}}")
// ========= Preisskala-Labels =========
// Wolke (Pink) Linie im Pane + Preisskaleneintrag
plot(show_ps_wolke ? wolke_Line_pink : na,
title = "Wolke Pink",
color = col_ps_wolke,
linewidth = 1,
style = plot.style_line,
trackprice = true,
display = display.all)
// Blues NUR Preisskala (keine Linie), nur auf der letzten Kerze und nur wenn aktiv
ps_bluel_val = show_ps_bluel and long_pending_active ? long_refHigh : na
ps_blues_val = show_ps_blues and short_pending_active ? short_refLow : na
ps_bluel_last = barstate.islast ? ps_bluel_val : na
ps_blues_last = barstate.islast ? ps_blues_val : na
plot(ps_bluel_last, title="Blues Long-Level", color=col_ps_bluel, trackprice=true, display=display.price_scale)
plot(ps_blues_last, title="Blues Short-Level", color=col_ps_blues, trackprice=true, display=display.price_scale)
// ========= Dezente Labels / Shapes =========
if isPearlLong
label.new(bar_index, low - atr * label_offset_mult, text="Pearl Diver", style=label.style_label_up, color=color.purple, textcolor=color.white, size=size.small)
if isPearlShort
label.new(bar_index, high + atr * label_offset_mult, text="Oyster Farmer", style=label.style_label_down, color=color.purple, textcolor=color.white, size=size.small)
if ulti_rally
label.new(bar_index, low - atr * label_offset_mult, text="Ulti", style=label.style_label_up, color=color.aqua, textcolor=color.white, size=size.small)
if stephan_setup
label.new(bar_index, low - atr * label_offset_mult, text="Stephan", style=label.style_label_up, color=color.teal, textcolor=color.white, size=size.small)
if is_bgrl
label.new(bar_index, low - atr * label_offset_mult, text="BGRL", style=label.style_label_up, color=color.gray, textcolor=color.white, size=size.small)
if is_rotes_plus
label.new(bar_index, high + atr * label_offset_mult, text="Rotes Kreuz", style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)
plotshape(isPearlLong, title="Pearl Long", location=location.abovebar, color=color.new(color.purple, 100), style=shape.labelup, size=size.tiny)
plotshape(isPearlShort, title="Pearl Short", location=location.belowbar, color=color.new(color.purple, 100), style=shape.labeldown, size=size.tiny)
plotshape(ulti_rally, title="Ulti Rally", location=location.abovebar, color=color.new(color.aqua, 100), style=shape.diamond, size=size.tiny)
plotshape(stephan_setup, title="Stephan Setup", location=location.abovebar, color=color.new(color.teal, 100), style=shape.labelup, size=size.tiny)
plotshape(is_bgrl, title="BGRL", location=location.abovebar, color=color.new(color.gray, 100), style=shape.triangleup, size=size.tiny)
plotshape(is_rotes_plus, title="Rotes Kreuz", location=location.belowbar, color=color.new(color.red, 100), style=shape.labeldown, size=size.tiny)
plotshape(long_pending_active, title="Ein Hoch kommt noch", location=location.abovebar, color=color.new(color.blue, 100), style=shape.circle, size=size.tiny)
plotshape(short_pending_active, title="Ein Tief kommt noch", location=location.belowbar, color=color.new(color.blue, 100), style=shape.circle, size=size.tiny)