oakscriptjs 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/cjs/box/index.d.ts +3 -3
  2. package/dist/cjs/box/index.d.ts.map +1 -1
  3. package/dist/cjs/box/index.js.map +2 -2
  4. package/dist/cjs/drawing/output.d.ts +2 -1
  5. package/dist/cjs/drawing/output.d.ts.map +1 -1
  6. package/dist/cjs/drawing/output.js +5 -4
  7. package/dist/cjs/drawing/output.js.map +2 -2
  8. package/dist/cjs/index.d.ts +1 -1
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/label/index.d.ts +2 -2
  12. package/dist/cjs/label/index.d.ts.map +1 -1
  13. package/dist/cjs/label/index.js.map +2 -2
  14. package/dist/cjs/line/index.d.ts +4 -4
  15. package/dist/cjs/line/index.d.ts.map +1 -1
  16. package/dist/cjs/line/index.js +1 -1
  17. package/dist/cjs/line/index.js.map +2 -2
  18. package/dist/cjs/polyline/index.d.ts +2 -2
  19. package/dist/cjs/polyline/index.d.ts.map +1 -1
  20. package/dist/cjs/polyline/index.js.map +2 -2
  21. package/dist/cjs/script/constants.d.ts +6 -1
  22. package/dist/cjs/script/constants.d.ts.map +1 -1
  23. package/dist/cjs/script/constants.js +2 -1
  24. package/dist/cjs/script/constants.js.map +2 -2
  25. package/dist/cjs/script/index.d.ts +44 -17
  26. package/dist/cjs/script/index.d.ts.map +1 -1
  27. package/dist/cjs/script/index.js +55 -6
  28. package/dist/cjs/script/index.js.map +2 -2
  29. package/dist/cjs/session/bars.d.ts +9 -0
  30. package/dist/cjs/session/bars.d.ts.map +1 -1
  31. package/dist/cjs/session/bars.js +36 -15
  32. package/dist/cjs/session/bars.js.map +2 -2
  33. package/dist/cjs/session/calendar.d.ts +10 -0
  34. package/dist/cjs/session/calendar.d.ts.map +1 -1
  35. package/dist/cjs/session/calendar.js +15 -0
  36. package/dist/cjs/session/calendar.js.map +2 -2
  37. package/dist/cjs/session/context.js +1 -1
  38. package/dist/cjs/session/context.js.map +2 -2
  39. package/dist/cjs/types/index.d.ts +13 -11
  40. package/dist/cjs/types/index.d.ts.map +1 -1
  41. package/dist/cjs/types/index.js +3 -1
  42. package/dist/cjs/types/index.js.map +2 -2
  43. package/dist/cjs/types/metadata.d.ts +12 -8
  44. package/dist/cjs/types/metadata.d.ts.map +1 -1
  45. package/dist/cjs/types/metadata.js.map +1 -1
  46. package/dist/esm/box/index.d.ts +3 -3
  47. package/dist/esm/box/index.d.ts.map +1 -1
  48. package/dist/esm/box/index.js +1 -1
  49. package/dist/esm/box/index.js.map +1 -1
  50. package/dist/esm/drawing/output.d.ts +2 -1
  51. package/dist/esm/drawing/output.d.ts.map +1 -1
  52. package/dist/esm/drawing/output.js +9 -7
  53. package/dist/esm/drawing/output.js.map +1 -1
  54. package/dist/esm/index.d.ts +1 -1
  55. package/dist/esm/index.js +1 -1
  56. package/dist/esm/label/index.d.ts +2 -2
  57. package/dist/esm/label/index.d.ts.map +1 -1
  58. package/dist/esm/label/index.js.map +1 -1
  59. package/dist/esm/line/index.d.ts +4 -4
  60. package/dist/esm/line/index.d.ts.map +1 -1
  61. package/dist/esm/line/index.js +3 -3
  62. package/dist/esm/line/index.js.map +1 -1
  63. package/dist/esm/polyline/index.d.ts +2 -2
  64. package/dist/esm/polyline/index.d.ts.map +1 -1
  65. package/dist/esm/polyline/index.js +1 -1
  66. package/dist/esm/polyline/index.js.map +1 -1
  67. package/dist/esm/script/constants.d.ts +6 -1
  68. package/dist/esm/script/constants.d.ts.map +1 -1
  69. package/dist/esm/script/constants.js +6 -1
  70. package/dist/esm/script/constants.js.map +1 -1
  71. package/dist/esm/script/index.d.ts +44 -17
  72. package/dist/esm/script/index.d.ts.map +1 -1
  73. package/dist/esm/script/index.js +57 -4
  74. package/dist/esm/script/index.js.map +1 -1
  75. package/dist/esm/session/bars.d.ts +9 -0
  76. package/dist/esm/session/bars.d.ts.map +1 -1
  77. package/dist/esm/session/bars.js +40 -15
  78. package/dist/esm/session/bars.js.map +1 -1
  79. package/dist/esm/session/calendar.d.ts +10 -0
  80. package/dist/esm/session/calendar.d.ts.map +1 -1
  81. package/dist/esm/session/calendar.js +16 -0
  82. package/dist/esm/session/calendar.js.map +1 -1
  83. package/dist/esm/session/context.js +1 -1
  84. package/dist/esm/session/context.js.map +1 -1
  85. package/dist/esm/types/index.d.ts +13 -11
  86. package/dist/esm/types/index.d.ts.map +1 -1
  87. package/dist/esm/types/index.js +3 -1
  88. package/dist/esm/types/index.js.map +1 -1
  89. package/dist/esm/types/metadata.d.ts +12 -8
  90. package/dist/esm/types/metadata.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/skills/oakscript/reference/pine-differences.md +2 -0
  93. package/skills/oakscript/reference/plotting.md +24 -1
  94. package/src/box/index.ts +4 -4
  95. package/src/drawing/output.ts +12 -8
  96. package/src/index.ts +1 -1
  97. package/src/label/index.ts +3 -3
  98. package/src/line/index.ts +6 -6
  99. package/src/polyline/index.ts +2 -2
  100. package/src/script/constants.ts +6 -1
  101. package/src/script/index.ts +79 -8
  102. package/src/session/bars.ts +40 -15
  103. package/src/session/calendar.ts +22 -0
  104. package/src/session/context.ts +1 -1
  105. package/src/types/index.ts +13 -11
  106. package/src/types/metadata.ts +12 -8
