Skip to content

Commit 4160b3e

Browse files
committed
Drawing arenas: share records between checkpoint copies so a COOF run costs O(bars)
calc_on_order_fills checkpoints the generated script state at every script bar (pine_scheduler_native.cpp: snapshot at the bar open, restore before the close execution, commit after it, two restores per fill recalculation), and the generated hooks copy each DrawingArena by value. A record is never forgotten -- delete and max_*_count eviction only tombstone it -- so every copy cost O(every drawing ever created) and a drawing COOF run was quadratic in bars (job-2892: ~239 s CPU on NYSE:F 15, ~12,950 s on ETH 15). DrawingArena's records now live in a store that is a vector until the arena is copied, exactly as before, and nothing in a vector is ever shared. A copy is built as blocks of 32 under a 32-way radix trie plus a tail block, and a copy of a block store -- or a store assigned from one -- shares every block; a write clones only the blocks and nodes on its path that another copy still shares. Under the scheduler's sequence the first snapshot copies the vector (O(records), once, at the first bar) and the restore assigns the copy back, so from then on a checkpoint copy or restore is O(1) for records plus O(live) for the order_ deque (at most max_*_count ids), and a script execution pays for the blocks it writes. The generated by-value checkpoint needs no codegen change. An arena that is never copied keeps the vector and inlines only the vector paths; every block path is out of line. Every observable -- ids, liveness, every field of live and dead records, order() (the *.all and eviction order), every pf_* result and exception -- is unchanged. Getters read through a const path that never unshares. Eviction tombstones a record before it leaves order_, so a refused allocation in that write leaves the arena consistent; a moved-from arena is empty and a self-move keeps the arena. Rows: - test_drawing_checkpoint: differential against the pre-lane vector arena (verbatim) over random create/delete/eviction/set_* and every pf_* getter/setter/copy, interleaved with snapshot/restore/commit and arbitrary copy graphs, past three trie levels, every checkpoint compared whole before it is dropped; the scheduler's sequence across a run reset; refused allocations, including partway through copying a block of labels; the cost pins (after the first bar an unchanged checkpoint copies no record and allocates the same for 10,000 and 40,000 records; synth-label-coof's churn copies <= 64 records per execution and the checkpoint steps' bytes stay per-step bounded, N -> 2N ratio <= 2.25). Under AddressSanitizer the random and cost rows run fewer steps (its fake stack made the row take 575 s). - test_coof_drawing_checkpoint_cost: synth-label-coof through the Pine host with calc_on_order_fills and fills, 4,000 vs 8,000 bars, the same bounds on record copies and on what the checkpoint hooks allocate. - test_coof_drawing_rollback_tape: TradingView's coof-drawing-rollback tape (CG-POPFIX, 41 trades) replayed through the Pine host: all 41 trades identical in times, prices, quantities and both comments (x2 == n). Fail-before (the three rows against the old drawing.hpp): every cost pin fails (30,000,000 record copies for an unchanged 10,000-record arena; ratio 4.000), every exactness row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 52f0395087ac6b8d9e83475ab1e664c71df058aa) INT27 pick note (late pick, accepted 2026-09-26 22:47, placed after the last scheduled pick and its behaviour half; the list names no place): drawing.hpp, the three rows and the fixture applied unchanged. git's clean merge put this lane's fixture-dir block inside TV-DEFAULTS' `if(TARGET test_tv_strategy_defaults)` block, before its endif(); each block stands on its own. The lane's floors and doc anchors (0d651058) are not picked: INT27's floors item recounts the floors (this lane: kernel +1, release +3, each PR registration floor +3) and INT27's single re-anchor pass sets the digits.
1 parent 5c6988c commit 4160b3e

11 files changed

Lines changed: 2441 additions & 26 deletions

File tree

‎include/pineforge/drawing.hpp‎

Lines changed: 317 additions & 26 deletions
Large diffs are not rendered by default.

