[{"data":1,"prerenderedAt":2622},["ShallowReactive",2],{"indicators:core-concepts/repainting":3},{"slug":4,"filePath":5,"frontmatter":6,"rawMarkdown":11,"tree":12},"core-concepts/repainting","core-concepts/repainting.md",{"title":7,"description":8,"order":9,"section":10},"Repainting","What repainting is, why it breaks backtests, and why an Indicator does not repaint by construction: state() sees one bar and nothing later, a higher timeframe…",24,"core-concepts","---\ntitle: \"Repainting\"\ndescription: \"What repainting is, why it breaks backtests, and why an Indicator does not repaint by construction: state() sees one bar and nothing later, a higher timeframe…\"\norder: 24\nsection: \"core-concepts\"\n---\n\n\u003C!-- source: docs/indicators/core-concepts/repainting.md; generated by packages/cli/scripts/gen-indicator-docs.ts, do not edit -->\n\n# Repainting\n\nWhat repainting is, why it breaks backtests, and why an Indicator does not\nrepaint by construction: `state()` sees one bar and nothing later, a\nhigher timeframe is folded in only after its candle closes, an `interval`\npin is read as of close, and the forming bar is replayed through `reset()`.\nThe one way to repaint an Indicator is a field `reset()` forgets, and this\npage shows what that looks like so you never ship it. kScript (legacy) got\nthe same guarantee from a confirmed `htf()`; an Indicator gets it from the\nshape of the model.\n\n## What repainting is\n\nRepainting is when a script's historical values change after the fact. The\nline you see today over old bars is not the line the script drew when those\nbars were live. A signal that looks like it fired one bar early in backtest\nfires one bar late in production, or never. The chart redraws itself once\nthe future arrives, so your backtest is reading numbers that did not exist\nat the time.\n\nThat is the whole problem in one sentence: a repainting indicator lies\nabout the past, so anything you measure on history (win rate, drawdown,\nsignal timing) is fiction. You cannot trust a backtest you cannot\nreproduce.\n\n## Why it happens\n\nRepainting comes from reading data that was not yet available at the bar\nyou are computing. Three sources, two classic and one specific to a module\nwith state:\n\n- **An unclosed higher-timeframe candle.** A naive 4h lookup on a 1h chart\n  hands back the forming candle's live value; history backfills the\n  finished number the live chart never had.\n- **A future-leaking series.** Anything that depends on a later bar: a\n  centered smoother, \"highest of the next N bars\". History resolves it; live\n  it does not exist yet.\n- **Stale state on the replayed bar.** The forming bar is evaluated on every\n  tick; if an evaluation sees leftovers from the previous one, the newest\n  value drifts with every tick and settles where history never will.\n\nThe tell is the same each time: the computation saw something during the\nbacktest that it could not have seen live, or saw something live that\nhistory will not replay.\n\n## The good news: no lookahead by construction\n\n`state()` receives exactly one bar: the inputs of the bar being evaluated,\noldest first. There is no history array to index forward, no `[−1]`, no\nway to reach the next bar. A value can only depend on bars at or before\nits own, so a mark that appears in history would have appeared live on the\nsame bar. An Indicator cannot break this by accident; there is nothing to\npeek at.\n\nThe causal-prefix guarantee in one sentence: at bar *t*, every value the\nmodule holds was derived only from bars at or before *t*, so the past never\nchanges when the future arrives.\n\n## Higher timeframes: confirmed by the fold\n\nOn the chart every input is the chart's own interval, so a higher timeframe\nis built inside the module: bucket bars by `time.bar_open_sec`, remember\nthe running bucket's close, and fold it into the 4h statistic only when a\nbar from the **next** bucket arrives. A 4h candle contributes exactly once,\nafter it closed. Rerun over history and it matches what it showed live,\nbar for bar. No look-ahead, no flag to remember.\n\n```typescript\nimport { input, line, ohlcv, output, overlay, param, time } from \"./sdk/declare\";\nimport { in_bar_t, in_close } from \"./gen/inputs\";\nimport { emitRow, out_close, out_h4_close, out_h4_developing } from \"./gen/outputs\";\nimport { p_bucket_hours } from \"./gen/params\";\n\nparam(\"bucket_hours\", 4, { min: 1, max: 168, description: \"Higher-timeframe bucket, in hours\" });\ninput(\"close\", ohlcv.close);\ninput(\"bar_t\", time.bar_open_sec);\n// The confirmed higher-timeframe close: flat across the bucket, stepping only when a candle closes.\noutput(\"h4_close\", line, overlay, { color: \"#7c3aed\", width: 2, description: \"The most recent fully closed 4h candle, no look-ahead\" });\n// The developing value, opt-in and clearly labeled: it moves with every bar inside the bucket.\noutput(\"h4_developing\", line, overlay, { color: \"#16a34a\", width: 1, description: \"The forming 4h candle's running close (repaints by design)\" });\noutput(\"close\", line, overlay, { color: \"#94a3b8\", width: 1, description: \"The chart-timeframe close for comparison\" });\n\nlet bucketSec: f64 = 14400.0;\nlet bucket: f64 = NaN; // the bucket the running candle belongs to\nlet running: f64 = NaN; // the running candle's latest close (developing)\nlet confirmed: f64 = NaN; // the last CLOSED candle's close\nlet close: f64 = NaN;\n\nexport function init(): void {\n  bucketSec = p_bucket_hours() * 3600.0;\n}\n\nexport function state(): i32 {\n  close = in_close();\n  const b = Math.floor(in_bar_t() / bucketSec);\n  if (b != bucket) {\n    // A bar from the next bucket has arrived: the running candle is now closed, and only now is it confirmed.\n    if (!isNaN(bucket)) confirmed = running;\n    bucket = b;\n  }\n  running = close;\n  return isNaN(confirmed) ? 0 : 1;\n}\n\nexport function finalize(): void {\n  out_h4_close(confirmed);\n  out_h4_developing(running);\n  out_close(close);\n  emitRow();\n}\n\nexport function reset(): void {\n  bucket = NaN;\n  running = NaN;\n  confirmed = NaN;\n  close = NaN;\n}\n```\n\n### Read the staircase\n\nThe purple `h4_close` line is flat across four 1h bars, then steps to a new\nlevel, then holds flat again. That staircase is the visual signature of a\ncorrect, confirmed higher timeframe: the value only changes when a 4h\ncandle actually closes, and between closes there is no new confirmed\ninformation. The green `h4_developing` line tracks the grey chart close\ninside each bucket: that is what a repainting value looks like, and it is\ndrawn here on purpose so you can see the difference. A cross built on the\ngreen line would not survive into production; a cross built on the purple\none reproduces exactly.\n\n## Requesting a live value is opt-in\n\nSometimes you genuinely want the forming bucket: a live 4h close ticking in\na readout. In a module that is just the running variable, as above, and it\nis a deliberate choice you make by reading `running` instead of\n`confirmed`. A developing value is fine for a display; it is the wrong\nthing for a signal, because it changes as the bucket fills, so a cross or\nthreshold built on it will not reproduce on history. Reach for it only when\nyou want to *show* the live edge, never when you want to *act* on it.\n\n## Pins are read as of close\n\nOn your machine an `interval` pin reads a real coarser feed and the host\napplies the same rule for you: a coarser source contributes to a primary\nrow only as of its candle's CLOSE, live or historical, so a forming 4h\ncandle never leaks into the 1h rows under it (`multi-timeframe.md`). The\ncost is a value that steps once per source candle: the same staircase.\n\n## The forming bar and `reset()`\n\nThe forming bar is the one exception to \"one call per bar\": it re-evaluates\non every tick. The host does not re-run history for that; it snapshots the\nmodule after the last closed bar and replays the revised forming bar into\nthe snapshot. Because the snapshot holds every module-level variable, the\nmodule's `reset()` is what puts the state back before each replay, and a\nstale field is the one way an Indicator repaints:\n\n```text\nlet barsSeen: f64 = 0.0;\nlet cvd: f64 = 0.0;\n\nexport function reset(): void {\n  cvd = 0.0;\n  // barsSeen is not reset: the forming bar's replays keep incrementing it,\n  // so the newest row reads 1, then 2, then 3 as ticks arrive, and history\n  // (which counted it once) will never show those values.\n}\n```\n\nEvery module-level `let` is reassigned in `reset()`, every TA object gets\n`.reset()`, and a class you wrote gets a `reset()` of its own. Allocation\ndoes not belong there (the module never frees memory; reset the fields in\nplace). If a value on the newest bar drifts as you watch it while the\nclosed bars stay put, `reset()` is the first place to look.\n\n## The host decides which bars the module sees\n\nRun-level renderers and drawings are selected from the finished row set\nwith no backward scan (the newest ready row that satisfies the kind's rule\nwins), and they never change a metric value. On your machine `om metric\nseries` returns the forming bar as its newest row; bar-evaluated metric\nsignals compute AS OF the last closed primary bar instead, dropping the\nforming rows before the module folds them. The module is the same either\nway.\n\n## How to stay repaint-safe\n\nA short checklist:\n\n- **Fold higher timeframes on the next bucket.** The confirmed value is the\n  one you act on; the running value is a readout.\n- **Do not act on the still-forming bar.** Its high, low, and close are\n  moving until it closes. Gate confirmed signals on settled data, or let a\n  closed-bar consumer cut the forming bar for you.\n- **Reset everything.** Every module-level variable, every TA object, every\n  class you wrote. A forgotten field is the one repaint an Indicator can\n  have.\n- **Keep the primary selector-following and the pins honest.** A pinned\n  coarse input is read as of close on your machine; on the chart, pins are\n  not honored and every input is the chart's own interval, so build the\n  higher timeframe with the fold.\n\nStick to confirmed folds and a complete `reset()` and your backtest will\nmean something: what you measured on history is what the Indicator would\nhave done live.\n\n## See also\n\n- [Multi-timeframe](multi-timeframe.md) for the full bucket-fold and\n  `interval`-pin story, calendar buckets included.\n- [Execution model](execution-model.md) for the bar loop, warm-up, and the\n  three hosts.\n",{"type":13,"children":14,"data":2615,"position":2617},"root",[15,25,28,29,152,153,172,173,189,190,204,205,222,223,238,239,348,349,363,364,380,381,429,430,489,490,506,507,560,561,1748,1749,1766,1767,1819,1820,1836,1837,1932,1933,1949,1950,2002,2003,2030,2031,2064,2065,2152,2153,2257,2258,2274,2275,2310,2311,2327,2328,2342,2343,2474,2475,2507,2508,2524,2525],{"type":16,"value":17,"position":18},"comment"," source: docs/indicators/core-concepts/repainting.md; generated by packages/cli/scripts/gen-indicator-docs.ts, do not edit ",{"start":19,"end":22},{"line":20,"column":20,"offset":21},1,0,{"line":20,"column":23,"offset":24},131,130,{"type":26,"value":27},"text","\n",{"type":26,"value":27},{"type":30,"tagName":31,"properties":32,"children":33,"position":149},"element","p",{},[34,44,58,66,79,87,100,108,120,128,141],{"type":26,"value":35,"position":36},"What repainting is, why it breaks backtests, and why an Indicator does not\nrepaint by construction: ",{"start":37,"end":40},{"line":38,"column":20,"offset":39},5,146,{"line":41,"column":42,"offset":43},6,26,246,{"type":30,"tagName":45,"properties":46,"children":47,"position":55},"code",{},[48],{"type":26,"value":49,"position":50},"state()",{"start":51,"end":52},{"line":41,"column":42,"offset":43},{"line":41,"column":53,"offset":54},35,255,{"start":56,"end":57},{"line":41,"column":42,"offset":43},{"line":41,"column":53,"offset":54},{"type":26,"value":59,"position":60}," sees one bar and nothing later, a\nhigher timeframe is folded in only after its candle closes, an ",{"start":61,"end":62},{"line":41,"column":53,"offset":54},{"line":63,"column":64,"offset":65},7,64,353,{"type":30,"tagName":45,"properties":67,"children":68,"position":76},{},[69],{"type":26,"value":70,"position":71},"interval",{"start":72,"end":73},{"line":63,"column":64,"offset":65},{"line":63,"column":74,"offset":75},74,363,{"start":77,"end":78},{"line":63,"column":64,"offset":65},{"line":63,"column":74,"offset":75},{"type":26,"value":80,"position":81},"\npin is read as of close, and the forming bar is replayed through ",{"start":82,"end":83},{"line":63,"column":74,"offset":75},{"line":84,"column":85,"offset":86},8,66,429,{"type":30,"tagName":45,"properties":88,"children":89,"position":97},{},[90],{"type":26,"value":91,"position":92},"reset()",{"start":93,"end":94},{"line":84,"column":85,"offset":86},{"line":84,"column":95,"offset":96},75,438,{"start":98,"end":99},{"line":84,"column":85,"offset":86},{"line":84,"column":95,"offset":96},{"type":26,"value":101,"position":102},".\nThe one way to repaint an Indicator is a field ",{"start":103,"end":104},{"line":84,"column":95,"offset":96},{"line":105,"column":106,"offset":107},9,48,487,{"type":30,"tagName":45,"properties":109,"children":110,"position":117},{},[111],{"type":26,"value":91,"position":112},{"start":113,"end":114},{"line":105,"column":106,"offset":107},{"line":105,"column":115,"offset":116},57,496,{"start":118,"end":119},{"line":105,"column":106,"offset":107},{"line":105,"column":115,"offset":116},{"type":26,"value":121,"position":122}," forgets, and this\npage shows what that looks like so you never ship it. kScript (legacy) got\nthe same guarantee from a confirmed ",{"start":123,"end":124},{"line":105,"column":115,"offset":116},{"line":125,"column":126,"offset":127},11,37,626,{"type":30,"tagName":45,"properties":129,"children":130,"position":138},{},[131],{"type":26,"value":132,"position":133},"htf()",{"start":134,"end":135},{"line":125,"column":126,"offset":127},{"line":125,"column":136,"offset":137},44,633,{"start":139,"end":140},{"line":125,"column":126,"offset":127},{"line":125,"column":136,"offset":137},{"type":26,"value":142,"position":143},"; an Indicator gets it from the\nshape of the model.",{"start":144,"end":145},{"line":125,"column":136,"offset":137},{"line":146,"column":147,"offset":148},12,20,684,{"start":150,"end":151},{"line":38,"column":20,"offset":39},{"line":146,"column":147,"offset":148},{"type":26,"value":27},{"type":30,"tagName":154,"properties":155,"children":157,"position":168},"h2",{"id":156},"what-repainting-is",[158],{"type":26,"value":159,"position":160},"What repainting is",{"start":161,"end":165},{"line":162,"column":163,"offset":164},14,4,689,{"line":162,"column":166,"offset":167},22,707,{"start":169,"end":171},{"line":162,"column":20,"offset":170},686,{"line":162,"column":166,"offset":167},{"type":26,"value":27},{"type":30,"tagName":31,"properties":174,"children":175,"position":186},{},[176],{"type":26,"value":177,"position":178},"Repainting is when a script's historical values change after the fact. The\nline you see today over old bars is not the line the script drew when those\nbars were live. A signal that looks like it fired one bar early in backtest\nfires one bar late in production, or never. The chart redraws itself once\nthe future arrives, so your backtest is reading numbers that did not exist\nat the time.",{"start":179,"end":182},{"line":180,"column":20,"offset":181},16,709,{"line":183,"column":184,"offset":185},21,13,1097,{"start":187,"end":188},{"line":180,"column":20,"offset":181},{"line":183,"column":184,"offset":185},{"type":26,"value":27},{"type":30,"tagName":31,"properties":191,"children":192,"position":201},{},[193],{"type":26,"value":194,"position":195},"That is the whole problem in one sentence: a repainting indicator lies\nabout the past, so anything you measure on history (win rate, drawdown,\nsignal timing) is fiction. You cannot trust a backtest you cannot\nreproduce.",{"start":196,"end":199},{"line":197,"column":20,"offset":198},23,1099,{"line":42,"column":125,"offset":200},1318,{"start":202,"end":203},{"line":197,"column":20,"offset":198},{"line":42,"column":125,"offset":200},{"type":26,"value":27},{"type":30,"tagName":154,"properties":206,"children":208,"position":218},{"id":207},"why-it-happens",[209],{"type":26,"value":210,"position":211},"Why it happens",{"start":212,"end":215},{"line":213,"column":163,"offset":214},28,1323,{"line":213,"column":216,"offset":217},18,1337,{"start":219,"end":221},{"line":213,"column":20,"offset":220},1320,{"line":213,"column":216,"offset":217},{"type":26,"value":27},{"type":30,"tagName":31,"properties":224,"children":225,"position":235},{},[226],{"type":26,"value":227,"position":228},"Repainting comes from reading data that was not yet available at the bar\nyou are computing. Three sources, two classic and one specific to a module\nwith state:",{"start":229,"end":232},{"line":230,"column":20,"offset":231},30,1339,{"line":233,"column":146,"offset":234},32,1498,{"start":236,"end":237},{"line":230,"column":20,"offset":231},{"line":233,"column":146,"offset":234},{"type":26,"value":27},{"type":30,"tagName":240,"properties":241,"children":242,"position":345},"ul",{},[243,244,279,280,312,313,344],{"type":26,"value":27},{"type":30,"tagName":245,"properties":246,"children":247,"position":275},"li",{},[248,268],{"type":30,"tagName":249,"properties":250,"children":251,"position":261},"strong",{},[252],{"type":26,"value":253,"position":254},"An unclosed higher-timeframe candle.",{"start":255,"end":258},{"line":256,"column":38,"offset":257},34,1504,{"line":256,"column":259,"offset":260},41,1540,{"start":262,"end":265},{"line":256,"column":263,"offset":264},3,1502,{"line":256,"column":266,"offset":267},43,1542,{"type":26,"value":269,"position":270}," A naive 4h lookup on a 1h chart\nhands back the forming candle's live value; history backfills the\nfinished number the live chart never had.",{"start":271,"end":272},{"line":256,"column":266,"offset":267},{"line":273,"column":136,"offset":274},36,1686,{"start":276,"end":278},{"line":256,"column":20,"offset":277},1500,{"line":273,"column":136,"offset":274},{"type":26,"value":27},{"type":30,"tagName":245,"properties":281,"children":282,"position":308},{},[283,300],{"type":30,"tagName":249,"properties":284,"children":285,"position":294},{},[286],{"type":26,"value":287,"position":288},"A future-leaking series.",{"start":289,"end":291},{"line":126,"column":38,"offset":290},1691,{"line":126,"column":292,"offset":293},29,1715,{"start":295,"end":297},{"line":126,"column":263,"offset":296},1689,{"line":126,"column":298,"offset":299},31,1717,{"type":26,"value":301,"position":302}," Anything that depends on a later bar: a\ncentered smoother, \"highest of the next N bars\". History resolves it; live\nit does not exist yet.",{"start":303,"end":304},{"line":126,"column":298,"offset":299},{"line":305,"column":306,"offset":307},39,25,1859,{"start":309,"end":311},{"line":126,"column":20,"offset":310},1687,{"line":305,"column":306,"offset":307},{"type":26,"value":27},{"type":30,"tagName":245,"properties":314,"children":315,"position":340},{},[316,332],{"type":30,"tagName":249,"properties":317,"children":318,"position":327},{},[319],{"type":26,"value":320,"position":321},"Stale state on the replayed bar.",{"start":322,"end":325},{"line":323,"column":38,"offset":324},40,1864,{"line":323,"column":126,"offset":326},1896,{"start":328,"end":330},{"line":323,"column":263,"offset":329},1862,{"line":323,"column":305,"offset":331},1898,{"type":26,"value":333,"position":334}," The forming bar is evaluated on every\ntick; if an evaluation sees leftovers from the previous one, the newest\nvalue drifts with every tick and settles where history never will.",{"start":335,"end":336},{"line":323,"column":305,"offset":331},{"line":337,"column":338,"offset":339},42,69,2079,{"start":341,"end":343},{"line":323,"column":20,"offset":342},1860,{"line":337,"column":338,"offset":339},{"type":26,"value":27},{"start":346,"end":347},{"line":256,"column":20,"offset":277},{"line":337,"column":338,"offset":339},{"type":26,"value":27},{"type":30,"tagName":31,"properties":350,"children":351,"position":360},{},[352],{"type":26,"value":353,"position":354},"The tell is the same each time: the computation saw something during the\nbacktest that it could not have seen live, or saw something live that\nhistory will not replay.",{"start":355,"end":357},{"line":136,"column":20,"offset":356},2081,{"line":358,"column":306,"offset":359},46,2248,{"start":361,"end":362},{"line":136,"column":20,"offset":356},{"line":358,"column":306,"offset":359},{"type":26,"value":27},{"type":30,"tagName":154,"properties":365,"children":367,"position":376},{"id":366},"the-good-news-no-lookahead-by-construction",[368],{"type":26,"value":369,"position":370},"The good news: no lookahead by construction",{"start":371,"end":373},{"line":106,"column":163,"offset":372},2253,{"line":106,"column":374,"offset":375},47,2296,{"start":377,"end":379},{"line":106,"column":20,"offset":378},2250,{"line":106,"column":374,"offset":375},{"type":26,"value":27},{"type":30,"tagName":31,"properties":382,"children":383,"position":426},{},[384,398,406,419],{"type":30,"tagName":45,"properties":385,"children":386,"position":395},{},[387],{"type":26,"value":49,"position":388},{"start":389,"end":392},{"line":390,"column":20,"offset":391},50,2298,{"line":390,"column":393,"offset":394},10,2307,{"start":396,"end":397},{"line":390,"column":20,"offset":391},{"line":390,"column":393,"offset":394},{"type":26,"value":399,"position":400}," receives exactly one bar: the inputs of the bar being evaluated,\noldest first. There is no history array to index forward, no ",{"start":401,"end":402},{"line":390,"column":393,"offset":394},{"line":403,"column":404,"offset":405},51,62,2434,{"type":30,"tagName":45,"properties":407,"children":408,"position":416},{},[409],{"type":26,"value":410,"position":411},"[−1]",{"start":412,"end":413},{"line":403,"column":404,"offset":405},{"line":403,"column":414,"offset":415},68,2440,{"start":417,"end":418},{"line":403,"column":404,"offset":405},{"line":403,"column":414,"offset":415},{"type":26,"value":420,"position":421},", no\nway to reach the next bar. A value can only depend on bars at or before\nits own, so a mark that appears in history would have appeared live on the\nsame bar. An Indicator cannot break this by accident; there is nothing to\npeek at.",{"start":422,"end":423},{"line":403,"column":414,"offset":415},{"line":424,"column":105,"offset":425},55,2674,{"start":427,"end":428},{"line":390,"column":20,"offset":391},{"line":424,"column":105,"offset":425},{"type":26,"value":27},{"type":30,"tagName":31,"properties":431,"children":432,"position":486},{},[433,441,458,465,478],{"type":26,"value":434,"position":435},"The causal-prefix guarantee in one sentence: at bar ",{"start":436,"end":438},{"line":115,"column":20,"offset":437},2676,{"line":115,"column":439,"offset":440},53,2728,{"type":30,"tagName":442,"properties":443,"children":444,"position":453},"em",{},[445],{"type":26,"value":446,"position":447},"t",{"start":448,"end":451},{"line":115,"column":449,"offset":450},54,2729,{"line":115,"column":424,"offset":452},2730,{"start":454,"end":455},{"line":115,"column":439,"offset":440},{"line":115,"column":456,"offset":457},56,2731,{"type":26,"value":459,"position":460},", every value the\nmodule holds was derived only from bars at or before ",{"start":461,"end":462},{"line":115,"column":456,"offset":457},{"line":463,"column":449,"offset":464},58,2802,{"type":30,"tagName":442,"properties":466,"children":467,"position":474},{},[468],{"type":26,"value":446,"position":469},{"start":470,"end":472},{"line":463,"column":424,"offset":471},2803,{"line":463,"column":456,"offset":473},2804,{"start":475,"end":476},{"line":463,"column":449,"offset":464},{"line":463,"column":115,"offset":477},2805,{"type":26,"value":479,"position":480},", so the past never\nchanges when the future arrives.",{"start":481,"end":482},{"line":463,"column":115,"offset":477},{"line":483,"column":484,"offset":485},59,33,2857,{"start":487,"end":488},{"line":115,"column":20,"offset":437},{"line":483,"column":484,"offset":485},{"type":26,"value":27},{"type":30,"tagName":154,"properties":491,"children":493,"position":502},{"id":492},"higher-timeframes-confirmed-by-the-fold",[494],{"type":26,"value":495,"position":496},"Higher timeframes: confirmed by the fold",{"start":497,"end":500},{"line":498,"column":163,"offset":499},61,2862,{"line":498,"column":136,"offset":501},2902,{"start":503,"end":505},{"line":498,"column":20,"offset":504},2859,{"line":498,"column":136,"offset":501},{"type":26,"value":27},{"type":30,"tagName":31,"properties":508,"children":509,"position":557},{},[510,518,530,536,550],{"type":26,"value":511,"position":512},"On the chart every input is the chart's own interval, so a higher timeframe\nis built inside the module: bucket bars by ",{"start":513,"end":516},{"line":514,"column":20,"offset":515},63,2904,{"line":64,"column":136,"offset":517},3023,{"type":30,"tagName":45,"properties":519,"children":520,"position":527},{},[521],{"type":26,"value":522,"position":523},"time.bar_open_sec",{"start":524,"end":525},{"line":64,"column":136,"offset":517},{"line":64,"column":514,"offset":526},3042,{"start":528,"end":529},{"line":64,"column":136,"offset":517},{"line":64,"column":514,"offset":526},{"type":26,"value":531,"position":532},", remember\nthe running bucket's close, and fold it into the 4h statistic only when a\nbar from the ",{"start":533,"end":534},{"line":64,"column":514,"offset":526},{"line":85,"column":162,"offset":535},3140,{"type":30,"tagName":249,"properties":537,"children":538,"position":546},{},[539],{"type":26,"value":540,"position":541},"next",{"start":542,"end":544},{"line":85,"column":180,"offset":543},3142,{"line":85,"column":147,"offset":545},3146,{"start":547,"end":548},{"line":85,"column":162,"offset":535},{"line":85,"column":166,"offset":549},3148,{"type":26,"value":551,"position":552}," bucket arrives. A 4h candle contributes exactly once,\nafter it closed. Rerun over history and it matches what it showed live,\nbar for bar. No look-ahead, no flag to remember.",{"start":553,"end":554},{"line":85,"column":166,"offset":549},{"line":414,"column":555,"offset":556},49,3323,{"start":558,"end":559},{"line":514,"column":20,"offset":515},{"line":414,"column":555,"offset":556},{"type":26,"value":27},{"type":13,"children":562},[563],{"type":30,"tagName":564,"properties":565,"children":569,"data":-1},"pre",{"class":566,"style":567,"tabindex":568},"shiki shiki-themes github-dark github-light","--shiki-dark:#e1e4e8;--shiki-light:#24292e;--shiki-dark-bg:#24292e;--shiki-light-bg:#fff","0",[570],{"type":30,"tagName":45,"properties":571,"children":572},{},[573,606,607,632,633,658,659,684,685,688,689,754,755,777,778,799,800,809,810,860,861,869,870,916,917,962,963,966,967,1004,1005,1044,1045,1082,1083,1120,1121,1153,1154,1157,1158,1195,1196,1233,1234,1242,1243,1246,1247,1280,1281,1303,1304,1354,1355,1378,1379,1387,1388,1425,1426,1443,1444,1452,1453,1470,1471,1513,1514,1521,1522,1525,1526,1558,1559,1572,1573,1586,1587,1600,1601,1613,1614,1621,1622,1625,1626,1658,1659,1679,1680,1699,1700,1720,1721,1740,1741],{"type":30,"tagName":574,"properties":575,"children":577},"span",{"class":576},"line",[578,584,590,595,601],{"type":30,"tagName":574,"properties":579,"children":581},{"style":580},"--shiki-dark:#F97583;--shiki-light:#D73A49",[582],{"type":26,"value":583},"import",{"type":30,"tagName":574,"properties":585,"children":587},{"style":586},"--shiki-dark:#E1E4E8;--shiki-light:#24292E",[588],{"type":26,"value":589}," { input, line, ohlcv, output, overlay, param, time } ",{"type":30,"tagName":574,"properties":591,"children":592},{"style":580},[593],{"type":26,"value":594},"from",{"type":30,"tagName":574,"properties":596,"children":598},{"style":597},"--shiki-dark:#9ECBFF;--shiki-light:#032F62",[599],{"type":26,"value":600}," \"./sdk/declare\"",{"type":30,"tagName":574,"properties":602,"children":603},{"style":586},[604],{"type":26,"value":605},";",{"type":26,"value":27},{"type":30,"tagName":574,"properties":608,"children":609},{"class":576},[610,614,619,623,628],{"type":30,"tagName":574,"properties":611,"children":612},{"style":580},[613],{"type":26,"value":583},{"type":30,"tagName":574,"properties":615,"children":616},{"style":586},[617],{"type":26,"value":618}," { in_bar_t, in_close } ",{"type":30,"tagName":574,"properties":620,"children":621},{"style":580},[622],{"type":26,"value":594},{"type":30,"tagName":574,"properties":624,"children":625},{"style":597},[626],{"type":26,"value":627}," \"./gen/inputs\"",{"type":30,"tagName":574,"properties":629,"children":630},{"style":586},[631],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":634,"children":635},{"class":576},[636,640,645,649,654],{"type":30,"tagName":574,"properties":637,"children":638},{"style":580},[639],{"type":26,"value":583},{"type":30,"tagName":574,"properties":641,"children":642},{"style":586},[643],{"type":26,"value":644}," { emitRow, out_close, out_h4_close, out_h4_developing } ",{"type":30,"tagName":574,"properties":646,"children":647},{"style":580},[648],{"type":26,"value":594},{"type":30,"tagName":574,"properties":650,"children":651},{"style":597},[652],{"type":26,"value":653}," \"./gen/outputs\"",{"type":30,"tagName":574,"properties":655,"children":656},{"style":586},[657],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":660,"children":661},{"class":576},[662,666,671,675,680],{"type":30,"tagName":574,"properties":663,"children":664},{"style":580},[665],{"type":26,"value":583},{"type":30,"tagName":574,"properties":667,"children":668},{"style":586},[669],{"type":26,"value":670}," { p_bucket_hours } ",{"type":30,"tagName":574,"properties":672,"children":673},{"style":580},[674],{"type":26,"value":594},{"type":30,"tagName":574,"properties":676,"children":677},{"style":597},[678],{"type":26,"value":679}," \"./gen/params\"",{"type":30,"tagName":574,"properties":681,"children":682},{"style":586},[683],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":686,"children":687},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":690,"children":691},{"class":576},[692,698,703,708,713,719,724,729,734,739,744,749],{"type":30,"tagName":574,"properties":693,"children":695},{"style":694},"--shiki-dark:#B392F0;--shiki-light:#6F42C1",[696],{"type":26,"value":697},"param",{"type":30,"tagName":574,"properties":699,"children":700},{"style":586},[701],{"type":26,"value":702},"(",{"type":30,"tagName":574,"properties":704,"children":705},{"style":597},[706],{"type":26,"value":707},"\"bucket_hours\"",{"type":30,"tagName":574,"properties":709,"children":710},{"style":586},[711],{"type":26,"value":712},", ",{"type":30,"tagName":574,"properties":714,"children":716},{"style":715},"--shiki-dark:#79B8FF;--shiki-light:#005CC5",[717],{"type":26,"value":718},"4",{"type":30,"tagName":574,"properties":720,"children":721},{"style":586},[722],{"type":26,"value":723},", { min: ",{"type":30,"tagName":574,"properties":725,"children":726},{"style":715},[727],{"type":26,"value":728},"1",{"type":30,"tagName":574,"properties":730,"children":731},{"style":586},[732],{"type":26,"value":733},", max: ",{"type":30,"tagName":574,"properties":735,"children":736},{"style":715},[737],{"type":26,"value":738},"168",{"type":30,"tagName":574,"properties":740,"children":741},{"style":586},[742],{"type":26,"value":743},", description: ",{"type":30,"tagName":574,"properties":745,"children":746},{"style":597},[747],{"type":26,"value":748},"\"Higher-timeframe bucket, in hours\"",{"type":30,"tagName":574,"properties":750,"children":751},{"style":586},[752],{"type":26,"value":753}," });",{"type":26,"value":27},{"type":30,"tagName":574,"properties":756,"children":757},{"class":576},[758,763,767,772],{"type":30,"tagName":574,"properties":759,"children":760},{"style":694},[761],{"type":26,"value":762},"input",{"type":30,"tagName":574,"properties":764,"children":765},{"style":586},[766],{"type":26,"value":702},{"type":30,"tagName":574,"properties":768,"children":769},{"style":597},[770],{"type":26,"value":771},"\"close\"",{"type":30,"tagName":574,"properties":773,"children":774},{"style":586},[775],{"type":26,"value":776},", ohlcv.close);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":779,"children":780},{"class":576},[781,785,789,794],{"type":30,"tagName":574,"properties":782,"children":783},{"style":694},[784],{"type":26,"value":762},{"type":30,"tagName":574,"properties":786,"children":787},{"style":586},[788],{"type":26,"value":702},{"type":30,"tagName":574,"properties":790,"children":791},{"style":597},[792],{"type":26,"value":793},"\"bar_t\"",{"type":30,"tagName":574,"properties":795,"children":796},{"style":586},[797],{"type":26,"value":798},", time.bar_open_sec);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":801,"children":802},{"class":576},[803],{"type":30,"tagName":574,"properties":804,"children":806},{"style":805},"--shiki-dark:#6A737D;--shiki-light:#6A737D",[807],{"type":26,"value":808},"// The confirmed higher-timeframe close: flat across the bucket, stepping only when a candle closes.",{"type":26,"value":27},{"type":30,"tagName":574,"properties":811,"children":812},{"class":576},[813,818,822,827,832,837,842,847,851,856],{"type":30,"tagName":574,"properties":814,"children":815},{"style":694},[816],{"type":26,"value":817},"output",{"type":30,"tagName":574,"properties":819,"children":820},{"style":586},[821],{"type":26,"value":702},{"type":30,"tagName":574,"properties":823,"children":824},{"style":597},[825],{"type":26,"value":826},"\"h4_close\"",{"type":30,"tagName":574,"properties":828,"children":829},{"style":586},[830],{"type":26,"value":831},", line, overlay, { color: ",{"type":30,"tagName":574,"properties":833,"children":834},{"style":597},[835],{"type":26,"value":836},"\"#7c3aed\"",{"type":30,"tagName":574,"properties":838,"children":839},{"style":586},[840],{"type":26,"value":841},", width: ",{"type":30,"tagName":574,"properties":843,"children":844},{"style":715},[845],{"type":26,"value":846},"2",{"type":30,"tagName":574,"properties":848,"children":849},{"style":586},[850],{"type":26,"value":743},{"type":30,"tagName":574,"properties":852,"children":853},{"style":597},[854],{"type":26,"value":855},"\"The most recent fully closed 4h candle, no look-ahead\"",{"type":30,"tagName":574,"properties":857,"children":858},{"style":586},[859],{"type":26,"value":753},{"type":26,"value":27},{"type":30,"tagName":574,"properties":862,"children":863},{"class":576},[864],{"type":30,"tagName":574,"properties":865,"children":866},{"style":805},[867],{"type":26,"value":868},"// The developing value, opt-in and clearly labeled: it moves with every bar inside the bucket.",{"type":26,"value":27},{"type":30,"tagName":574,"properties":871,"children":872},{"class":576},[873,877,881,886,890,895,899,903,907,912],{"type":30,"tagName":574,"properties":874,"children":875},{"style":694},[876],{"type":26,"value":817},{"type":30,"tagName":574,"properties":878,"children":879},{"style":586},[880],{"type":26,"value":702},{"type":30,"tagName":574,"properties":882,"children":883},{"style":597},[884],{"type":26,"value":885},"\"h4_developing\"",{"type":30,"tagName":574,"properties":887,"children":888},{"style":586},[889],{"type":26,"value":831},{"type":30,"tagName":574,"properties":891,"children":892},{"style":597},[893],{"type":26,"value":894},"\"#16a34a\"",{"type":30,"tagName":574,"properties":896,"children":897},{"style":586},[898],{"type":26,"value":841},{"type":30,"tagName":574,"properties":900,"children":901},{"style":715},[902],{"type":26,"value":728},{"type":30,"tagName":574,"properties":904,"children":905},{"style":586},[906],{"type":26,"value":743},{"type":30,"tagName":574,"properties":908,"children":909},{"style":597},[910],{"type":26,"value":911},"\"The forming 4h candle's running close (repaints by design)\"",{"type":30,"tagName":574,"properties":913,"children":914},{"style":586},[915],{"type":26,"value":753},{"type":26,"value":27},{"type":30,"tagName":574,"properties":918,"children":919},{"class":576},[920,924,928,932,936,941,945,949,953,958],{"type":30,"tagName":574,"properties":921,"children":922},{"style":694},[923],{"type":26,"value":817},{"type":30,"tagName":574,"properties":925,"children":926},{"style":586},[927],{"type":26,"value":702},{"type":30,"tagName":574,"properties":929,"children":930},{"style":597},[931],{"type":26,"value":771},{"type":30,"tagName":574,"properties":933,"children":934},{"style":586},[935],{"type":26,"value":831},{"type":30,"tagName":574,"properties":937,"children":938},{"style":597},[939],{"type":26,"value":940},"\"#94a3b8\"",{"type":30,"tagName":574,"properties":942,"children":943},{"style":586},[944],{"type":26,"value":841},{"type":30,"tagName":574,"properties":946,"children":947},{"style":715},[948],{"type":26,"value":728},{"type":30,"tagName":574,"properties":950,"children":951},{"style":586},[952],{"type":26,"value":743},{"type":30,"tagName":574,"properties":954,"children":955},{"style":597},[956],{"type":26,"value":957},"\"The chart-timeframe close for comparison\"",{"type":30,"tagName":574,"properties":959,"children":960},{"style":586},[961],{"type":26,"value":753},{"type":26,"value":27},{"type":30,"tagName":574,"properties":964,"children":965},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":968,"children":969},{"class":576},[970,975,980,985,990,995,1000],{"type":30,"tagName":574,"properties":971,"children":972},{"style":580},[973],{"type":26,"value":974},"let",{"type":30,"tagName":574,"properties":976,"children":977},{"style":586},[978],{"type":26,"value":979}," bucketSec",{"type":30,"tagName":574,"properties":981,"children":982},{"style":580},[983],{"type":26,"value":984},":",{"type":30,"tagName":574,"properties":986,"children":987},{"style":694},[988],{"type":26,"value":989}," f64",{"type":30,"tagName":574,"properties":991,"children":992},{"style":580},[993],{"type":26,"value":994}," =",{"type":30,"tagName":574,"properties":996,"children":997},{"style":715},[998],{"type":26,"value":999}," 14400.0",{"type":30,"tagName":574,"properties":1001,"children":1002},{"style":586},[1003],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1006,"children":1007},{"class":576},[1008,1012,1017,1021,1025,1029,1034,1039],{"type":30,"tagName":574,"properties":1009,"children":1010},{"style":580},[1011],{"type":26,"value":974},{"type":30,"tagName":574,"properties":1013,"children":1014},{"style":586},[1015],{"type":26,"value":1016}," bucket",{"type":30,"tagName":574,"properties":1018,"children":1019},{"style":580},[1020],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1022,"children":1023},{"style":694},[1024],{"type":26,"value":989},{"type":30,"tagName":574,"properties":1026,"children":1027},{"style":580},[1028],{"type":26,"value":994},{"type":30,"tagName":574,"properties":1030,"children":1031},{"style":715},[1032],{"type":26,"value":1033}," NaN",{"type":30,"tagName":574,"properties":1035,"children":1036},{"style":586},[1037],{"type":26,"value":1038},"; ",{"type":30,"tagName":574,"properties":1040,"children":1041},{"style":805},[1042],{"type":26,"value":1043},"// the bucket the running candle belongs to",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1046,"children":1047},{"class":576},[1048,1052,1057,1061,1065,1069,1073,1077],{"type":30,"tagName":574,"properties":1049,"children":1050},{"style":580},[1051],{"type":26,"value":974},{"type":30,"tagName":574,"properties":1053,"children":1054},{"style":586},[1055],{"type":26,"value":1056}," running",{"type":30,"tagName":574,"properties":1058,"children":1059},{"style":580},[1060],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1062,"children":1063},{"style":694},[1064],{"type":26,"value":989},{"type":30,"tagName":574,"properties":1066,"children":1067},{"style":580},[1068],{"type":26,"value":994},{"type":30,"tagName":574,"properties":1070,"children":1071},{"style":715},[1072],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1074,"children":1075},{"style":586},[1076],{"type":26,"value":1038},{"type":30,"tagName":574,"properties":1078,"children":1079},{"style":805},[1080],{"type":26,"value":1081},"// the running candle's latest close (developing)",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1084,"children":1085},{"class":576},[1086,1090,1095,1099,1103,1107,1111,1115],{"type":30,"tagName":574,"properties":1087,"children":1088},{"style":580},[1089],{"type":26,"value":974},{"type":30,"tagName":574,"properties":1091,"children":1092},{"style":586},[1093],{"type":26,"value":1094}," confirmed",{"type":30,"tagName":574,"properties":1096,"children":1097},{"style":580},[1098],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1100,"children":1101},{"style":694},[1102],{"type":26,"value":989},{"type":30,"tagName":574,"properties":1104,"children":1105},{"style":580},[1106],{"type":26,"value":994},{"type":30,"tagName":574,"properties":1108,"children":1109},{"style":715},[1110],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1112,"children":1113},{"style":586},[1114],{"type":26,"value":1038},{"type":30,"tagName":574,"properties":1116,"children":1117},{"style":805},[1118],{"type":26,"value":1119},"// the last CLOSED candle's close",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1122,"children":1123},{"class":576},[1124,1128,1133,1137,1141,1145,1149],{"type":30,"tagName":574,"properties":1125,"children":1126},{"style":580},[1127],{"type":26,"value":974},{"type":30,"tagName":574,"properties":1129,"children":1130},{"style":586},[1131],{"type":26,"value":1132}," close",{"type":30,"tagName":574,"properties":1134,"children":1135},{"style":580},[1136],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1138,"children":1139},{"style":694},[1140],{"type":26,"value":989},{"type":30,"tagName":574,"properties":1142,"children":1143},{"style":580},[1144],{"type":26,"value":994},{"type":30,"tagName":574,"properties":1146,"children":1147},{"style":715},[1148],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1150,"children":1151},{"style":586},[1152],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1155,"children":1156},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":1159,"children":1160},{"class":576},[1161,1166,1171,1176,1181,1185,1190],{"type":30,"tagName":574,"properties":1162,"children":1163},{"style":580},[1164],{"type":26,"value":1165},"export",{"type":30,"tagName":574,"properties":1167,"children":1168},{"style":580},[1169],{"type":26,"value":1170}," function",{"type":30,"tagName":574,"properties":1172,"children":1173},{"style":694},[1174],{"type":26,"value":1175}," init",{"type":30,"tagName":574,"properties":1177,"children":1178},{"style":586},[1179],{"type":26,"value":1180},"()",{"type":30,"tagName":574,"properties":1182,"children":1183},{"style":580},[1184],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1186,"children":1187},{"style":715},[1188],{"type":26,"value":1189}," void",{"type":30,"tagName":574,"properties":1191,"children":1192},{"style":586},[1193],{"type":26,"value":1194}," {",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1197,"children":1198},{"class":576},[1199,1204,1209,1214,1219,1224,1229],{"type":30,"tagName":574,"properties":1200,"children":1201},{"style":586},[1202],{"type":26,"value":1203},"  bucketSec ",{"type":30,"tagName":574,"properties":1205,"children":1206},{"style":580},[1207],{"type":26,"value":1208},"=",{"type":30,"tagName":574,"properties":1210,"children":1211},{"style":694},[1212],{"type":26,"value":1213}," p_bucket_hours",{"type":30,"tagName":574,"properties":1215,"children":1216},{"style":586},[1217],{"type":26,"value":1218},"() ",{"type":30,"tagName":574,"properties":1220,"children":1221},{"style":580},[1222],{"type":26,"value":1223},"*",{"type":30,"tagName":574,"properties":1225,"children":1226},{"style":715},[1227],{"type":26,"value":1228}," 3600.0",{"type":30,"tagName":574,"properties":1230,"children":1231},{"style":586},[1232],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1235,"children":1236},{"class":576},[1237],{"type":30,"tagName":574,"properties":1238,"children":1239},{"style":586},[1240],{"type":26,"value":1241},"}",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1244,"children":1245},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":1248,"children":1249},{"class":576},[1250,1254,1258,1263,1267,1271,1276],{"type":30,"tagName":574,"properties":1251,"children":1252},{"style":580},[1253],{"type":26,"value":1165},{"type":30,"tagName":574,"properties":1255,"children":1256},{"style":580},[1257],{"type":26,"value":1170},{"type":30,"tagName":574,"properties":1259,"children":1260},{"style":694},[1261],{"type":26,"value":1262}," state",{"type":30,"tagName":574,"properties":1264,"children":1265},{"style":586},[1266],{"type":26,"value":1180},{"type":30,"tagName":574,"properties":1268,"children":1269},{"style":580},[1270],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1272,"children":1273},{"style":694},[1274],{"type":26,"value":1275}," i32",{"type":30,"tagName":574,"properties":1277,"children":1278},{"style":586},[1279],{"type":26,"value":1194},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1282,"children":1283},{"class":576},[1284,1289,1293,1298],{"type":30,"tagName":574,"properties":1285,"children":1286},{"style":586},[1287],{"type":26,"value":1288},"  close ",{"type":30,"tagName":574,"properties":1290,"children":1291},{"style":580},[1292],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1294,"children":1295},{"style":694},[1296],{"type":26,"value":1297}," in_close",{"type":30,"tagName":574,"properties":1299,"children":1300},{"style":586},[1301],{"type":26,"value":1302},"();",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1305,"children":1306},{"class":576},[1307,1312,1317,1321,1326,1331,1335,1340,1344,1349],{"type":30,"tagName":574,"properties":1308,"children":1309},{"style":580},[1310],{"type":26,"value":1311},"  const",{"type":30,"tagName":574,"properties":1313,"children":1314},{"style":715},[1315],{"type":26,"value":1316}," b",{"type":30,"tagName":574,"properties":1318,"children":1319},{"style":580},[1320],{"type":26,"value":994},{"type":30,"tagName":574,"properties":1322,"children":1323},{"style":586},[1324],{"type":26,"value":1325}," Math.",{"type":30,"tagName":574,"properties":1327,"children":1328},{"style":694},[1329],{"type":26,"value":1330},"floor",{"type":30,"tagName":574,"properties":1332,"children":1333},{"style":586},[1334],{"type":26,"value":702},{"type":30,"tagName":574,"properties":1336,"children":1337},{"style":694},[1338],{"type":26,"value":1339},"in_bar_t",{"type":30,"tagName":574,"properties":1341,"children":1342},{"style":586},[1343],{"type":26,"value":1218},{"type":30,"tagName":574,"properties":1345,"children":1346},{"style":580},[1347],{"type":26,"value":1348},"/",{"type":30,"tagName":574,"properties":1350,"children":1351},{"style":586},[1352],{"type":26,"value":1353}," bucketSec);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1356,"children":1357},{"class":576},[1358,1363,1368,1373],{"type":30,"tagName":574,"properties":1359,"children":1360},{"style":580},[1361],{"type":26,"value":1362},"  if",{"type":30,"tagName":574,"properties":1364,"children":1365},{"style":586},[1366],{"type":26,"value":1367}," (b ",{"type":30,"tagName":574,"properties":1369,"children":1370},{"style":580},[1371],{"type":26,"value":1372},"!=",{"type":30,"tagName":574,"properties":1374,"children":1375},{"style":586},[1376],{"type":26,"value":1377}," bucket) {",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1380,"children":1381},{"class":576},[1382],{"type":30,"tagName":574,"properties":1383,"children":1384},{"style":805},[1385],{"type":26,"value":1386},"    // A bar from the next bucket has arrived: the running candle is now closed, and only now is it confirmed.",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1389,"children":1390},{"class":576},[1391,1396,1401,1406,1411,1416,1420],{"type":30,"tagName":574,"properties":1392,"children":1393},{"style":580},[1394],{"type":26,"value":1395},"    if",{"type":30,"tagName":574,"properties":1397,"children":1398},{"style":586},[1399],{"type":26,"value":1400}," (",{"type":30,"tagName":574,"properties":1402,"children":1403},{"style":580},[1404],{"type":26,"value":1405},"!",{"type":30,"tagName":574,"properties":1407,"children":1408},{"style":694},[1409],{"type":26,"value":1410},"isNaN",{"type":30,"tagName":574,"properties":1412,"children":1413},{"style":586},[1414],{"type":26,"value":1415},"(bucket)) confirmed ",{"type":30,"tagName":574,"properties":1417,"children":1418},{"style":580},[1419],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1421,"children":1422},{"style":586},[1423],{"type":26,"value":1424}," running;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1427,"children":1428},{"class":576},[1429,1434,1438],{"type":30,"tagName":574,"properties":1430,"children":1431},{"style":586},[1432],{"type":26,"value":1433},"    bucket ",{"type":30,"tagName":574,"properties":1435,"children":1436},{"style":580},[1437],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1439,"children":1440},{"style":586},[1441],{"type":26,"value":1442}," b;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1445,"children":1446},{"class":576},[1447],{"type":30,"tagName":574,"properties":1448,"children":1449},{"style":586},[1450],{"type":26,"value":1451},"  }",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1454,"children":1455},{"class":576},[1456,1461,1465],{"type":30,"tagName":574,"properties":1457,"children":1458},{"style":586},[1459],{"type":26,"value":1460},"  running ",{"type":30,"tagName":574,"properties":1462,"children":1463},{"style":580},[1464],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1466,"children":1467},{"style":586},[1468],{"type":26,"value":1469}," close;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1472,"children":1473},{"class":576},[1474,1479,1484,1489,1494,1499,1504,1509],{"type":30,"tagName":574,"properties":1475,"children":1476},{"style":580},[1477],{"type":26,"value":1478},"  return",{"type":30,"tagName":574,"properties":1480,"children":1481},{"style":694},[1482],{"type":26,"value":1483}," isNaN",{"type":30,"tagName":574,"properties":1485,"children":1486},{"style":586},[1487],{"type":26,"value":1488},"(confirmed) ",{"type":30,"tagName":574,"properties":1490,"children":1491},{"style":580},[1492],{"type":26,"value":1493},"?",{"type":30,"tagName":574,"properties":1495,"children":1496},{"style":715},[1497],{"type":26,"value":1498}," 0",{"type":30,"tagName":574,"properties":1500,"children":1501},{"style":580},[1502],{"type":26,"value":1503}," :",{"type":30,"tagName":574,"properties":1505,"children":1506},{"style":715},[1507],{"type":26,"value":1508}," 1",{"type":30,"tagName":574,"properties":1510,"children":1511},{"style":586},[1512],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1515,"children":1516},{"class":576},[1517],{"type":30,"tagName":574,"properties":1518,"children":1519},{"style":586},[1520],{"type":26,"value":1241},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1523,"children":1524},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":1527,"children":1528},{"class":576},[1529,1533,1537,1542,1546,1550,1554],{"type":30,"tagName":574,"properties":1530,"children":1531},{"style":580},[1532],{"type":26,"value":1165},{"type":30,"tagName":574,"properties":1534,"children":1535},{"style":580},[1536],{"type":26,"value":1170},{"type":30,"tagName":574,"properties":1538,"children":1539},{"style":694},[1540],{"type":26,"value":1541}," finalize",{"type":30,"tagName":574,"properties":1543,"children":1544},{"style":586},[1545],{"type":26,"value":1180},{"type":30,"tagName":574,"properties":1547,"children":1548},{"style":580},[1549],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1551,"children":1552},{"style":715},[1553],{"type":26,"value":1189},{"type":30,"tagName":574,"properties":1555,"children":1556},{"style":586},[1557],{"type":26,"value":1194},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1560,"children":1561},{"class":576},[1562,1567],{"type":30,"tagName":574,"properties":1563,"children":1564},{"style":694},[1565],{"type":26,"value":1566},"  out_h4_close",{"type":30,"tagName":574,"properties":1568,"children":1569},{"style":586},[1570],{"type":26,"value":1571},"(confirmed);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1574,"children":1575},{"class":576},[1576,1581],{"type":30,"tagName":574,"properties":1577,"children":1578},{"style":694},[1579],{"type":26,"value":1580},"  out_h4_developing",{"type":30,"tagName":574,"properties":1582,"children":1583},{"style":586},[1584],{"type":26,"value":1585},"(running);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1588,"children":1589},{"class":576},[1590,1595],{"type":30,"tagName":574,"properties":1591,"children":1592},{"style":694},[1593],{"type":26,"value":1594},"  out_close",{"type":30,"tagName":574,"properties":1596,"children":1597},{"style":586},[1598],{"type":26,"value":1599},"(close);",{"type":26,"value":27},{"type":30,"tagName":574,"properties":1602,"children":1603},{"class":576},[1604,1609],{"type":30,"tagName":574,"properties":1605,"children":1606},{"style":694},[1607],{"type":26,"value":1608},"  emitRow",{"type":30,"tagName":574,"properties":1610,"children":1611},{"style":586},[1612],{"type":26,"value":1302},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1615,"children":1616},{"class":576},[1617],{"type":30,"tagName":574,"properties":1618,"children":1619},{"style":586},[1620],{"type":26,"value":1241},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1623,"children":1624},{"class":576},[],{"type":26,"value":27},{"type":30,"tagName":574,"properties":1627,"children":1628},{"class":576},[1629,1633,1637,1642,1646,1650,1654],{"type":30,"tagName":574,"properties":1630,"children":1631},{"style":580},[1632],{"type":26,"value":1165},{"type":30,"tagName":574,"properties":1634,"children":1635},{"style":580},[1636],{"type":26,"value":1170},{"type":30,"tagName":574,"properties":1638,"children":1639},{"style":694},[1640],{"type":26,"value":1641}," reset",{"type":30,"tagName":574,"properties":1643,"children":1644},{"style":586},[1645],{"type":26,"value":1180},{"type":30,"tagName":574,"properties":1647,"children":1648},{"style":580},[1649],{"type":26,"value":984},{"type":30,"tagName":574,"properties":1651,"children":1652},{"style":715},[1653],{"type":26,"value":1189},{"type":30,"tagName":574,"properties":1655,"children":1656},{"style":586},[1657],{"type":26,"value":1194},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1660,"children":1661},{"class":576},[1662,1667,1671,1675],{"type":30,"tagName":574,"properties":1663,"children":1664},{"style":586},[1665],{"type":26,"value":1666},"  bucket ",{"type":30,"tagName":574,"properties":1668,"children":1669},{"style":580},[1670],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1672,"children":1673},{"style":715},[1674],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1676,"children":1677},{"style":586},[1678],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1681,"children":1682},{"class":576},[1683,1687,1691,1695],{"type":30,"tagName":574,"properties":1684,"children":1685},{"style":586},[1686],{"type":26,"value":1460},{"type":30,"tagName":574,"properties":1688,"children":1689},{"style":580},[1690],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1692,"children":1693},{"style":715},[1694],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1696,"children":1697},{"style":586},[1698],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1701,"children":1702},{"class":576},[1703,1708,1712,1716],{"type":30,"tagName":574,"properties":1704,"children":1705},{"style":586},[1706],{"type":26,"value":1707},"  confirmed ",{"type":30,"tagName":574,"properties":1709,"children":1710},{"style":580},[1711],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1713,"children":1714},{"style":715},[1715],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1717,"children":1718},{"style":586},[1719],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1722,"children":1723},{"class":576},[1724,1728,1732,1736],{"type":30,"tagName":574,"properties":1725,"children":1726},{"style":586},[1727],{"type":26,"value":1288},{"type":30,"tagName":574,"properties":1729,"children":1730},{"style":580},[1731],{"type":26,"value":1208},{"type":30,"tagName":574,"properties":1733,"children":1734},{"style":715},[1735],{"type":26,"value":1033},{"type":30,"tagName":574,"properties":1737,"children":1738},{"style":586},[1739],{"type":26,"value":605},{"type":26,"value":27},{"type":30,"tagName":574,"properties":1742,"children":1743},{"class":576},[1744],{"type":30,"tagName":574,"properties":1745,"children":1746},{"style":586},[1747],{"type":26,"value":1241},{"type":26,"value":27},{"type":30,"tagName":1750,"properties":1751,"children":1753,"position":1762},"h3",{"id":1752},"read-the-staircase",[1754],{"type":26,"value":1755,"position":1756},"Read the staircase",{"start":1757,"end":1760},{"line":1758,"column":38,"offset":1759},122,5292,{"line":1758,"column":197,"offset":1761},5310,{"start":1763,"end":1765},{"line":1758,"column":20,"offset":1764},5288,{"line":1758,"column":197,"offset":1761},{"type":26,"value":27},{"type":30,"tagName":31,"properties":1768,"children":1769,"position":1816},{},[1770,1778,1790,1797,1809],{"type":26,"value":1771,"position":1772},"The purple ",{"start":1773,"end":1776},{"line":1774,"column":20,"offset":1775},124,5312,{"line":1774,"column":146,"offset":1777},5323,{"type":30,"tagName":45,"properties":1779,"children":1780,"position":1787},{},[1781],{"type":26,"value":1782,"position":1783},"h4_close",{"start":1784,"end":1785},{"line":1774,"column":146,"offset":1777},{"line":1774,"column":166,"offset":1786},5333,{"start":1788,"end":1789},{"line":1774,"column":146,"offset":1777},{"line":1774,"column":166,"offset":1786},{"type":26,"value":1791,"position":1792}," line is flat across four 1h bars, then steps to a new\nlevel, then holds flat again. That staircase is the visual signature of a\ncorrect, confirmed higher timeframe: the value only changes when a 4h\ncandle actually closes, and between closes there is no new confirmed\ninformation. The green ",{"start":1793,"end":1794},{"line":1774,"column":166,"offset":1786},{"line":1795,"column":9,"offset":1796},128,5624,{"type":30,"tagName":45,"properties":1798,"children":1799,"position":1806},{},[1800],{"type":26,"value":1801,"position":1802},"h4_developing",{"start":1803,"end":1804},{"line":1795,"column":9,"offset":1796},{"line":1795,"column":305,"offset":1805},5639,{"start":1807,"end":1808},{"line":1795,"column":9,"offset":1796},{"line":1795,"column":305,"offset":1805},{"type":26,"value":1810,"position":1811}," line tracks the grey chart close\ninside each bucket: that is what a repainting value looks like, and it is\ndrawn here on purpose so you can see the difference. A cross built on the\ngreen line would not survive into production; a cross built on the purple\none reproduces exactly.",{"start":1812,"end":1813},{"line":1795,"column":305,"offset":1805},{"line":1814,"column":9,"offset":1815},132,5918,{"start":1817,"end":1818},{"line":1774,"column":20,"offset":1775},{"line":1814,"column":9,"offset":1815},{"type":26,"value":27},{"type":30,"tagName":154,"properties":1821,"children":1823,"position":1832},{"id":1822},"requesting-a-live-value-is-opt-in",[1824],{"type":26,"value":1825,"position":1826},"Requesting a live value is opt-in",{"start":1827,"end":1830},{"line":1828,"column":163,"offset":1829},134,5923,{"line":1828,"column":126,"offset":1831},5956,{"start":1833,"end":1835},{"line":1828,"column":20,"offset":1834},5920,{"line":1828,"column":126,"offset":1831},{"type":26,"value":27},{"type":30,"tagName":31,"properties":1838,"children":1839,"position":1929},{},[1840,1849,1861,1868,1880,1887,1902,1908,1922],{"type":26,"value":1841,"position":1842},"Sometimes you genuinely want the forming bucket: a live 4h close ticking in\na readout. In a module that is just the running variable, as above, and it\nis a deliberate choice you make by reading ",{"start":1843,"end":1846},{"line":1844,"column":20,"offset":1845},136,5958,{"line":1847,"column":136,"offset":1848},138,6152,{"type":30,"tagName":45,"properties":1850,"children":1851,"position":1858},{},[1852],{"type":26,"value":1853,"position":1854},"running",{"start":1855,"end":1856},{"line":1847,"column":136,"offset":1848},{"line":1847,"column":439,"offset":1857},6161,{"start":1859,"end":1860},{"line":1847,"column":136,"offset":1848},{"line":1847,"column":439,"offset":1857},{"type":26,"value":1862,"position":1863}," instead of\n",{"start":1864,"end":1865},{"line":1847,"column":439,"offset":1857},{"line":1866,"column":20,"offset":1867},139,6173,{"type":30,"tagName":45,"properties":1869,"children":1870,"position":1877},{},[1871],{"type":26,"value":1872,"position":1873},"confirmed",{"start":1874,"end":1875},{"line":1866,"column":20,"offset":1867},{"line":1866,"column":146,"offset":1876},6184,{"start":1878,"end":1879},{"line":1866,"column":20,"offset":1867},{"line":1866,"column":146,"offset":1876},{"type":26,"value":1881,"position":1882},". A developing value is fine for a display; it is the wrong\nthing for a signal, because it changes as the bucket fills, so a cross or\nthreshold built on it will not reproduce on history. Reach for it only when\nyou want to ",{"start":1883,"end":1884},{"line":1866,"column":146,"offset":1876},{"line":1885,"column":184,"offset":1886},142,6406,{"type":30,"tagName":442,"properties":1888,"children":1889,"position":1897},{},[1890],{"type":26,"value":1891,"position":1892},"show",{"start":1893,"end":1895},{"line":1885,"column":162,"offset":1894},6407,{"line":1885,"column":216,"offset":1896},6411,{"start":1898,"end":1899},{"line":1885,"column":184,"offset":1886},{"line":1885,"column":1900,"offset":1901},19,6412,{"type":26,"value":1903,"position":1904}," the live edge, never when you want to ",{"start":1905,"end":1906},{"line":1885,"column":1900,"offset":1901},{"line":1885,"column":463,"offset":1907},6451,{"type":30,"tagName":442,"properties":1909,"children":1910,"position":1918},{},[1911],{"type":26,"value":1912,"position":1913},"act",{"start":1914,"end":1916},{"line":1885,"column":483,"offset":1915},6452,{"line":1885,"column":404,"offset":1917},6455,{"start":1919,"end":1920},{"line":1885,"column":463,"offset":1907},{"line":1885,"column":514,"offset":1921},6456,{"type":26,"value":1923,"position":1924}," on it.",{"start":1925,"end":1926},{"line":1885,"column":514,"offset":1921},{"line":1885,"column":1927,"offset":1928},70,6463,{"start":1930,"end":1931},{"line":1844,"column":20,"offset":1845},{"line":1885,"column":1927,"offset":1928},{"type":26,"value":27},{"type":30,"tagName":154,"properties":1934,"children":1936,"position":1945},{"id":1935},"pins-are-read-as-of-close",[1937],{"type":26,"value":1938,"position":1939},"Pins are read as of close",{"start":1940,"end":1943},{"line":1941,"column":163,"offset":1942},144,6468,{"line":1941,"column":292,"offset":1944},6493,{"start":1946,"end":1948},{"line":1941,"column":20,"offset":1947},6465,{"line":1941,"column":292,"offset":1944},{"type":26,"value":27},{"type":30,"tagName":31,"properties":1951,"children":1952,"position":1999},{},[1953,1960,1971,1978,1991],{"type":26,"value":1954,"position":1955},"On your machine an ",{"start":1956,"end":1958},{"line":39,"column":20,"offset":1957},6495,{"line":39,"column":147,"offset":1959},6514,{"type":30,"tagName":45,"properties":1961,"children":1962,"position":1968},{},[1963],{"type":26,"value":70,"position":1964},{"start":1965,"end":1966},{"line":39,"column":147,"offset":1959},{"line":39,"column":230,"offset":1967},6524,{"start":1969,"end":1970},{"line":39,"column":147,"offset":1959},{"line":39,"column":230,"offset":1967},{"type":26,"value":1972,"position":1973}," pin reads a real coarser feed and the host\napplies the same rule for you: a coarser source contributes to a primary\nrow only as of its candle's CLOSE, live or historical, so a forming 4h\ncandle never leaks into the 1h rows under it (",{"start":1974,"end":1975},{"line":39,"column":230,"offset":1967},{"line":1976,"column":374,"offset":1977},149,6758,{"type":30,"tagName":45,"properties":1979,"children":1980,"position":1988},{},[1981],{"type":26,"value":1982,"position":1983},"multi-timeframe.md",{"start":1984,"end":1985},{"line":1976,"column":374,"offset":1977},{"line":1976,"column":1986,"offset":1987},67,6778,{"start":1989,"end":1990},{"line":1976,"column":374,"offset":1977},{"line":1976,"column":1986,"offset":1987},{"type":26,"value":1992,"position":1993},"). The\ncost is a value that steps once per source candle: the same staircase.",{"start":1994,"end":1995},{"line":1976,"column":1986,"offset":1987},{"line":1996,"column":1997,"offset":1998},150,71,6855,{"start":2000,"end":2001},{"line":39,"column":20,"offset":1957},{"line":1996,"column":1997,"offset":1998},{"type":26,"value":27},{"type":30,"tagName":154,"properties":2004,"children":2006,"position":2026},{"id":2005},"the-forming-bar-and-reset",[2007,2015],{"type":26,"value":2008,"position":2009},"The forming bar and ",{"start":2010,"end":2013},{"line":2011,"column":163,"offset":2012},152,6860,{"line":2011,"column":9,"offset":2014},6880,{"type":30,"tagName":45,"properties":2016,"children":2017,"position":2023},{},[2018],{"type":26,"value":91,"position":2019},{"start":2020,"end":2021},{"line":2011,"column":9,"offset":2014},{"line":2011,"column":484,"offset":2022},6889,{"start":2024,"end":2025},{"line":2011,"column":9,"offset":2014},{"line":2011,"column":484,"offset":2022},{"start":2027,"end":2029},{"line":2011,"column":20,"offset":2028},6857,{"line":2011,"column":484,"offset":2022},{"type":26,"value":27},{"type":30,"tagName":31,"properties":2032,"children":2033,"position":2061},{},[2034,2043,2054],{"type":26,"value":2035,"position":2036},"The forming bar is the one exception to \"one call per bar\": it re-evaluates\non every tick. The host does not re-run history for that; it snapshots the\nmodule after the last closed bar and replays the revised forming bar into\nthe snapshot. Because the snapshot holds every module-level variable, the\nmodule's ",{"start":2037,"end":2040},{"line":2038,"column":20,"offset":2039},154,6891,{"line":2041,"column":393,"offset":2042},158,7199,{"type":30,"tagName":45,"properties":2044,"children":2045,"position":2051},{},[2046],{"type":26,"value":91,"position":2047},{"start":2048,"end":2049},{"line":2041,"column":393,"offset":2042},{"line":2041,"column":1900,"offset":2050},7208,{"start":2052,"end":2053},{"line":2041,"column":393,"offset":2042},{"line":2041,"column":1900,"offset":2050},{"type":26,"value":2055,"position":2056}," is what puts the state back before each replay, and a\nstale field is the one way an Indicator repaints:",{"start":2057,"end":2058},{"line":2041,"column":1900,"offset":2050},{"line":2059,"column":390,"offset":2060},159,7312,{"start":2062,"end":2063},{"line":2038,"column":20,"offset":2039},{"line":2059,"column":390,"offset":2060},{"type":26,"value":27},{"type":13,"children":2066},[2067],{"type":30,"tagName":564,"properties":2068,"children":2069,"data":-1},{"class":566,"style":567,"tabindex":568},[2070],{"type":30,"tagName":45,"properties":2071,"children":2072},{},[2073,2081,2082,2090,2091,2099,2100,2108,2109,2117,2118,2126,2127,2135,2136,2144,2145],{"type":30,"tagName":574,"properties":2074,"children":2075},{"class":576},[2076],{"type":30,"tagName":574,"properties":2077,"children":2078},{},[2079],{"type":26,"value":2080},"let barsSeen: f64 = 0.0;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2083,"children":2084},{"class":576},[2085],{"type":30,"tagName":574,"properties":2086,"children":2087},{},[2088],{"type":26,"value":2089},"let cvd: f64 = 0.0;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2092,"children":2093},{"class":576},[2094],{"type":30,"tagName":574,"properties":2095,"children":2096},{},[2097],{"type":26,"value":2098},"",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2101,"children":2102},{"class":576},[2103],{"type":30,"tagName":574,"properties":2104,"children":2105},{},[2106],{"type":26,"value":2107},"export function reset(): void {",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2110,"children":2111},{"class":576},[2112],{"type":30,"tagName":574,"properties":2113,"children":2114},{},[2115],{"type":26,"value":2116},"  cvd = 0.0;",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2119,"children":2120},{"class":576},[2121],{"type":30,"tagName":574,"properties":2122,"children":2123},{},[2124],{"type":26,"value":2125},"  // barsSeen is not reset: the forming bar's replays keep incrementing it,",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2128,"children":2129},{"class":576},[2130],{"type":30,"tagName":574,"properties":2131,"children":2132},{},[2133],{"type":26,"value":2134},"  // so the newest row reads 1, then 2, then 3 as ticks arrive, and history",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2137,"children":2138},{"class":576},[2139],{"type":30,"tagName":574,"properties":2140,"children":2141},{},[2142],{"type":26,"value":2143},"  // (which counted it once) will never show those values.",{"type":26,"value":27},{"type":30,"tagName":574,"properties":2146,"children":2147},{"class":576},[2148],{"type":30,"tagName":574,"properties":2149,"children":2150},{},[2151],{"type":26,"value":1241},{"type":26,"value":27},{"type":30,"tagName":31,"properties":2154,"children":2155,"position":2254},{},[2156,2164,2175,2181,2193,2200,2212,2218,2229,2236,2247],{"type":26,"value":2157,"position":2158},"Every module-level ",{"start":2159,"end":2162},{"line":2160,"column":20,"offset":2161},173,7631,{"line":2160,"column":147,"offset":2163},7650,{"type":30,"tagName":45,"properties":2165,"children":2166,"position":2172},{},[2167],{"type":26,"value":974,"position":2168},{"start":2169,"end":2170},{"line":2160,"column":147,"offset":2163},{"line":2160,"column":306,"offset":2171},7655,{"start":2173,"end":2174},{"line":2160,"column":147,"offset":2163},{"line":2160,"column":306,"offset":2171},{"type":26,"value":2176,"position":2177}," is reassigned in ",{"start":2178,"end":2179},{"line":2160,"column":306,"offset":2171},{"line":2160,"column":266,"offset":2180},7673,{"type":30,"tagName":45,"properties":2182,"children":2183,"position":2190},{},[2184],{"type":26,"value":91,"position":2185},{"start":2186,"end":2187},{"line":2160,"column":266,"offset":2180},{"line":2160,"column":2188,"offset":2189},52,7682,{"start":2191,"end":2192},{"line":2160,"column":266,"offset":2180},{"line":2160,"column":2188,"offset":2189},{"type":26,"value":2194,"position":2195},", every TA object gets\n",{"start":2196,"end":2197},{"line":2160,"column":2188,"offset":2189},{"line":2198,"column":20,"offset":2199},174,7705,{"type":30,"tagName":45,"properties":2201,"children":2202,"position":2209},{},[2203],{"type":26,"value":2204,"position":2205},".reset()",{"start":2206,"end":2207},{"line":2198,"column":20,"offset":2199},{"line":2198,"column":125,"offset":2208},7715,{"start":2210,"end":2211},{"line":2198,"column":20,"offset":2199},{"line":2198,"column":125,"offset":2208},{"type":26,"value":2213,"position":2214},", and a class you wrote gets a ",{"start":2215,"end":2216},{"line":2198,"column":125,"offset":2208},{"line":2198,"column":337,"offset":2217},7746,{"type":30,"tagName":45,"properties":2219,"children":2220,"position":2226},{},[2221],{"type":26,"value":91,"position":2222},{"start":2223,"end":2224},{"line":2198,"column":337,"offset":2217},{"line":2198,"column":403,"offset":2225},7755,{"start":2227,"end":2228},{"line":2198,"column":337,"offset":2217},{"line":2198,"column":403,"offset":2225},{"type":26,"value":2230,"position":2231}," of its own. Allocation\ndoes not belong there (the module never frees memory; reset the fields in\nplace). If a value on the newest bar drifts as you watch it while the\nclosed bars stay put, ",{"start":2232,"end":2233},{"line":2198,"column":403,"offset":2225},{"line":2234,"column":197,"offset":2235},177,7945,{"type":30,"tagName":45,"properties":2237,"children":2238,"position":2244},{},[2239],{"type":26,"value":91,"position":2240},{"start":2241,"end":2242},{"line":2234,"column":197,"offset":2235},{"line":2234,"column":233,"offset":2243},7954,{"start":2245,"end":2246},{"line":2234,"column":197,"offset":2235},{"line":2234,"column":233,"offset":2243},{"type":26,"value":2248,"position":2249}," is the first place to look.",{"start":2250,"end":2251},{"line":2234,"column":233,"offset":2243},{"line":2234,"column":2252,"offset":2253},60,7982,{"start":2255,"end":2256},{"line":2160,"column":20,"offset":2161},{"line":2234,"column":2252,"offset":2253},{"type":26,"value":27},{"type":30,"tagName":154,"properties":2259,"children":2261,"position":2270},{"id":2260},"the-host-decides-which-bars-the-module-sees",[2262],{"type":26,"value":2263,"position":2264},"The host decides which bars the module sees",{"start":2265,"end":2268},{"line":2266,"column":163,"offset":2267},179,7987,{"line":2266,"column":374,"offset":2269},8030,{"start":2271,"end":2273},{"line":2266,"column":20,"offset":2272},7984,{"line":2266,"column":374,"offset":2269},{"type":26,"value":27},{"type":30,"tagName":31,"properties":2276,"children":2277,"position":2307},{},[2278,2287,2300],{"type":26,"value":2279,"position":2280},"Run-level renderers and drawings are selected from the finished row set\nwith no backward scan (the newest ready row that satisfies the kind's rule\nwins), and they never change a metric value. On your machine ",{"start":2281,"end":2284},{"line":2282,"column":20,"offset":2283},181,8032,{"line":2285,"column":404,"offset":2286},183,8240,{"type":30,"tagName":45,"properties":2288,"children":2289,"position":2297},{},[2290],{"type":26,"value":2291,"position":2292},"om metric series",{"start":2293,"end":2294},{"line":2285,"column":404,"offset":2286},{"line":2295,"column":84,"offset":2296},184,8258,{"start":2298,"end":2299},{"line":2285,"column":404,"offset":2286},{"line":2295,"column":84,"offset":2296},{"type":26,"value":2301,"position":2302}," returns the forming bar as its newest row; bar-evaluated metric\nsignals compute AS OF the last closed primary bar instead, dropping the\nforming rows before the module folds them. The module is the same either\nway.",{"start":2303,"end":2304},{"line":2295,"column":84,"offset":2296},{"line":2305,"column":38,"offset":2306},187,8472,{"start":2308,"end":2309},{"line":2282,"column":20,"offset":2283},{"line":2305,"column":38,"offset":2306},{"type":26,"value":27},{"type":30,"tagName":154,"properties":2312,"children":2314,"position":2323},{"id":2313},"how-to-stay-repaint-safe",[2315],{"type":26,"value":2316,"position":2317},"How to stay repaint-safe",{"start":2318,"end":2321},{"line":2319,"column":163,"offset":2320},189,8477,{"line":2319,"column":213,"offset":2322},8501,{"start":2324,"end":2326},{"line":2319,"column":20,"offset":2325},8474,{"line":2319,"column":213,"offset":2322},{"type":26,"value":27},{"type":30,"tagName":31,"properties":2329,"children":2330,"position":2339},{},[2331],{"type":26,"value":2332,"position":2333},"A short checklist:",{"start":2334,"end":2337},{"line":2335,"column":20,"offset":2336},191,8503,{"line":2335,"column":1900,"offset":2338},8521,{"start":2340,"end":2341},{"line":2335,"column":20,"offset":2336},{"line":2335,"column":1900,"offset":2338},{"type":26,"value":27},{"type":30,"tagName":240,"properties":2344,"children":2345,"position":2471},{},[2346,2347,2377,2378,2408,2409,2439,2440,2470],{"type":26,"value":27},{"type":30,"tagName":245,"properties":2348,"children":2349,"position":2373},{},[2350,2366],{"type":30,"tagName":249,"properties":2351,"children":2352,"position":2361},{},[2353],{"type":26,"value":2354,"position":2355},"Fold higher timeframes on the next bucket.",{"start":2356,"end":2359},{"line":2357,"column":38,"offset":2358},193,8527,{"line":2357,"column":374,"offset":2360},8569,{"start":2362,"end":2364},{"line":2357,"column":263,"offset":2363},8525,{"line":2357,"column":555,"offset":2365},8571,{"type":26,"value":2367,"position":2368}," The confirmed value is the\none you act on; the running value is a readout.",{"start":2369,"end":2370},{"line":2357,"column":555,"offset":2365},{"line":2371,"column":390,"offset":2372},194,8648,{"start":2374,"end":2376},{"line":2357,"column":20,"offset":2375},8523,{"line":2371,"column":390,"offset":2372},{"type":26,"value":27},{"type":30,"tagName":245,"properties":2379,"children":2380,"position":2404},{},[2381,2397],{"type":30,"tagName":249,"properties":2382,"children":2383,"position":2392},{},[2384],{"type":26,"value":2385,"position":2386},"Do not act on the still-forming bar.",{"start":2387,"end":2390},{"line":2388,"column":38,"offset":2389},195,8653,{"line":2388,"column":259,"offset":2391},8689,{"start":2393,"end":2395},{"line":2388,"column":263,"offset":2394},8651,{"line":2388,"column":266,"offset":2396},8691,{"type":26,"value":2398,"position":2399}," Its high, low, and close are\nmoving until it closes. Gate confirmed signals on settled data, or let a\nclosed-bar consumer cut the forming bar for you.",{"start":2400,"end":2401},{"line":2388,"column":266,"offset":2396},{"line":2402,"column":403,"offset":2403},197,8846,{"start":2405,"end":2407},{"line":2388,"column":20,"offset":2406},8649,{"line":2402,"column":403,"offset":2403},{"type":26,"value":27},{"type":30,"tagName":245,"properties":2410,"children":2411,"position":2435},{},[2412,2428],{"type":30,"tagName":249,"properties":2413,"children":2414,"position":2423},{},[2415],{"type":26,"value":2416,"position":2417},"Reset everything.",{"start":2418,"end":2421},{"line":2419,"column":38,"offset":2420},198,8851,{"line":2419,"column":166,"offset":2422},8868,{"start":2424,"end":2426},{"line":2419,"column":263,"offset":2425},8849,{"line":2419,"column":9,"offset":2427},8870,{"type":26,"value":2429,"position":2430}," Every module-level variable, every TA object, every\nclass you wrote. A forgotten field is the one repaint an Indicator can\nhave.",{"start":2431,"end":2432},{"line":2419,"column":9,"offset":2427},{"line":2433,"column":84,"offset":2434},200,9003,{"start":2436,"end":2438},{"line":2419,"column":20,"offset":2437},8847,{"line":2433,"column":84,"offset":2434},{"type":26,"value":27},{"type":30,"tagName":245,"properties":2441,"children":2442,"position":2466},{},[2443,2459],{"type":30,"tagName":249,"properties":2444,"children":2445,"position":2454},{},[2446],{"type":26,"value":2447,"position":2448},"Keep the primary selector-following and the pins honest.",{"start":2449,"end":2452},{"line":2450,"column":38,"offset":2451},201,9008,{"line":2450,"column":498,"offset":2453},9064,{"start":2455,"end":2457},{"line":2450,"column":263,"offset":2456},9006,{"line":2450,"column":514,"offset":2458},9066,{"type":26,"value":2460,"position":2461}," A pinned\ncoarse input is read as of close on your machine; on the chart, pins are\nnot honored and every input is the chart's own interval, so build the\nhigher timeframe with the fold.",{"start":2462,"end":2463},{"line":2450,"column":514,"offset":2458},{"line":2464,"column":256,"offset":2465},204,9256,{"start":2467,"end":2469},{"line":2450,"column":20,"offset":2468},9004,{"line":2464,"column":256,"offset":2465},{"type":26,"value":27},{"start":2472,"end":2473},{"line":2357,"column":20,"offset":2375},{"line":2464,"column":256,"offset":2465},{"type":26,"value":27},{"type":30,"tagName":31,"properties":2476,"children":2477,"position":2504},{},[2478,2486,2497],{"type":26,"value":2479,"position":2480},"Stick to confirmed folds and a complete ",{"start":2481,"end":2484},{"line":2482,"column":20,"offset":2483},206,9258,{"line":2482,"column":259,"offset":2485},9298,{"type":30,"tagName":45,"properties":2487,"children":2488,"position":2494},{},[2489],{"type":26,"value":91,"position":2490},{"start":2491,"end":2492},{"line":2482,"column":259,"offset":2485},{"line":2482,"column":390,"offset":2493},9307,{"start":2495,"end":2496},{"line":2482,"column":259,"offset":2485},{"line":2482,"column":390,"offset":2493},{"type":26,"value":2498,"position":2499}," and your backtest will\nmean something: what you measured on history is what the Indicator would\nhave done live.",{"start":2500,"end":2501},{"line":2482,"column":390,"offset":2493},{"line":2502,"column":180,"offset":2503},208,9419,{"start":2505,"end":2506},{"line":2482,"column":20,"offset":2483},{"line":2502,"column":180,"offset":2503},{"type":26,"value":27},{"type":30,"tagName":154,"properties":2509,"children":2511,"position":2520},{"id":2510},"see-also",[2512],{"type":26,"value":2513,"position":2514},"See also",{"start":2515,"end":2518},{"line":2516,"column":163,"offset":2517},210,9424,{"line":2516,"column":146,"offset":2519},9432,{"start":2521,"end":2523},{"line":2516,"column":20,"offset":2522},9421,{"line":2516,"column":146,"offset":2519},{"type":26,"value":27},{"type":30,"tagName":240,"properties":2526,"children":2527,"position":2612},{},[2528,2529,2578,2579,2611],{"type":26,"value":27},{"type":30,"tagName":245,"properties":2530,"children":2531,"position":2574},{},[2532,2549,2556,2568],{"type":30,"tagName":2533,"properties":2534,"children":2535,"position":2544},"a",{"href":1982},[2536],{"type":26,"value":2537,"position":2538},"Multi-timeframe",{"start":2539,"end":2542},{"line":2540,"column":163,"offset":2541},212,9437,{"line":2540,"column":1900,"offset":2543},9452,{"start":2545,"end":2547},{"line":2540,"column":263,"offset":2546},9436,{"line":2540,"column":323,"offset":2548},9473,{"type":26,"value":2550,"position":2551}," for the full bucket-fold and\n",{"start":2552,"end":2553},{"line":2540,"column":323,"offset":2548},{"line":2554,"column":20,"offset":2555},213,9503,{"type":30,"tagName":45,"properties":2557,"children":2558,"position":2565},{},[2559],{"type":26,"value":70,"position":2560},{"start":2561,"end":2563},{"line":2554,"column":263,"offset":2562},9505,{"line":2554,"column":184,"offset":2564},9515,{"start":2566,"end":2567},{"line":2554,"column":263,"offset":2562},{"line":2554,"column":184,"offset":2564},{"type":26,"value":2569,"position":2570},"-pin story, calendar buckets included.",{"start":2571,"end":2572},{"line":2554,"column":184,"offset":2564},{"line":2554,"column":403,"offset":2573},9553,{"start":2575,"end":2577},{"line":2540,"column":20,"offset":2576},9434,{"line":2554,"column":403,"offset":2573},{"type":26,"value":27},{"type":30,"tagName":245,"properties":2580,"children":2581,"position":2607},{},[2582,2599],{"type":30,"tagName":2533,"properties":2583,"children":2585,"position":2594},{"href":2584},"execution-model.md",[2586],{"type":26,"value":2587,"position":2588},"Execution model",{"start":2589,"end":2592},{"line":2590,"column":163,"offset":2591},214,9557,{"line":2590,"column":1900,"offset":2593},9572,{"start":2595,"end":2597},{"line":2590,"column":263,"offset":2596},9556,{"line":2590,"column":323,"offset":2598},9593,{"type":26,"value":2600,"position":2601}," for the bar loop, warm-up, and the\nthree hosts.",{"start":2602,"end":2603},{"line":2590,"column":323,"offset":2598},{"line":2604,"column":2605,"offset":2606},215,15,9643,{"start":2608,"end":2610},{"line":2590,"column":20,"offset":2609},9554,{"line":2604,"column":2605,"offset":2606},{"type":26,"value":27},{"start":2613,"end":2614},{"line":2540,"column":20,"offset":2576},{"line":2604,"column":2605,"offset":2606},{"quirksMode":2616},false,{"start":2618,"end":2619},{"line":20,"column":20,"offset":21},{"line":2620,"column":20,"offset":2621},216,9644,1790157144642]