//@version=6 // Cycle List — tekent precies de cycli die JIJ opgeeft. Geen berekend raster. // // Elke starttijd in de lijst krijgt een blok van de opgegeven lengte. // Toevoegen of weghalen = de lijst aanpassen, verder niets. // Tijden zijn New York. indicator("Cycle List", "Cycles", overlay = true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500) gL = "De cycli" lijst1 = input.string("00:00,00:40,01:20,02:00,03:07,03:20,04:00,04:40,05:20,06:00,06:40,07:20,08:27,08:40,09:47,10:00,10:40,11:20,12:00,12:40,13:20,14:00,14:40,15:20,15:47,16:00,16:40,17:20,18:00,18:40,19:20,20:00,20:40,21:20,22:00,22:40,23:20", "Starttijden (HH:MM, komma's)", group = gL, tooltip = "Voeg toe of haal weg wat je wilt. Volgorde maakt niet uit.") lijst2 = input.string("", "Extra regel (optioneel)", group = gL, tooltip = "Als de eerste regel vol is. Zelfde formaat.") lengte = input.string("13m", "Lengte per blok", group = gL, tooltip = "13m laat het blok eindigen op de getoonde eindtijd (03:07 – 03:20).\n" + "13m20s is de rekenkundige cycluslengte en loopt een minuut door.") gS = "Stijl" kl = input.color(#1c4e80, "Blok", group = gS) vul = input.int(90, "Doorzichtigheid", minval = 70, maxval = 99, group = gS) rand = input.int(1, "Randdikte", minval = 1, maxval = 3, group = gS) toonTijd = input.bool(true, "Begin- en eindtijd tonen", group = gS) bewaar = input.int(60, "Blokken bewaren", minval = 5, maxval = 300, group = gS) string tz = "America/New_York" // ───────────────────────────────────────────── lengte in seconden parseDur(string raw) => string t = str.replace_all(str.lower(raw), " ", "") float total = 0.0 bool unit = str.contains(t, "h") or str.contains(t, "m") or str.contains(t, "s") if str.contains(t, ":") and not unit a = str.split(t, ":") float mm = array.size(a) > 0 ? nz(str.tonumber(array.get(a, 0))) : 0.0 float ss = array.size(a) > 1 ? nz(str.tonumber(array.get(a, 1))) : 0.0 total := mm * 60.0 + ss else string buf = "" string last = "" if str.length(t) > 0 for i = 0 to str.length(t) - 1 string ch = str.substring(t, i, i + 1) if ch == "h" or ch == "m" or ch == "s" total += nz(str.tonumber(buf)) * (ch == "h" ? 3600.0 : ch == "m" ? 60.0 : 1.0) buf := "" last := ch else buf := buf + ch if str.length(buf) > 0 total += nz(str.tonumber(buf)) * (last == "h" ? 60.0 : last == "" ? 60.0 : 1.0) total // ───────────────────────────────────── lijst inlezen naar seconden-van-de-dag vulLijst(string bron, array doel) => string b = str.replace_all(bron, " ", "") if str.length(b) > 0 arr = str.split(b, ",") for i = 0 to array.size(arr) - 1 string e = array.get(arr, i) if str.contains(e, ":") p = str.split(e, ":") int hh = array.size(p) > 0 ? int(math.round(nz(str.tonumber(array.get(p, 0))))) : -1 int mm = array.size(p) > 1 ? int(math.round(nz(str.tonumber(array.get(p, 1))))) : 0 if hh >= 0 and hh < 24 and mm >= 0 and mm < 60 array.push(doel, hh * 3600 + mm * 60) var array starts = array.new() if barstate.isfirst vulLijst(lijst1, starts) vulLijst(lijst2, starts) int L = int(parseDur(lengte)) int sod = hour(time, tz) * 3600 + minute(time, tz) * 60 + second(time, tz) // welk blok is nu actief? int actief = -1 if array.size(starts) > 0 for i = 0 to array.size(starts) - 1 int s = array.get(starts, i) if sod >= s and sod < s + L actief := s // ───────────────────────────────────────────────────────────── tekenen var array bxs = array.new() var array