‎tests/CMakeLists.txt‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ set(TEST_SOURCES
394394
test_pointvalue
395395
test_metrics
396396
test_drawing
397+
test_drawing_checkpoint
398+
test_coof_drawing_checkpoint_cost
399+
test_coof_drawing_rollback_tape
397400
test_margin_call
398401
test_high_value_fractional_money_margin
399402
test_margin_call_intrabar_chronology
@@ -2250,6 +2253,13 @@ if(TARGET test_tv_strategy_defaults)
22502253
PINEFORGE_TVD_FIXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tv_strategy_defaults")
22512254
endif()
22522255

2256+
# K-DRAWSNAP replays TradingView's calc_on_order_fills drawing-rollback tape
2257+
# through the Pine host; source-bound.
2258+
if(TARGET test_coof_drawing_rollback_tape)
2259+
target_compile_definitions(test_coof_drawing_rollback_tape PRIVATE
2260+
PINEFORGE_K_DRAWSNAP_FIXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/fixtures/coof_drawing_rollback")
2261+
endif()
2262+
22532263
# R5 F5 replays the same tapes through a bare host; kernel-only, so this row
22542264
# exists in every profile.
22552265
if(TARGET test_native_session_day_facts)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Drawing-rollback tape (R5 lane K-DRAWSNAP)
2+
3+
TradingView's own answer to whether a `calc_on_order_fills` recalculation's
4+
drawing edits survive it. They do not: the drawings roll back with the
5+
script's `var` variables. `tests/test_coof_drawing_rollback_tape.cpp` checks the
6+
tape and replays its window through the Pine host; the engine's
7+
generated-state checkpoint therefore has to hold the drawing arenas exactly,
8+
which lane K-DRAWSNAP made cheap (`include/pineforge/drawing.hpp`).
9+
10+
`coof-drawing-rollback/` is one `lab tv --no-note` export by lane CG-POPFIX
11+
(pineforge-workflow, channel `ws-report-v1`, `rangeProof: covered`), copied
12+
byte-identical from `exec/CG-POPFIX-scratch/tv/coof-drawing-rollback/out/`:
13+
`strategy.pine`, `tv_trades.csv` (times UTC+8), `meta.json`, `metrics.json`.
14+
The tape's sha256 is `metrics.json` `tvTradesCsvHash`
15+
(`acf0087f1bb17679aab9cac097dc82ecb75a0731df1914c10795f36bff0a82cd`).
16+
17+
| probe | chart | window | trades | TradingView |
18+
|---|---|---|---|---|
19+
| `coof-drawing-rollback` | BINANCE:ETHUSDT.P 15 | 2025-04-01 .. 2025-04-03 | 41 | `x2 == n` on 82/82 order comments, `m > n` on 81 |
20+
21+
The probe bumps a `var line`'s x2 on every execution, counts executions in a
22+
`var int n` (rolled back by a recalculation) and a `varip int m` (never rolled
23+
back), deletes and re-creates one label per execution, and spells all of them
24+
into its order comments (`x2=5 n=5 m=5 labels=1`). x2 equal to n while m runs
25+
ahead means every recalculation ran and its line edit rolled back.
26+
27+
`bars.inc` holds the window's 192 15m bars, resampled from the corpus 1m feed
28+
(`corpus/data/ohlcv_ETH-USDT-USDT_1m.csv`, sha256
29+
`db8c1332da093008cfbd063e05db0b33fe8f7fd35d78cf058a366519eb9f6cc5`) with
30+
`scripts/derive_corpus_feeds.py`'s rule (`exec/K-DRAWSNAP-scratch/tape/gen_inc.py`).
31+
Every entry and exit price of the tape is a bar open of that feed.
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
// Generated by K-DRAWSNAP-scratch/tape/gen_inc.py from the corpus 1m feed
2+
// corpus/data/ohlcv_ETH-USDT-USDT_1m.csv sha256 db8c1332da093008cfbd063e05db0b33fe8f7fd35d78cf058a366519eb9f6cc5,
3+
// resampled to 15m with scripts/derive_corpus_feeds.py's rule.
4+
// {timestamp_ms, open, high, low, close, volume}
5+
constexpr FeedBar kEth15m[192] = {
6+
{1743465600000LL, 1821.59, 1826.24, 1819.01, 1821.47, 29469.477},
7+
{1743466500000LL, 1821.48, 1829.36, 1820.11, 1826.38, 27806.476},
8+
{1743467400000LL, 1826.37, 1828.8, 1822.33, 1824.92, 17099.961},
9+
{1743468300000LL, 1824.93, 1842.57, 1816.64, 1831.2, 144554.059},
10+
{1743469200000LL, 1831.19, 1832.45, 1820, 1825.14, 47997.03},
11+
{1743470100000LL, 1825.13, 1828.31, 1822.51, 1827.4, 14456.395},
12+
{1743471000000LL, 1827.39, 1828.3, 1820.7, 1821.5, 17183.354},
13+
{1743471900000LL, 1821.49, 1827.54, 1821.49, 1825.52, 19577.512},
14+
{1743472800000LL, 1825.51, 1830.35, 1823.38, 1830.33, 16625.598},
15+
{1743473700000LL, 1830.34, 1834.37, 1829.66, 1830.9, 19983.129},
16+
{1743474600000LL, 1830.9, 1835.42, 1828.68, 1834.29, 16343.835},
17+
{1743475500000LL, 1834.29, 1838.7, 1833.56, 1838.53, 26600.559},
18+
{1743476400000LL, 1838.52, 1840.6, 1836, 1838.87, 28114.432},
19+
{1743477300000LL, 1838.86, 1839.88, 1833.5, 1833.75, 19046.561},
20+
{1743478200000LL, 1833.76, 1837.86, 1833.11, 1834.41, 15837.307},
21+
{1743479100000LL, 1834.4, 1836.85, 1832.2, 1834.25, 12728.004},
22+
{1743480000000LL, 1834.25, 1836, 1831.47, 1833.03, 21046.678},
23+
{1743480900000LL, 1833.02, 1837.16, 1831.23, 1835.9, 13546.486},
24+
{1743481800000LL, 1835.9, 1839.8, 1834.4, 1838.29, 21875.639},
25+
{1743482700000LL, 1838.29, 1839, 1836.5, 1837.47, 11161.809},
26+
{1743483600000LL, 1837.48, 1842.48, 1835.95, 1842.11, 17470.907},
27+
{1743484500000LL, 1842.1, 1849.9, 1841.71, 1846.82, 81918.308},
28+
{1743485400000LL, 1846.82, 1848.5, 1842.29, 1842.53, 17578.477},
29+
{1743486300000LL, 1842.53, 1843.1, 1839.66, 1840.75, 17048.415},
30+
{1743487200000LL, 1840.74, 1843.81, 1838.51, 1843.48, 23493.18},
31+
{1743488100000LL, 1843.47, 1847.86, 1843.19, 1847.08, 18040.793},
32+
{1743489000000LL, 1847.08, 1866.98, 1846.53, 1860.81, 110294.415},
33+
{1743489900000LL, 1860.81, 1862, 1855.6, 1856.8, 53165.662},
34+
{1743490800000LL, 1856.79, 1861.99, 1855, 1857.94, 45342.209},
35+
{1743491700000LL, 1857.93, 1858, 1853.1, 1855.95, 34448.598},
36+
{1743492600000LL, 1855.95, 1857.18, 1851.46, 1854.01, 22748.612},
37+
{1743493500000LL, 1854, 1855.6, 1851.91, 1853.34, 15857.538},
38+
{1743494400000LL, 1853.34, 1861.16, 1853.02, 1861.08, 28209.641},
39+
{1743495300000LL, 1861.08, 1885, 1860.84, 1883.69, 196027.879},
40+
{1743496200000LL, 1883.7, 1891.42, 1875.14, 1880.8, 117348.064},
41+
{1743497100000LL, 1880.81, 1887.85, 1880.17, 1883.41, 44357.02},
42+
{1743498000000LL, 1883.41, 1888.88, 1881.48, 1882.49, 45866.137},
43+
{1743498900000LL, 1882.49, 1884.1, 1877, 1880.23, 49205.114},
44+
{1743499800000LL, 1880.22, 1884.63, 1879.11, 1883.29, 28452.167},
45+
{1743500700000LL, 1883.29, 1886.32, 1881.32, 1884.49, 31256.168},
46+
{1743501600000LL, 1884.5, 1885.17, 1877.7, 1879.48, 41673.465},
47+
{1743502500000LL, 1879.48, 1884, 1878.2, 1879.21, 22496.506},
48+
{1743503400000LL, 1879.21, 1879.59, 1872.27, 1874.99, 60524.143},
49+
{1743504300000LL, 1874.99, 1879.41, 1871.57, 1872.49, 37019.418},
50+
{1743505200000LL, 1872.49, 1872.9, 1864.14, 1867.76, 69109.89},
51+
{1743506100000LL, 1867.77, 1870.95, 1866.01, 1867.92, 23106.161},
52+
{1743507000000LL, 1867.9, 1868.47, 1855.39, 1859.84, 80159.425},
53+
{1743507900000LL, 1859.83, 1862.82, 1858.77, 1861.48, 28252.479},
54+
{1743508800000LL, 1861.49, 1869.5, 1861.4, 1868.83, 55938.076},
55+
{1743509700000LL, 1868.83, 1869.8, 1863, 1868.41, 28745.851},
56+
{1743510600000LL, 1868.41, 1868.95, 1860.12, 1862.52, 30262.811},
57+
{1743511500000LL, 1862.52, 1866.06, 1858.8, 1864.85, 33317.281},
58+
{1743512400000LL, 1864.86, 1871.75, 1863.04, 1868.62, 40418.364},
59+
{1743513300000LL, 1868.62, 1873.64, 1865.8, 1872.93, 43088.792},
60+
{1743514200000LL, 1872.93, 1877.88, 1862.96, 1874.27, 96378.57},
61+
{1743515100000LL, 1874.26, 1880.94, 1868.55, 1872.14, 68291.787},
62+
{1743516000000LL, 1872.14, 1875, 1843.97, 1849.27, 220531.201},
63+
{1743516900000LL, 1849.28, 1858.69, 1841.2, 1856.19, 112811.419},
64+
{1743517800000LL, 1856.2, 1874.99, 1854.99, 1870.24, 126718.013},
65+
{1743518700000LL, 1870.23, 1887.92, 1867.38, 1881.48, 160882.002},
66+
{1743519600000LL, 1881.48, 1910, 1881.48, 1903.31, 235750.727},
67+
{1743520500000LL, 1903.31, 1927.69, 1899.5, 1910, 306244.687},
68+
{1743521400000LL, 1910, 1920.58, 1907.98, 1919.43, 118059.995},
69+
{1743522300000LL, 1919.43, 1927.79, 1916.85, 1917.89, 111892.701},
70+
{1743523200000LL, 1917.89, 1923.63, 1913.39, 1914.92, 81508.816},
71+
{1743524100000LL, 1914.92, 1919.7, 1910.64, 1912.99, 65592.44},
72+
{1743525000000LL, 1913, 1917.67, 1907.53, 1908.41, 53136.618},
73+
{1743525900000LL, 1908.4, 1916.46, 1906.65, 1915.01, 37541.559},
74+
{1743526800000LL, 1915, 1919.43, 1912.96, 1917.99, 31039.816},
75+
{1743527700000LL, 1917.99, 1920.93, 1913.62, 1915.58, 34940.519},
76+
{1743528600000LL, 1915.58, 1918.79, 1914, 1915.94, 15917.742},
77+
{1743529500000LL, 1915.94, 1922.49, 1914.01, 1914.55, 27100.959},
78+
{1743530400000LL, 1914.56, 1915, 1903.86, 1905.8, 50245.999},
79+
{1743531300000LL, 1905.8, 1909.69, 1900.53, 1908.61, 54471.962},
80+
{1743532200000LL, 1908.61, 1910.77, 1905.8, 1908.99, 24239.667},
81+
{1743533100000LL, 1908.99, 1909.07, 1901.49, 1907.5, 22023.948},
82+
{1743534000000LL, 1907.49, 1908.67, 1902.5, 1906.64, 25626.429},
83+
{1743534900000LL, 1906.63, 1908.61, 1902.13, 1903.78, 18510.611},
84+
{1743535800000LL, 1903.77, 1906.27, 1902, 1906, 12231.643},
85+
{1743536700000LL, 1905.99, 1910.5, 1904.7, 1909.12, 31359.364},
86+
{1743537600000LL, 1909.11, 1909.75, 1904.16, 1908.36, 28960.208},
87+
{1743538500000LL, 1908.35, 1912.65, 1900, 1901.6, 32868.284},
88+
{1743539400000LL, 1901.61, 1907.49, 1895.9, 1905, 43535.045},
89+
{1743540300000LL, 1905, 1915.2, 1904.6, 1912.06, 44179.766},
90+
{1743541200000LL, 1912.07, 1916.56, 1907.55, 1913.53, 30791.517},
91+
{1743542100000LL, 1913.52, 1916.11, 1912.43, 1914.01, 10333.544},
92+
{1743543000000LL, 1914, 1921.98, 1910.7, 1917.24, 39196.076},
93+
{1743543900000LL, 1917.23, 1917.24, 1911.61, 1914.19, 12319.285},
94+
{1743544800000LL, 1914.2, 1916.73, 1910.76, 1915.54, 23016.947},
95+
{1743545700000LL, 1915.55, 1917.1, 1912.69, 1916.01, 27918.883},
96+
{1743546600000LL, 1916.02, 1919.3, 1914.21, 1914.47, 15517.902},
97+
{1743547500000LL, 1914.47, 1916, 1910.09, 1911, 14411.016},
98+
{1743548400000LL, 1911.01, 1912.13, 1903.86, 1904.52, 25837.12},
99+
{1743549300000LL, 1904.52, 1910.64, 1904.51, 1910.06, 14948.886},
100+
{1743550200000LL, 1910.05, 1914.36, 1908, 1909.32, 16539.141},
101+
{1743551100000LL, 1909.32, 1909.32, 1903.77, 1904.21, 15025.522},
102+
{1743552000000LL, 1904.21, 1908.01, 1900.09, 1900.21, 40336.673},
103+
{1743552900000LL, 1900.21, 1904.46, 1896.2, 1896.99, 31026.742},
104+
{1743553800000LL, 1896.99, 1899.98, 1891.62, 1893.74, 39420.219},
105+
{1743554700000LL, 1893.74, 1896.46, 1886.04, 1889.06, 53466.34},
106+
{1743555600000LL, 1889.07, 1891.84, 1882.02, 1883.91, 50546.777},
107+
{1743556500000LL, 1883.9, 1888.46, 1882.69, 1884.99, 35527.597},
108+
{1743557400000LL, 1884.99, 1895.84, 1884, 1891.95, 51463.389},
109+
{1743558300000LL, 1891.96, 1893.29, 1887.94, 1891.71, 18083.236},
110+
{1743559200000LL, 1891.71, 1892.41, 1875.5, 1876.71, 70709.866},
111+
{1743560100000LL, 1876.71, 1881.28, 1871.31, 1880.71, 52124.133},
112+
{1743561000000LL, 1880.7, 1883.45, 1877.07, 1878.1, 32257.169},
113+
{1743561900000LL, 1878.1, 1882.74, 1877.12, 1877.57, 15936.818},
114+
{1743562800000LL, 1877.56, 1884.54, 1876.68, 1883.61, 22261.401},
115+
{1743563700000LL, 1883.6, 1886.45, 1880.34, 1882.81, 24772.014},
116+
{1743564600000LL, 1882.8, 1883.07, 1875.44, 1879.46, 20407.298},
117+
{1743565500000LL, 1879.45, 1879.65, 1874.46, 1875.41, 19276.052},
118+
{1743566400000LL, 1875.4, 1881.71, 1874.79, 1880.68, 18449.907},
119+
{1743567300000LL, 1880.67, 1882.31, 1878.63, 1880.67, 15573.626},
120+
{1743568200000LL, 1880.66, 1880.67, 1876.19, 1876.59, 15442.421},
121+
{1743569100000LL, 1876.59, 1879.81, 1874.72, 1878.14, 15700.915},
122+
{1743570000000LL, 1878.14, 1878.38, 1862.53, 1866.16, 88547.217},
123+
{1743570900000LL, 1866.16, 1866.46, 1853.57, 1855.88, 146270.205},
124+
{1743571800000LL, 1855.88, 1862.18, 1854.03, 1859.99, 46681.148},
125+
{1743572700000LL, 1859.99, 1863.69, 1854.1, 1855.08, 53916.625},
126+
{1743573600000LL, 1855.07, 1859.35, 1853.86, 1857.2, 42443.813},
127+
{1743574500000LL, 1857.2, 1861.45, 1850.69, 1855.8, 63467.607},
128+
{1743575400000LL, 1855.79, 1861.72, 1851.7, 1860.89, 42271.908},
129+
{1743576300000LL, 1860.89, 1860.9, 1852.63, 1852.84, 35317.698},
130+
{1743577200000LL, 1852.84, 1856.59, 1851.34, 1854.99, 29196.478},
131+
{1743578100000LL, 1854.98, 1861.6, 1853.33, 1856.15, 53135.188},
132+
{1743579000000LL, 1856.16, 1863.88, 1855.2, 1858.9, 55632.844},
133+
{1743579900000LL, 1858.9, 1865.78, 1858.33, 1864.07, 34732.681},
134+
{1743580800000LL, 1864.06, 1866.44, 1861.81, 1864.52, 33820.02},
135+
{1743581700000LL, 1864.51, 1869.36, 1861.61, 1867.93, 32073.213},
136+
{1743582600000LL, 1867.93, 1875.54, 1867.11, 1871.42, 57174.436},
137+
{1743583500000LL, 1871.41, 1872.6, 1865.88, 1866.91, 17980.898},
138+
{1743584400000LL, 1866.9, 1887.23, 1865.38, 1883.98, 133661.846},
139+
{1743585300000LL, 1883.98, 1885, 1874, 1878.59, 34794.978},
140+
{1743586200000LL, 1878.58, 1881.73, 1876, 1876.58, 20336.01},
141+
{1743587100000LL, 1876.57, 1880.38, 1874.98, 1878.44, 14083.235},
142+
{1743588000000LL, 1878.43, 1883.8, 1876.15, 1880.03, 29455.19},
143+
{1743588900000LL, 1880.02, 1886.7, 1878.19, 1878.91, 34278.998},
144+
{1743589800000LL, 1878.9, 1878.98, 1871.85, 1874.48, 37542.352},
145+
{1743590700000LL, 1874.47, 1876.52, 1870, 1871.92, 24803.139},
146+
{1743591600000LL, 1871.93, 1877.62, 1871, 1874.59, 23225.24},
147+
{1743592500000LL, 1874.59, 1877.53, 1872.5, 1872.6, 14322.558},
148+
{1743593400000LL, 1872.6, 1873.99, 1868.5, 1871.4, 33717.537},
149+
{1743594300000LL, 1871.39, 1872.64, 1867.32, 1868.05, 35603.983},
150+
{1743595200000LL, 1868.08, 1869.97, 1859.53, 1865.27, 69805.742},
151+
{1743596100000LL, 1865.26, 1865.99, 1857.06, 1857.87, 44507.866},
152+
{1743597000000LL, 1857.87, 1867.48, 1857.54, 1866.86, 44885.792},
153+
{1743597900000LL, 1866.85, 1872.55, 1863.5, 1871.16, 46399.418},
154+
{1743598800000LL, 1871.16, 1871.17, 1860.21, 1860.9, 37079.111},
155+
{1743599700000LL, 1860.91, 1863.27, 1856.89, 1858.15, 39716.662},
156+
{1743600600000LL, 1858.15, 1876.61, 1853.12, 1872.19, 123887.785},
157+
{1743601500000LL, 1872.27, 1892.7, 1869.82, 1870.41, 204369.033},
158+
{1743602400000LL, 1870.4, 1880.71, 1856.5, 1863.13, 143174.077},
159+
{1743603300000LL, 1863.14, 1872.65, 1860.01, 1870.75, 65884.918},
160+
{1743604200000LL, 1870.75, 1875.85, 1863.52, 1870.75, 54007.966},
161+
{1743605100000LL, 1870.74, 1877.04, 1868.55, 1874.69, 35059.783},
162+
{1743606000000LL, 1874.7, 1894.47, 1873.16, 1881, 139752.351},
163+
{1743606900000LL, 1881, 1893.06, 1880.5, 1889.52, 76522.994},
164+
{1743607800000LL, 1889.52, 1918, 1889.3, 1913.94, 334936.345},
165+
{1743608700000LL, 1913.9, 1918, 1892.39, 1900.09, 313381.872},
166+
{1743609600000LL, 1900.1, 1905, 1894.05, 1901.26, 62196.258},
167+
{1743610500000LL, 1901.26, 1907.4, 1900.77, 1906.86, 41553.556},
168+
{1743611400000LL, 1906.86, 1909.21, 1897.1, 1902.19, 42580.94},
169+
{1743612300000LL, 1902.19, 1906.94, 1898.41, 1901.99, 45930.495},
170+
{1743613200000LL, 1902, 1913.85, 1900.8, 1910.59, 101330.528},
171+
{1743614100000LL, 1910.59, 1910.99, 1896.9, 1896.9, 49837.314},
172+
{1743615000000LL, 1896.9, 1897.97, 1883.27, 1888.15, 81146.34},
173+
{1743615900000LL, 1888.14, 1893.88, 1881.09, 1891.61, 52666.634},
174+
{1743616800000LL, 1891.6, 1896.75, 1887.29, 1891.34, 35302.632},
175+
{1743617700000LL, 1891.34, 1894.5, 1888, 1888.42, 26108.427},
176+
{1743618600000LL, 1888.41, 1903.66, 1888, 1900.81, 50356.456},
177+
{1743619500000LL, 1900.8, 1903.64, 1896.84, 1897.08, 27191.124},
178+
{1743620400000LL, 1897.09, 1901.55, 1897, 1898.6, 23075.839},
179+
{1743621300000LL, 1898.59, 1900.83, 1892.11, 1899.69, 25471.406},
180+
{1743622200000LL, 1899.69, 1905.9, 1896.53, 1905.26, 28007.742},
181+
{1743623100000LL, 1905.25, 1915.28, 1904.98, 1910.56, 67245.989},
182+
{1743624000000LL, 1910.59, 1946.03, 1881, 1933.11, 303499.492},
183+
{1743624900000LL, 1933.11, 1957.97, 1872.48, 1897.82, 545254.946},
184+
{1743625800000LL, 1897.82, 1904.55, 1865, 1870.06, 307968.308},
185+
{1743626700000LL, 1870, 1883.75, 1866.79, 1880, 111710.625},
186+
{1743627600000LL, 1880.16, 1883.91, 1853.93, 1859.77, 138995.519},
187+
{1743628500000LL, 1859.76, 1878.45, 1856.75, 1862.71, 123974.903},
188+
{1743629400000LL, 1862.71, 1870.79, 1859.48, 1869, 36094.542},
189+
{1743630300000LL, 1868.99, 1869, 1858.69, 1866.28, 38720.81},
190+
{1743631200000LL, 1866.27, 1866.83, 1829.16, 1836.21, 253553.148},
191+
{1743632100000LL, 1836.21, 1836.21, 1816, 1823.67, 168671.693},
192+
{1743633000000LL, 1823.67, 1824.8, 1792.43, 1794.27, 156022.396},
193+
{1743633900000LL, 1794.27, 1807.18, 1787.75, 1796.94, 138340.47},
194+
{1743634800000LL, 1796.91, 1796.92, 1780.52, 1794.29, 143572.953},
195+
{1743635700000LL, 1794.29, 1797.1, 1781.3, 1796.84, 78446.39},
196+
{1743636600000LL, 1796.83, 1801.7, 1793.97, 1801.15, 52887.46},
197+
{1743637500000LL, 1801.15, 1801.15, 1791.35, 1794.1, 37498.515},
198+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"title": "PF coof drawing rollback",
3+
"slug": "pf-popfix-coof-drawing-rollback",
4+
"source": "pineforge-workflow campaign lab tv",
5+
"channel": "ws-report-v1",
6+
"exportedAt": "2026-09-26T07:54:27.097Z",
7+
"chart": {
8+
"symbol": "BINANCE:ETHUSDT.P",
9+
"interval": "15",
10+
"from": "2025-04-01",
11+
"to": "2025-04-03"
12+
},
13+
"pine_sha256": "331f0ed9ebc6c7e6b7e679291c735815d21a7f6b49f7af897685dc21e183d34d",
14+
"tv_trades_sha256": "acf0087f1bb17679aab9cac097dc82ecb75a0731df1914c10795f36bff0a82cd",
15+
"tv_trades_rows": 82
16+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"validationEligible": true,
3+
"strategy": "pf-popfix-coof-drawing-rollback",
4+
"symbol": "BINANCE:ETHUSDT.P",
5+
"interval": "15",
6+
"from": "2025-04-01",
7+
"to": "2025-04-03",
8+
"deepBacktesting": true,
9+
"trades": 41,
10+
"tvTradesCsv": "tv_trades.csv",
11+
"tapeChannel": "ws-report-v1",
12+
"sourceCanonicalization": "pine-facade-v1",
13+
"sourceArtifactHash": "331f0ed9ebc6c7e6b7e679291c735815d21a7f6b49f7af897685dc21e183d34d",
14+
"tvTradesCsvHash": "acf0087f1bb17679aab9cac097dc82ecb75a0731df1914c10795f36bff0a82cd",
15+
"wsProvenance": {
16+
"schemaVersion": 1,
17+
"wsEndpoint": "wss://history-data.tradingview.com/socket.io/websocket?from=chart%2F&type=chart&auth=sessionid",
18+
"authUser": "luisleo52655",
19+
"accountType": "pro_premium_expert",
20+
"pineId": "USER;3c3ee73838da415d9f6fb36ccd7cbe97",
21+
"pineVersion": "0.87971",
22+
"symbol": "BINANCE:ETHUSDT.P",
23+
"interval": "15",
24+
"requestedRange": {
25+
"from": 1743465600000,
26+
"to": 1743638400000
27+
},
28+
"returnedRange": {
29+
"from": 1743465600000,
30+
"to": 1743638400000
31+
},
32+
"rangeProof": "covered",
33+
"rawFrameSha256": "06c170b3018c49157801165476a1f1ca0dc1500802234484b06ad721f56d4547",
34+
"decodedReportSha256": "804f17c06fc4db6c8c1fea8c14ea43baa08b4024dd350d27aa209a6e3b2f99d9",
35+
"closedTrades": 41,
36+
"proves": "which compile bytecode and which from/to window were sent to TradingView, and the exact trades TradingView returned for it (re-derivable from rawFrameSha256)",
37+
"doesNotProve": "chart activation or the displayed applied range (browser-only); CSV byte identity and priceExact are lab renderings, screen-only until a parity study"
38+
},
39+
"backtestedAt": "2026-09-26T07:54:27.096Z"
40+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@version=6
2+
// Does a calc_on_order_fills recalculation roll back drawings? A var line's x2
3+
// is bumped on every execution; n (var) is rolled back, m (varip) is not. The
4+
// order comments spell all three: x2 == n means drawings roll back with vars,
5+
// x2 == m means a recalculation's drawing edits persist.
6+
strategy("PF coof drawing rollback", overlay = true, calc_on_order_fills = true)
7+
var line l = line.new(0, 0, 0, 0)
8+
line.set_x2(l, line.get_x2(l) + 1)
9+
var int n = 0
10+
n += 1
11+
varip int m = 0
12+
m += 1
13+
var label lab = na
14+
label.delete(lab)
15+
lab := label.new(bar_index, high, "k")
16+
string tag = "x2=" + str.tostring(line.get_x2(l)) + " n=" + str.tostring(n) + " m=" + str.tostring(m) + " labels=" + str.tostring(array.size(label.all))
17+
if minute(time, "UTC") == 0 and strategy.position_size == 0
18+
strategy.entry("L", strategy.long, comment = tag)
19+
if minute(time, "UTC") == 30
20+
strategy.close("L", comment = tag)

0 commit comments

Comments
 (0)