@@ -126,14 +126,15 @@ export class SessionBars {
126
126
  */
127
127
  timeOf(time: number, timeframe: string): number {
128
128
  const tf = this.timeframe(timeframe);
129
- const at = this.calendar.locate(time);
129
+ const at = this.locateBar(time);
130
130
  if (!at) return NaN;
131
131
  if (tf.isintraday) {
132
132
  if (this.chart.isdwm) return time;
133
133
  // a bar after an early close has no intraday period either (#173)
134
134
  if (this.stray(time)) return NaN;
135
- const [start] = this.calendar.periods(at.date)[at.index]!;
136
135
  const ms = in_seconds(tf.period) * 1000;
136
+ if (this.calendar.barOrigin !== null) return this.calendar.gridStart(time, ms);
137
+ const [start] = this.calendar.periods(at.date)[at.index]!;
137
138
  return start + Math.floor((time - start) / ms) * ms;
138
139
  }
139
140
  const { unit, n } = unitOf(tf);
@@ -146,14 +147,14 @@ export class SessionBars {
146
147
  /** PineScript `time_close(tf)` for a bar that opens at `time`. */
147
148
  closeOf(time: number, timeframe: string): number {
148
149
  const tf = this.timeframe(timeframe);
149
- const at = this.calendar.locate(time);
150
+ const at = this.locateBar(time);
150
151
  if (!at) return NaN;
151
152
  if (tf.isintraday) {
152
153
  const [, end] = this.calendar.periods(at.date)[at.index]!;
153
154
  // on D / W / M charts: the end of the session period that contains the bar open
154
155
  if (this.chart.isdwm) return end;
155
156
  if (this.stray(time)) return NaN;
156
- return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);
157
+ return this.intradayClose(time, timeframe, end);
157
158
  }
158
159
  const { unit, n } = unitOf(tf);
159
160
  if (unit === 'D' && n === 1 && this.stray(time)) return NaN;
@@ -170,7 +171,7 @@ export class SessionBars {
170
171
 
171
172
  /** Trading day of a bar: on D / W / M charts the last trading day of the chart period. */
172
173
  tradingDay(time: number): DateNum | null {
173
- const at = this.calendar.locate(time);
174
+ const at = this.locateBar(time);
174
175
  if (!at || this.stray(time)) return null;
175
176
  if (this.chart.isdwm) {
176
177
  const { unit, n } = unitOf(this.chart);
@@ -187,11 +188,11 @@ export class SessionBars {
187
188
  */
188
189
  periodEnd(time: number, timeframe: string): number {
189
190
  const tf = this.timeframe(timeframe);
190
- const at = this.calendar.locate(time);
191
+ const at = this.locateBar(time);
191
192
  if (!at) return NaN;
192
193
  if (tf.isintraday) {
193
194
  const [, end] = this.calendar.periods(at.date)[at.index]!;
194
- return Math.min(this.timeOf(time, timeframe) + in_seconds(tf.period) * 1000, end);
195
+ return this.intradayClose(time, timeframe, end);
195
196
  }
196
197
  const { unit, n } = unitOf(tf);
197
198
  const [from, to] = this.periodRange(at.date, unit, n);
@@ -211,17 +212,20 @@ export class SessionBars {
211
212
  * trading day of the next chart period. NaN when none is found within 400 days.
212
213
  */
213
214
  nextBarTime(time: number): number {
214
- const at = this.calendar.locate(time);
215
+ const at = this.locateBar(time);
215
216
  if (!at) return NaN;
216
217
  if (!this.chart.isdwm) {
217
218
  const periods = this.calendar.periods(at.date);
218
219
  const [start, end] = periods[at.index]!;
219
220
  const ms = in_seconds(this.chart.period) * 1000;
220
- const next = start + (Math.floor((time - start) / ms) + 1) * ms;
221
+ const grid = this.calendar.barOrigin !== null;
222
+ // on the clock grid, the next session opens in the bar of the grid that holds it
223
+ const open = (t: number): number => (grid ? this.calendar.gridStart(t, ms) : t);
224
+ const next = grid ? this.calendar.gridStart(time, ms) + ms : start + (Math.floor((time - start) / ms) + 1) * ms;
221
225
  if (at.inside && next < end) return next;
222
- if (at.index + 1 < periods.length) return periods[at.index + 1]![0];
226
+ if (at.index + 1 < periods.length) return open(periods[at.index + 1]![0]);
223
227
  const day = this.calendar.firstTradingDay(addDays(at.date, 1), addDays(at.date, 400));
224
- return day === null ? NaN : this.dayStart(day);
228
+ return day === null ? NaN : open(this.dayStart(day));
225
229
  }
226
230
  const { unit, n } = unitOf(this.chart);
227
231
  const [, to] = this.periodRange(at.date, unit, n);
@@ -229,6 +233,25 @@ export class SessionBars {
229
233
  return day === null ? NaN : this.dayStart(day);
230
234
  }
231
235
 
236
+ /**
237
+ * Trading day and period of a chart bar that opens at `time` (see TradingCalendar.locate). On the clock grid
238
+ * (`barOrigin`), an intraday bar that opens before a session period but holds its open belongs to that period
239
+ * (a 01:00 five-minute bar when trading opens at 01:01).
240
+ */
241
+ locateBar(time: number): ReturnType<TradingCalendar['locate']> {
242
+ const at = this.calendar.locate(time);
243
+ if (this.calendar.barOrigin === null || this.chart.isdwm || at?.inside) return at;
244
+ const ahead = this.calendar.locate(time + in_seconds(this.chart.period) * 1000 - 1);
245
+ return ahead?.inside && this.calendar.periods(ahead.date)[ahead.index]![0] > time ? ahead : at;
246
+ }
247
+
248
+ /** Close of the intraday `timeframe` period that holds `time`: cut at the session period `end`, except on the
249
+ * clock grid, whose bars run their whole length. */
250
+ private intradayClose(time: number, timeframe: string, end: number): number {
251
+ const close = this.timeOf(time, timeframe) + in_seconds(this.timeframe(timeframe).period) * 1000;
252
+ return this.calendar.barOrigin !== null ? close : Math.min(close, end);
253
+ }
254
+
232
255
  /** An intraday bar that opens after an early close of its day (see TradingCalendar.afterEarlyClose). */
233
256
  stray(time: number): boolean {
234
257
  return !this.chart.isdwm && this.calendar.afterEarlyClose(time);
@@ -236,12 +259,12 @@ export class SessionBars {
236
259
 
237
260
  /** True when the bar at `time` is inside the session. */
238
261
  inside(time: number): boolean {
239
- return this.calendar.locate(time)?.inside ?? false;
262
+ return this.locateBar(time)?.inside ?? false;
240
263
  }
241
264
 
242
265
  /** Session start and end of the trading day of `time`, or null. */
243
266
  dayBounds(time: number): { date: DateNum; start: number; end: number } | null {
244
- const at = this.calendar.locate(time);
267
+ const at = this.locateBar(time);
245
268
  return at ? { date: at.date, start: this.dayStart(at.date), end: this.dayEnd(at.date) } : null;
246
269
  }
247
270
  }
@@ -302,7 +325,7 @@ export function sessionFlags(times: number[], bars: SessionBars, regular: Sessio
302
325
  for (const k of ['isfirstbar', 'islastbar', 'ismarket', 'isfirstbar_regular', 'islastbar_regular'] as const) out[k][i] = true;
303
326
  continue;
304
327
  }
305
- const at = bars.calendar.locate(t);
328
+ const at = bars.locateBar(t);
306
329
  if (!at) {
307
330
  previousPeriod = previousRegular = '';
308
331
  continue;
@@ -317,7 +340,9 @@ export function sessionFlags(times: number[], bars: SessionBars, regular: Sessio
317
340
  const stray = bars.stray(t);
318
341
  out.islastbar[i] = !stray && close >= end;
319
342
  const regularPeriods = regular.calendar.periods(at.date);
320
- const r = regularPeriods.findIndex(([s, e]) => s <= t && t < e);
343
+ // a bar of the clock grid that holds the open (see locateBar) is read at the open
344
+ const open = Math.max(t, start);
345
+ const r = regularPeriods.findIndex(([s, e]) => s <= open && open < e);
321
346
  const market = r !== -1;
322
347
  out.ismarket[i] = market || regular.stray(t);
323
348
  if (!market && regularPeriods.length) {
@@ -29,6 +29,12 @@ export interface SessionSpec {
29
29
  corrections?: string;
30
30
  /** Exchange holidays as "YYYYMMDD" (symbol info "session_holidays"), comma-separated or as an array */
31
31
  holidays?: string | string[];
32
+ /**
33
+ * Minutes after midnight (in the time zone) where the intraday bars of every size start their grid, for a source
34
+ * whose bars ignore the session opens (a broker terminal: 5-minute bars at 01:00, 01:05... when trading opens at
35
+ * 01:01). Unset: intraday periods start at each session period start.
36
+ */
37
+ barOrigin?: number | null;
32
38
  }
33
39
 
34
40
  /** Date as YYYYMMDD. */
@@ -178,6 +184,8 @@ export class TradingCalendar {
178
184
  /** The last time located and its result: the functions of one bar locate the same time several times */
179
185
  private lastTime = NaN;
180
186
  private lastAt: Located | null = null;
187
+ /** Minutes after midnight of the intraday bar grid (`SessionSpec.barOrigin`), null when bars start at the periods */
188
+ readonly barOrigin: number | null;
181
189
 
182
190
  /**
183
191
  * @param timezone - Time zone of the session hours (the exchange time zone)
@@ -193,6 +201,7 @@ export class TradingCalendar {
193
201
  dayPlacement = false
194
202
  ) {
195
203
  this.pine = rule === 'pine' && dayPlacement;
204
+ this.barOrigin = spec.barOrigin ?? null;
196
205
  const [first = '', ...changes] = spec.session.split('#');
197
206
  this.versions = [parseVersion(first, 0, spec.session, rule)];
198
207
  for (const change of changes) {
@@ -250,6 +259,19 @@ export class TradingCalendar {
250
259
  return this.versions[k]!;
251
260
  }
252
261
 
262
+ /** Start of the `ms` bar of the clock grid (`barOrigin`) that holds `time`; each local day restarts the grid. */
263
+ gridStart(time: number, ms: number): number {
264
+ const origin = this.barOrigin ?? 0;
265
+ const local = Math.floor((time + zoneOffset(time, this.timezone)) / MS_PER_DAY);
266
+ const anchorOf = (day: number): number => {
267
+ const { year, month, day: d } = civilFromDays(day);
268
+ return zonedToUnix(this.timezone, year, month, d, Math.floor(origin / 60), origin % 60);
269
+ };
270
+ let anchor = anchorOf(local);
271
+ if (anchor > time) anchor = anchorOf(local - 1);
272
+ return anchor + Math.floor((time - anchor) / ms) * ms;
273
+ }
274
+
253
275
  isTradingDay(date: DateNum): boolean {
254
276
  return this.periods(date).length > 0;
255
277
  }
@@ -235,7 +235,7 @@ export function resampleSession(bars: Bar[], timeframe: string, chart: SessionCo
235
235
  const calendar = tf.isdwm ? s.regular : s.bars;
236
236
  const starts = times.map((t) => calendar.timeOf(t, tf.period));
237
237
  const dayPeriods = times.map((t, i) => {
238
- const at = s.bars.calendar.locate(t);
238
+ const at = s.bars.locateBar(t);
239
239
  const periods = at ? calendar.calendar.periods(at.date) : [];
240
240
  return periods.length ? calendar.timeOf(periods[0]![0], tf.period) : starts[i]!;
241
241
  });
@@ -70,16 +70,16 @@ export interface PineMatrix<T> {
70
70
  * for detecting trend line breakouts, calculating support/resistance levels, etc.
71
71
  */
72
72
  export interface Line {
73
- /** First point's x coordinate (bar index or UNIX timestamp) */
73
+ /** First point's x coordinate (bar index, UNIX timestamp, or percent of the pane's width with xloc 'pane') */
74
74
  x1: number;
75
75
  /** First point's y coordinate (price level) */
76
76
  y1: number;
77
- /** Second point's x coordinate (bar index or UNIX timestamp) */
77
+ /** Second point's x coordinate (bar index, UNIX timestamp, or percent of the pane's width with xloc 'pane') */
78
78
  x2: number;
79
79
  /** Second point's y coordinate (price level) */
80
80
  y2: number;
81
81
  /** X-axis coordinate system */
82
- xloc: 'bar_index' | 'bar_time';
82
+ xloc: 'bar_index' | 'bar_time' | 'pane';
83
83
  /** Extension mode */
84
84
  extend: 'none' | 'left' | 'right' | 'both';
85
85
  /** Line color (stored but not used for calculations) */
@@ -99,16 +99,16 @@ export interface Line {
99
99
  * range breakout analysis, and consolidation zone identification.
100
100
  */
101
101
  export interface Box {
102
- /** Left border x coordinate (bar index or UNIX timestamp) */
102
+ /** Left border x coordinate (bar index, UNIX timestamp, or percent of the pane's width with xloc 'pane') */
103
103
  left: number;
104
104
  /** Top border y coordinate (price level) */
105
105
  top: number;
106
- /** Right border x coordinate (bar index or UNIX timestamp) */
106
+ /** Right border x coordinate (bar index, UNIX timestamp, or percent of the pane's width with xloc 'pane') */
107
107
  right: number;
108
108
  /** Bottom border y coordinate (price level) */
109
109
  bottom: number;
110
110
  /** X-axis coordinate system */
111
- xloc: 'bar_index' | 'bar_time';
111
+ xloc: 'bar_index' | 'bar_time' | 'pane';
112
112
  /** Horizontal extension mode */
113
113
  extend: 'none' | 'left' | 'right' | 'both';
114
114
  /** Border color (stored but not used for calculations) */
@@ -145,12 +145,12 @@ export interface Box {
145
145
  * Labels have limited computational value. Primarily used for marking points and displaying text.
146
146
  */
147
147
  export interface Label {
148
- /** X coordinate (bar index or UNIX timestamp) */
148
+ /** X coordinate (bar index, UNIX timestamp, or percent of the pane's width with xloc 'pane') */
149
149
  x: number;
150
150
  /** Y coordinate (price level when yloc = 'price') */
151
151
  y: number;
152
152
  /** X-axis coordinate system */
153
- xloc: 'bar_index' | 'bar_time';
153
+ xloc: 'bar_index' | 'bar_time' | 'pane';
154
154
  /** Y-axis positioning mode */
155
155
  yloc: 'price' | 'abovebar' | 'belowbar';
156
156
  /** Label text content */
@@ -357,13 +357,15 @@ export type na = null;
357
357
 
358
358
  /**
359
359
  * X-axis location constants
360
- * Used to specify whether x-coordinates are bar indices or timestamps
360
+ * Used to specify whether x-coordinates are bar indices, timestamps or places on the pane
361
361
  */
362
362
  export const xloc = {
363
363
  /** X-coordinates are bar indices */
364
364
  bar_index: 'bar_index' as const,
365
365
  /** X-coordinates are UNIX timestamps in milliseconds */
366
366
  bar_time: 'bar_time' as const,
367
+ /** X-coordinates are percents of the pane's width: 0 left edge, 100 right edge (not a PineScript value) */
368
+ pane: 'pane' as const,
367
369
  };
368
370
 
369
371
  /**
@@ -411,8 +413,8 @@ export interface Polyline {
411
413
  readonly curved: boolean;
412
414
  /** If true, connect the first point to the last point */
413
415
  readonly closed: boolean;
414
- /** X-coordinate mode: 'bar_index' or 'bar_time' */
415
- readonly xloc: 'bar_index' | 'bar_time';
416
+ /** X-coordinate mode: 'bar_index', 'bar_time' or 'pane' */
417
+ readonly xloc: 'bar_index' | 'bar_time' | 'pane';
416
418
  /** Color of line segments */
417
419
  readonly line_color: color;
418
420
  /** Fill color for closed polylines (null for no fill) */
@@ -438,8 +438,9 @@ export interface LabelData {
438
438
  time: number;
439
439
  /** 'bar_time': the x coordinates are times given by the script (xloc.bar_time). A time after the last bar is
440
440
  * drawn on the future bar that holds it, on the chart's calendar (trading sessions). Omitted: bar indexes (a
441
- * future bar index k bars after the last bar has the time lastTime + k * interval). */
442
- xloc?: 'bar_time';
441
+ * future bar index k bars after the last bar has the time lastTime + k * interval). 'pane': the times are percents
442
+ * of the pane's width (0 left edge, 100 right edge): drawn there whatever bars are in view. */
443
+ xloc?: 'bar_time' | 'pane';
443
444
  /** Price; not used with yloc 'abovebar' / 'belowbar' */
444
445
  price: number;
445
446
  text: string;
@@ -476,8 +477,9 @@ export interface LineDrawingData {
476
477
  price2: number;
477
478
  /** 'bar_time': the x coordinates are times given by the script (xloc.bar_time). A time after the last bar is
478
479
  * drawn on the future bar that holds it, on the chart's calendar (trading sessions). Omitted: bar indexes (a
479
- * future bar index k bars after the last bar has the time lastTime + k * interval). */
480
- xloc?: 'bar_time';
480
+ * future bar index k bars after the last bar has the time lastTime + k * interval). 'pane': the times are percents
481
+ * of the pane's width (0 left edge, 100 right edge): drawn there whatever bars are in view. */
482
+ xloc?: 'bar_time' | 'pane';
481
483
  /** Omitted: #2962FF (color.blue; #2196F3 in a v4 script) */
482
484
  color?: string;
483
485
  /** Omitted: 1. A width of 0 is kept (PineScript `width = 0`) */
@@ -499,8 +501,9 @@ export interface BoxData {
499
501
  price2: number;
500
502
  /** 'bar_time': the x coordinates are times given by the script (xloc.bar_time). A time after the last bar is
501
503
  * drawn on the future bar that holds it, on the chart's calendar (trading sessions). Omitted: bar indexes (a
502
- * future bar index k bars after the last bar has the time lastTime + k * interval). */
503
- xloc?: 'bar_time';
504
+ * future bar index k bars after the last bar has the time lastTime + k * interval). 'pane': the times are percents
505
+ * of the pane's width (0 left edge, 100 right edge): drawn there whatever bars are in view. */
506
+ xloc?: 'bar_time' | 'pane';
504
507
  /** Omitted: #2962FF (color.blue; #2196F3 in a v4 script) */
505
508
  bgColor?: string;
506
509
  /** Omitted: #2962FF (color.blue; #2196F3 in a v4 script) */
@@ -544,8 +547,9 @@ export interface PolylineData {
544
547
  points: Array<{ time: number; price: number }>;
545
548
  /** 'bar_time': the x coordinates are times given by the script (xloc.bar_time). A time after the last bar is
546
549
  * drawn on the future bar that holds it, on the chart's calendar (trading sessions). Omitted: bar indexes (a
547
- * future bar index k bars after the last bar has the time lastTime + k * interval). */
548
- xloc?: 'bar_time';
550
+ * future bar index k bars after the last bar has the time lastTime + k * interval). 'pane': the times are percents
551
+ * of the pane's width (0 left edge, 100 right edge): drawn there whatever bars are in view. */
552
+ xloc?: 'bar_time' | 'pane';
549
553
  /** Curved segments between the points */
550
554
  curved?: boolean;
551
555
  /** The last point is connected to the first */