oakscriptjs 0.8.1 → 0.9.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.
- package/LICENSE +1 -1
- package/README.md +31 -9
- package/dist/cjs/array/index.d.ts +701 -0
- package/dist/cjs/array/index.d.ts.map +1 -0
- package/dist/cjs/array/index.js +392 -0
- package/dist/cjs/array/index.js.map +7 -0
- package/dist/cjs/box/index.d.ts +444 -0
- package/dist/cjs/box/index.d.ts.map +1 -0
- package/dist/cjs/box/index.js +246 -0
- package/dist/cjs/box/index.js.map +7 -0
- package/dist/cjs/callsite/index.d.ts +61 -0
- package/dist/cjs/callsite/index.d.ts.map +1 -0
- package/dist/cjs/callsite/index.js +65 -0
- package/dist/cjs/callsite/index.js.map +7 -0
- package/dist/cjs/chartpoint/index.d.ts +90 -0
- package/dist/cjs/chartpoint/index.d.ts.map +1 -0
- package/dist/cjs/chartpoint/index.js +56 -0
- package/dist/cjs/chartpoint/index.js.map +7 -0
- package/dist/cjs/color/index.d.ts +285 -0
- package/dist/cjs/color/index.d.ts.map +1 -0
- package/dist/cjs/color/index.js +143 -0
- package/dist/cjs/color/index.js.map +7 -0
- package/dist/cjs/compare/index.d.ts +26 -0
- package/dist/cjs/compare/index.d.ts.map +1 -0
- package/dist/cjs/compare/index.js +50 -0
- package/dist/cjs/compare/index.js.map +7 -0
- package/dist/cjs/drawing/registry.d.ts +42 -0
- package/dist/cjs/drawing/registry.d.ts.map +1 -0
- package/dist/cjs/drawing/registry.js +87 -0
- package/dist/cjs/drawing/registry.js.map +7 -0
- package/dist/cjs/index.d.ts +85 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +184 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/indicator.d.ts +117 -0
- package/dist/cjs/indicator.d.ts.map +1 -0
- package/dist/cjs/indicator.js +74 -0
- package/dist/cjs/indicator.js.map +7 -0
- package/dist/cjs/input.d.ts +196 -0
- package/dist/cjs/input.d.ts.map +1 -0
- package/dist/cjs/input.js +197 -0
- package/dist/cjs/input.js.map +7 -0
- package/dist/cjs/label/index.d.ts +303 -0
- package/dist/cjs/label/index.d.ts.map +1 -0
- package/dist/cjs/label/index.js +190 -0
- package/dist/cjs/label/index.js.map +7 -0
- package/dist/cjs/lib/index.d.ts +8 -0
- package/dist/cjs/lib/index.d.ts.map +1 -0
- package/dist/cjs/lib/index.js +19 -0
- package/dist/cjs/lib/index.js.map +7 -0
- package/dist/{lib → cjs/lib}/zigzag/index.d.ts +4 -1
- package/dist/cjs/lib/zigzag/index.d.ts.map +1 -0
- package/dist/cjs/lib/zigzag/index.js +27 -0
- package/dist/cjs/lib/zigzag/index.js.map +7 -0
- package/dist/cjs/lib/zigzag/zigzag.d.ts +100 -0
- package/dist/cjs/lib/zigzag/zigzag.d.ts.map +1 -0
- package/dist/cjs/lib/zigzag/zigzag.js +207 -0
- package/dist/cjs/lib/zigzag/zigzag.js.map +7 -0
- package/dist/cjs/line/index.d.ts +342 -0
- package/dist/cjs/line/index.d.ts.map +1 -0
- package/dist/cjs/line/index.js +193 -0
- package/dist/cjs/line/index.js.map +7 -0
- package/dist/cjs/linefill/index.d.ts +124 -0
- package/dist/cjs/linefill/index.d.ts.map +1 -0
- package/dist/cjs/linefill/index.js +56 -0
- package/dist/cjs/linefill/index.js.map +7 -0
- package/dist/cjs/map/index.d.ts +69 -0
- package/dist/cjs/map/index.d.ts.map +1 -0
- package/dist/cjs/map/index.js +80 -0
- package/dist/cjs/map/index.js.map +7 -0
- package/dist/cjs/math/index.d.ts +560 -0
- package/dist/cjs/math/index.d.ts.map +1 -0
- package/dist/cjs/math/index.js +441 -0
- package/dist/cjs/math/index.js.map +7 -0
- package/dist/cjs/matrix/index.d.ts +1231 -0
- package/dist/cjs/matrix/index.d.ts.map +1 -0
- package/dist/cjs/matrix/index.js +1200 -0
- package/dist/cjs/matrix/index.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plot.d.ts +76 -0
- package/dist/cjs/plot.d.ts.map +1 -0
- package/dist/cjs/plot.js +51 -0
- package/dist/cjs/plot.js.map +7 -0
- package/dist/cjs/polyline/index.d.ts +115 -0
- package/dist/cjs/polyline/index.d.ts.map +1 -0
- package/dist/cjs/polyline/index.js +76 -0
- package/dist/cjs/polyline/index.js.map +7 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.d.ts +86 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.d.ts.map +1 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.js +141 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.js.map +7 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.d.ts +59 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.d.ts.map +1 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.js +117 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.js.map +7 -0
- package/dist/{runtime → cjs/runtime}/index.d.ts +12 -5
- package/dist/cjs/runtime/index.d.ts.map +1 -0
- package/dist/cjs/runtime/index.js +49 -0
- package/dist/cjs/runtime/index.js.map +7 -0
- package/dist/cjs/runtime/inputs.d.ts +91 -0
- package/dist/cjs/runtime/inputs.d.ts.map +1 -0
- package/dist/cjs/runtime/inputs.js +262 -0
- package/dist/cjs/runtime/inputs.js.map +7 -0
- package/dist/cjs/runtime/runtime.d.ts +70 -0
- package/dist/cjs/runtime/runtime.d.ts.map +1 -0
- package/dist/cjs/runtime/runtime.js +148 -0
- package/dist/cjs/runtime/runtime.js.map +7 -0
- package/dist/cjs/runtime/series.d.ts +362 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -0
- package/dist/cjs/runtime/series.js +560 -0
- package/dist/cjs/runtime/series.js.map +7 -0
- package/dist/cjs/runtime/types.d.ts +282 -0
- package/dist/cjs/runtime/types.d.ts.map +1 -0
- package/dist/cjs/runtime/types.js +17 -0
- package/dist/cjs/runtime/types.js.map +7 -0
- package/dist/cjs/script/index.d.ts +987 -0
- package/dist/cjs/script/index.d.ts.map +1 -0
- package/dist/cjs/script/index.js +1169 -0
- package/dist/cjs/script/index.js.map +7 -0
- package/dist/cjs/security/resample.d.ts +63 -0
- package/dist/cjs/security/resample.d.ts.map +1 -0
- package/dist/cjs/security/resample.js +84 -0
- package/dist/cjs/security/resample.js.map +7 -0
- package/dist/cjs/session/bars.d.ts +80 -0
- package/dist/cjs/session/bars.d.ts.map +1 -0
- package/dist/cjs/session/bars.js +219 -0
- package/dist/cjs/session/bars.js.map +7 -0
- package/dist/cjs/session/calendar.d.ts +70 -0
- package/dist/cjs/session/calendar.d.ts.map +1 -0
- package/dist/cjs/session/calendar.js +164 -0
- package/dist/cjs/session/calendar.js.map +7 -0
- package/dist/cjs/str/dateformat.d.ts +15 -0
- package/dist/cjs/str/dateformat.d.ts.map +1 -0
- package/dist/cjs/str/dateformat.js +149 -0
- package/dist/cjs/str/dateformat.js.map +7 -0
- package/dist/cjs/str/index.d.ts +459 -0
- package/dist/cjs/str/index.d.ts.map +1 -0
- package/dist/cjs/str/index.js +143 -0
- package/dist/cjs/str/index.js.map +7 -0
- package/dist/cjs/str/messageformat.d.ts +14 -0
- package/dist/cjs/str/messageformat.d.ts.map +1 -0
- package/dist/cjs/str/messageformat.js +114 -0
- package/dist/cjs/str/messageformat.js.map +7 -0
- package/dist/cjs/str/numberformat.d.ts +19 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -0
- package/dist/cjs/str/numberformat.js +170 -0
- package/dist/cjs/str/numberformat.js.map +7 -0
- package/dist/{strategy → cjs/strategy}/index.d.ts +50 -0
- package/dist/cjs/strategy/index.d.ts.map +1 -0
- package/dist/cjs/strategy/index.js +92 -0
- package/dist/cjs/strategy/index.js.map +7 -0
- package/dist/cjs/ta/index.d.ts +1397 -0
- package/dist/cjs/ta/index.d.ts.map +1 -0
- package/dist/cjs/ta/index.js +1715 -0
- package/dist/cjs/ta/index.js.map +7 -0
- package/dist/cjs/ta/running-sum.d.ts +30 -0
- package/dist/cjs/ta/running-sum.d.ts.map +1 -0
- package/dist/cjs/ta/running-sum.js +99 -0
- package/dist/cjs/ta/running-sum.js.map +7 -0
- package/dist/cjs/ta-series.d.ts +558 -0
- package/dist/cjs/ta-series.d.ts.map +1 -0
- package/dist/cjs/ta-series.js +606 -0
- package/dist/cjs/ta-series.js.map +7 -0
- package/dist/cjs/text/index.d.ts +14 -0
- package/dist/cjs/text/index.d.ts.map +1 -0
- package/dist/cjs/text/index.js +29 -0
- package/dist/cjs/text/index.js.map +7 -0
- package/dist/cjs/time/datestring.d.ts +23 -0
- package/dist/cjs/time/datestring.d.ts.map +1 -0
- package/dist/cjs/time/datestring.js +106 -0
- package/dist/cjs/time/datestring.js.map +7 -0
- package/dist/cjs/time/index.d.ts +89 -0
- package/dist/cjs/time/index.d.ts.map +1 -0
- package/dist/cjs/time/index.js +85 -0
- package/dist/cjs/time/index.js.map +7 -0
- package/dist/cjs/time/session.d.ts +17 -0
- package/dist/cjs/time/session.d.ts.map +1 -0
- package/dist/cjs/time/session.js +65 -0
- package/dist/cjs/time/session.js.map +7 -0
- package/dist/cjs/time/timezone.d.ts +40 -0
- package/dist/cjs/time/timezone.d.ts.map +1 -0
- package/dist/cjs/time/timezone.js +125 -0
- package/dist/cjs/time/timezone.js.map +7 -0
- package/dist/cjs/timeframe/index.d.ts +73 -0
- package/dist/cjs/timeframe/index.d.ts.map +1 -0
- package/dist/cjs/timeframe/index.js +85 -0
- package/dist/cjs/timeframe/index.js.map +7 -0
- package/dist/cjs/types/index.d.ts +343 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +32 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/metadata.d.ts +300 -0
- package/dist/cjs/types/metadata.d.ts.map +1 -0
- package/dist/cjs/types/metadata.js +17 -0
- package/dist/cjs/types/metadata.js.map +7 -0
- package/dist/cjs/utils/index.d.ts +167 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +209 -0
- package/dist/cjs/utils/index.js.map +7 -0
- package/dist/esm/array/index.d.ts +701 -0
- package/dist/esm/array/index.d.ts.map +1 -0
- package/dist/esm/array/index.js +983 -0
- package/dist/esm/array/index.js.map +1 -0
- package/dist/esm/box/index.d.ts +444 -0
- package/dist/esm/box/index.d.ts.map +1 -0
- package/dist/esm/box/index.js +602 -0
- package/dist/esm/box/index.js.map +1 -0
- package/dist/esm/callsite/index.d.ts +61 -0
- package/dist/esm/callsite/index.d.ts.map +1 -0
- package/dist/esm/callsite/index.js +97 -0
- package/dist/esm/callsite/index.js.map +1 -0
- package/dist/esm/chartpoint/index.d.ts +90 -0
- package/dist/esm/chartpoint/index.d.ts.map +1 -0
- package/dist/esm/chartpoint/index.js +113 -0
- package/dist/esm/chartpoint/index.js.map +1 -0
- package/dist/esm/color/index.d.ts +285 -0
- package/dist/esm/color/index.d.ts.map +1 -0
- package/dist/esm/color/index.js +373 -0
- package/dist/esm/color/index.js.map +1 -0
- package/dist/esm/compare/index.d.ts +26 -0
- package/dist/esm/compare/index.d.ts.map +1 -0
- package/dist/esm/compare/index.js +39 -0
- package/dist/esm/compare/index.js.map +1 -0
- package/dist/esm/drawing/registry.d.ts +42 -0
- package/dist/esm/drawing/registry.d.ts.map +1 -0
- package/dist/esm/drawing/registry.js +89 -0
- package/dist/esm/drawing/registry.js.map +1 -0
- package/dist/esm/index.d.ts +85 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +96 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indicator.d.ts +117 -0
- package/dist/esm/indicator.d.ts.map +1 -0
- package/dist/esm/indicator.js +84 -0
- package/dist/esm/indicator.js.map +1 -0
- package/dist/esm/input.d.ts +196 -0
- package/dist/esm/input.d.ts.map +1 -0
- package/dist/esm/input.js +183 -0
- package/dist/esm/input.js.map +1 -0
- package/dist/esm/label/index.d.ts +303 -0
- package/dist/esm/label/index.d.ts.map +1 -0
- package/dist/esm/label/index.js +417 -0
- package/dist/esm/label/index.js.map +1 -0
- package/dist/esm/lib/index.d.ts +8 -0
- package/dist/esm/lib/index.d.ts.map +1 -0
- package/dist/esm/lib/index.js +8 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/zigzag/index.d.ts +5 -0
- package/dist/esm/lib/zigzag/index.d.ts.map +1 -0
- package/dist/esm/lib/zigzag/index.js +5 -0
- package/dist/esm/lib/zigzag/index.js.map +1 -0
- package/dist/esm/lib/zigzag/zigzag.d.ts +100 -0
- package/dist/esm/lib/zigzag/zigzag.d.ts.map +1 -0
- package/dist/esm/lib/zigzag/zigzag.js +229 -0
- package/dist/esm/lib/zigzag/zigzag.js.map +1 -0
- package/dist/esm/line/index.d.ts +342 -0
- package/dist/esm/line/index.d.ts.map +1 -0
- package/dist/esm/line/index.js +470 -0
- package/dist/esm/line/index.js.map +1 -0
- package/dist/esm/linefill/index.d.ts +124 -0
- package/dist/esm/linefill/index.d.ts.map +1 -0
- package/dist/esm/linefill/index.js +144 -0
- package/dist/esm/linefill/index.js.map +1 -0
- package/dist/esm/map/index.d.ts +69 -0
- package/dist/esm/map/index.d.ts.map +1 -0
- package/dist/esm/map/index.js +106 -0
- package/dist/esm/map/index.js.map +1 -0
- package/dist/esm/math/index.d.ts +560 -0
- package/dist/esm/math/index.d.ts.map +1 -0
- package/dist/esm/math/index.js +495 -0
- package/dist/esm/math/index.js.map +1 -0
- package/dist/esm/matrix/index.d.ts +1231 -0
- package/dist/esm/matrix/index.d.ts.map +1 -0
- package/dist/esm/matrix/index.js +2450 -0
- package/dist/esm/matrix/index.js.map +1 -0
- package/dist/esm/plot.d.ts +76 -0
- package/dist/esm/plot.d.ts.map +1 -0
- package/dist/esm/plot.js +63 -0
- package/dist/esm/plot.js.map +1 -0
- package/dist/esm/polyline/index.d.ts +115 -0
- package/dist/esm/polyline/index.d.ts.map +1 -0
- package/dist/esm/polyline/index.js +157 -0
- package/dist/esm/polyline/index.js.map +1 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.d.ts +86 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.d.ts.map +1 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.js +140 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.js.map +1 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.d.ts +59 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.d.ts.map +1 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.js +115 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.js.map +1 -0
- package/dist/esm/runtime/index.d.ts +13 -0
- package/dist/esm/runtime/index.d.ts.map +1 -0
- package/dist/esm/runtime/index.js +14 -0
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/inputs.d.ts +91 -0
- package/dist/esm/runtime/inputs.d.ts.map +1 -0
- package/dist/esm/runtime/inputs.js +334 -0
- package/dist/esm/runtime/inputs.js.map +1 -0
- package/dist/esm/runtime/runtime.d.ts +70 -0
- package/dist/esm/runtime/runtime.d.ts.map +1 -0
- package/dist/esm/runtime/runtime.js +193 -0
- package/dist/esm/runtime/runtime.js.map +1 -0
- package/dist/esm/runtime/series.d.ts +362 -0
- package/dist/esm/runtime/series.d.ts.map +1 -0
- package/dist/esm/runtime/series.js +583 -0
- package/dist/esm/runtime/series.js.map +1 -0
- package/dist/esm/runtime/types.d.ts +282 -0
- package/dist/esm/runtime/types.d.ts.map +1 -0
- package/dist/esm/runtime/types.js +7 -0
- package/dist/esm/runtime/types.js.map +1 -0
- package/dist/esm/script/index.d.ts +987 -0
- package/dist/esm/script/index.d.ts.map +1 -0
- package/dist/esm/script/index.js +1289 -0
- package/dist/esm/script/index.js.map +1 -0
- package/dist/esm/security/resample.d.ts +63 -0
- package/dist/esm/security/resample.d.ts.map +1 -0
- package/dist/esm/security/resample.js +110 -0
- package/dist/esm/security/resample.js.map +1 -0
- package/dist/esm/session/bars.d.ts +80 -0
- package/dist/esm/session/bars.d.ts.map +1 -0
- package/dist/esm/session/bars.js +232 -0
- package/dist/esm/session/bars.js.map +1 -0
- package/dist/esm/session/calendar.d.ts +70 -0
- package/dist/esm/session/calendar.d.ts.map +1 -0
- package/dist/esm/session/calendar.js +172 -0
- package/dist/esm/session/calendar.js.map +1 -0
- package/dist/esm/str/dateformat.d.ts +15 -0
- package/dist/esm/str/dateformat.d.ts.map +1 -0
- package/dist/esm/str/dateformat.js +136 -0
- package/dist/esm/str/dateformat.js.map +1 -0
- package/dist/esm/str/index.d.ts +459 -0
- package/dist/esm/str/index.d.ts.map +1 -0
- package/dist/esm/str/index.js +540 -0
- package/dist/esm/str/index.js.map +1 -0
- package/dist/esm/str/messageformat.d.ts +14 -0
- package/dist/esm/str/messageformat.d.ts.map +1 -0
- package/dist/esm/str/messageformat.js +111 -0
- package/dist/esm/str/messageformat.js.map +1 -0
- package/dist/esm/str/numberformat.d.ts +19 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -0
- package/dist/esm/str/numberformat.js +189 -0
- package/dist/esm/str/numberformat.js.map +1 -0
- package/dist/esm/strategy/index.d.ts +245 -0
- package/dist/esm/strategy/index.d.ts.map +1 -0
- package/dist/esm/strategy/index.js +84 -0
- package/dist/esm/strategy/index.js.map +1 -0
- package/dist/esm/ta/index.d.ts +1397 -0
- package/dist/esm/ta/index.d.ts.map +1 -0
- package/dist/esm/ta/index.js +3227 -0
- package/dist/esm/ta/index.js.map +1 -0
- package/dist/esm/ta/running-sum.d.ts +30 -0
- package/dist/esm/ta/running-sum.d.ts.map +1 -0
- package/dist/esm/ta/running-sum.js +113 -0
- package/dist/esm/ta/running-sum.js.map +1 -0
- package/dist/esm/ta-series.d.ts +558 -0
- package/dist/esm/ta-series.d.ts.map +1 -0
- package/dist/esm/ta-series.js +910 -0
- package/dist/esm/ta-series.js.map +1 -0
- package/dist/esm/text/index.d.ts +14 -0
- package/dist/esm/text/index.d.ts.map +1 -0
- package/dist/esm/text/index.js +14 -0
- package/dist/esm/text/index.js.map +1 -0
- package/dist/esm/time/datestring.d.ts +23 -0
- package/dist/esm/time/datestring.d.ts.map +1 -0
- package/dist/esm/time/datestring.js +94 -0
- package/dist/esm/time/datestring.js.map +1 -0
- package/dist/esm/time/index.d.ts +89 -0
- package/dist/esm/time/index.d.ts.map +1 -0
- package/dist/esm/time/index.js +108 -0
- package/dist/esm/time/index.js.map +1 -0
- package/dist/esm/time/session.d.ts +17 -0
- package/dist/esm/time/session.d.ts.map +1 -0
- package/dist/esm/time/session.js +69 -0
- package/dist/esm/time/session.js.map +1 -0
- package/dist/esm/time/timezone.d.ts +40 -0
- package/dist/esm/time/timezone.d.ts.map +1 -0
- package/dist/esm/time/timezone.js +144 -0
- package/dist/esm/time/timezone.js.map +1 -0
- package/dist/esm/timeframe/index.d.ts +73 -0
- package/dist/esm/timeframe/index.d.ts.map +1 -0
- package/dist/esm/timeframe/index.js +131 -0
- package/dist/esm/timeframe/index.js.map +1 -0
- package/dist/esm/types/index.d.ts +343 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +17 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/metadata.d.ts +300 -0
- package/dist/esm/types/metadata.d.ts.map +1 -0
- package/dist/esm/types/metadata.js +7 -0
- package/dist/esm/types/metadata.js.map +1 -0
- package/dist/esm/utils/index.d.ts +167 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +295 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/package.json +53 -23
- package/src/array/index.ts +1056 -0
- package/src/box/index.ts +680 -0
- package/src/callsite/index.ts +104 -0
- package/src/chartpoint/index.ts +126 -0
- package/src/color/index.ts +411 -0
- package/src/compare/index.ts +46 -0
- package/src/drawing/registry.ts +106 -0
- package/src/index.ts +201 -0
- package/src/indicator.ts +185 -0
- package/src/input.ts +280 -0
- package/src/label/index.ts +490 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/zigzag/index.ts +13 -0
- package/src/lib/zigzag/zigzag.ts +318 -0
- package/src/line/index.ts +530 -0
- package/src/linefill/index.ts +152 -0
- package/src/map/index.ts +115 -0
- package/src/math/index.ts +1071 -0
- package/src/matrix/index.ts +2697 -0
- package/src/plot.ts +121 -0
- package/src/polyline/index.ts +184 -0
- package/src/runtime/adapters/LightweightChartsAdapter.ts +201 -0
- package/src/runtime/adapters/SimpleInputAdapter.ts +132 -0
- package/src/runtime/index.ts +52 -0
- package/src/runtime/inputs.ts +377 -0
- package/src/runtime/runtime.ts +241 -0
- package/src/runtime/series.ts +644 -0
- package/src/runtime/types.ts +292 -0
- package/src/script/index.ts +1865 -0
- package/src/security/resample.ts +119 -0
- package/src/session/bars.ts +262 -0
- package/src/session/calendar.ts +199 -0
- package/src/str/dateformat.ts +104 -0
- package/src/str/index.ts +557 -0
- package/src/str/messageformat.ts +109 -0
- package/src/str/numberformat.ts +197 -0
- package/src/strategy/index.ts +281 -0
- package/src/ta/index.ts +3580 -0
- package/src/ta/running-sum.ts +117 -0
- package/src/ta-series.ts +1036 -0
- package/src/text/index.ts +14 -0
- package/src/time/datestring.ts +96 -0
- package/src/time/index.ts +161 -0
- package/src/time/session.ts +79 -0
- package/src/time/timezone.ts +180 -0
- package/src/timeframe/index.ts +144 -0
- package/src/types/index.ts +398 -0
- package/src/types/metadata.ts +334 -0
- package/src/utils/index.ts +334 -0
- package/dist/array/index.d.ts +0 -57
- package/dist/array/index.d.ts.map +0 -1
- package/dist/box/index.d.ts +0 -37
- package/dist/box/index.d.ts.map +0 -1
- package/dist/callsite/index.d.ts +0 -7
- package/dist/callsite/index.d.ts.map +0 -1
- package/dist/chartpoint/index.d.ts +0 -8
- package/dist/chartpoint/index.d.ts.map +0 -1
- package/dist/color/index.d.ts +0 -28
- package/dist/color/index.d.ts.map +0 -1
- package/dist/compare/index.d.ts +0 -8
- package/dist/compare/index.d.ts.map +0 -1
- package/dist/drawing/registry.d.ts +0 -19
- package/dist/drawing/registry.d.ts.map +0 -1
- package/dist/index.cjs +0 -7979
- package/dist/index.d.ts +0 -64
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -7962
- package/dist/indicator.d.ts +0 -42
- package/dist/indicator.d.ts.map +0 -1
- package/dist/input.d.ts +0 -47
- package/dist/input.d.ts.map +0 -1
- package/dist/label/index.d.ts +0 -30
- package/dist/label/index.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -2
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/zigzag/index.d.ts.map +0 -1
- package/dist/lib/zigzag/zigzag.d.ts +0 -47
- package/dist/lib/zigzag/zigzag.d.ts.map +0 -1
- package/dist/line/index.d.ts +0 -30
- package/dist/line/index.d.ts.map +0 -1
- package/dist/linefill/index.d.ts +0 -10
- package/dist/linefill/index.d.ts.map +0 -1
- package/dist/map/index.d.ts +0 -14
- package/dist/map/index.d.ts.map +0 -1
- package/dist/math/index.d.ts +0 -53
- package/dist/math/index.d.ts.map +0 -1
- package/dist/matrix/index.d.ts +0 -52
- package/dist/matrix/index.d.ts.map +0 -1
- package/dist/plot.d.ts +0 -20
- package/dist/plot.d.ts.map +0 -1
- package/dist/polyline/index.d.ts +0 -11
- package/dist/polyline/index.d.ts.map +0 -1
- package/dist/runtime/adapters/LightweightChartsAdapter.d.ts +0 -15
- package/dist/runtime/adapters/LightweightChartsAdapter.d.ts.map +0 -1
- package/dist/runtime/adapters/SimpleInputAdapter.d.ts +0 -16
- package/dist/runtime/adapters/SimpleInputAdapter.d.ts.map +0 -1
- package/dist/runtime/index.cjs +0 -600
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.mjs +0 -577
- package/dist/runtime/inputs.d.ts +0 -13
- package/dist/runtime/inputs.d.ts.map +0 -1
- package/dist/runtime/runtime.d.ts +0 -16
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/series.d.ts +0 -60
- package/dist/runtime/series.d.ts.map +0 -1
- package/dist/runtime/types.d.ts +0 -122
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/script/index.cjs +0 -6372
- package/dist/script/index.d.ts +0 -709
- package/dist/script/index.d.ts.map +0 -1
- package/dist/script/index.mjs +0 -6355
- package/dist/security/resample.d.ts +0 -13
- package/dist/security/resample.d.ts.map +0 -1
- package/dist/session/bars.d.ts +0 -34
- package/dist/session/bars.d.ts.map +0 -1
- package/dist/session/calendar.d.ts +0 -31
- package/dist/session/calendar.d.ts.map +0 -1
- package/dist/str/dateformat.d.ts +0 -2
- package/dist/str/dateformat.d.ts.map +0 -1
- package/dist/str/index.d.ts +0 -24
- package/dist/str/index.d.ts.map +0 -1
- package/dist/str/messageformat.d.ts +0 -2
- package/dist/str/messageformat.d.ts.map +0 -1
- package/dist/str/numberformat.d.ts +0 -3
- package/dist/str/numberformat.d.ts.map +0 -1
- package/dist/strategy/index.d.ts.map +0 -1
- package/dist/ta/index.d.ts +0 -72
- package/dist/ta/index.d.ts.map +0 -1
- package/dist/ta-series.d.ts +0 -143
- package/dist/ta-series.d.ts.map +0 -1
- package/dist/text/index.d.ts +0 -4
- package/dist/text/index.d.ts.map +0 -1
- package/dist/time/datestring.d.ts +0 -2
- package/dist/time/datestring.d.ts.map +0 -1
- package/dist/time/index.d.ts +0 -15
- package/dist/time/index.d.ts.map +0 -1
- package/dist/time/session.d.ts +0 -2
- package/dist/time/session.d.ts.map +0 -1
- package/dist/time/timezone.d.ts +0 -13
- package/dist/time/timezone.d.ts.map +0 -1
- package/dist/timeframe/index.d.ts +0 -17
- package/dist/timeframe/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -181
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/metadata.d.ts +0 -131
- package/dist/types/metadata.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -26
- package/dist/utils/index.d.ts.map +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line namespace
|
|
3
|
+
* Functions for creating and manipulating line drawing objects.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* While lines are primarily visual in PineScript, the line.get_price() function provides
|
|
7
|
+
* computational value for algorithmic trading - calculating trend line breakouts,
|
|
8
|
+
* support/resistance levels, and pattern recognition.
|
|
9
|
+
*
|
|
10
|
+
* @version 6
|
|
11
|
+
*/
|
|
12
|
+
import type { ChartPoint, Line, color } from '../types/index.js';
|
|
13
|
+
type LineXloc = 'bar_index' | 'bar_time';
|
|
14
|
+
type LineExtend = 'none' | 'left' | 'right' | 'both';
|
|
15
|
+
type LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new line (PineScript `line.new`), with two chart points or with coordinates:
|
|
18
|
+
*
|
|
19
|
+
* - `line.new(first_point, second_point, xloc?, extend?, color?, style?, width?, force_overlay?)`
|
|
20
|
+
* - `line.new(x1, y1, x2, y2, xloc?, extend?, color?, style?, width?, force_overlay?)`
|
|
21
|
+
*
|
|
22
|
+
* With chart points, x is `point.index` for `bar_index` lines and `point.time` for `bar_time` lines.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Create a trend line from bar 0 (price 100) to bar 50 (price 150)
|
|
27
|
+
* const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');
|
|
28
|
+
* const fromPoints = line.new(chartPoint.from_index(0, 100), chartPoint.from_index(50, 150));
|
|
29
|
+
*
|
|
30
|
+
* // Calculate price at bar 75 (extrapolated)
|
|
31
|
+
* const price = line.get_price(trendLine, 75); // Returns 175
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function new_line(first_point: ChartPoint, second_point: ChartPoint, xloc?: LineXloc, extend?: LineExtend, lineColor?: color, style?: LineStyle, width?: number, force_overlay?: boolean): Line;
|
|
35
|
+
export declare function new_line(x1: number, y1: number, x2: number, y2: number, xloc?: LineXloc, extend?: LineExtend, lineColor?: color, style?: LineStyle, width?: number, force_overlay?: boolean): Line;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the price level of a line at a given bar index.
|
|
38
|
+
*
|
|
39
|
+
* @param id - Line object
|
|
40
|
+
* @param x - Bar index to calculate price at
|
|
41
|
+
* @returns Price level at the given bar index, or NaN if outside bounds and not extended
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* - **CRITICAL COMPUTATIONAL FUNCTION** - Enables trend line breakout detection
|
|
45
|
+
* - Uses linear interpolation: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)
|
|
46
|
+
* - Respects extend mode:
|
|
47
|
+
* - 'none': Returns NaN if x is outside [x1, x2]
|
|
48
|
+
* - 'left': Extends infinitely to the left (x < x1)
|
|
49
|
+
* - 'right': Extends infinitely to the right (x > x2)
|
|
50
|
+
* - 'both': Extends infinitely in both directions
|
|
51
|
+
* - Only works with xloc='bar_index' lines (not xloc='bar_time')
|
|
52
|
+
* - In PineScript, this function treats all lines as if extend='both' regardless of actual setting
|
|
53
|
+
* For compatibility, we follow the actual extend setting
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');
|
|
58
|
+
*
|
|
59
|
+
* // Within segment
|
|
60
|
+
* line.get_price(trendLine, 25); // Returns 125
|
|
61
|
+
*
|
|
62
|
+
* // Extended right
|
|
63
|
+
* line.get_price(trendLine, 100); // Returns 200
|
|
64
|
+
*
|
|
65
|
+
* // Not extended left (with extend='right')
|
|
66
|
+
* line.get_price(trendLine, -10); // Returns NaN
|
|
67
|
+
*
|
|
68
|
+
* // Use for breakout detection
|
|
69
|
+
* const currentPrice = close[close.length - 1];
|
|
70
|
+
* const linePrice = line.get_price(trendLine, close.length - 1);
|
|
71
|
+
* if (currentPrice > linePrice) {
|
|
72
|
+
* console.log('Breakout above trend line!');
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function get_price(id: Line, x: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the first point's x coordinate.
|
|
79
|
+
*
|
|
80
|
+
* @param id - Line object
|
|
81
|
+
* @returns X coordinate of the first point
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const line = line.new(10, 100, 50, 150);
|
|
86
|
+
* const x1 = line.get_x1(line); // Returns 10
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function get_x1(id: Line): number;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the second point's x coordinate.
|
|
92
|
+
*
|
|
93
|
+
* @param id - Line object
|
|
94
|
+
* @returns X coordinate of the second point
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const line = line.new(10, 100, 50, 150);
|
|
99
|
+
* const x2 = line.get_x2(line); // Returns 50
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function get_x2(id: Line): number;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the first point's y coordinate (price level).
|
|
105
|
+
*
|
|
106
|
+
* @param id - Line object
|
|
107
|
+
* @returns Y coordinate (price) of the first point
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const line = line.new(10, 100, 50, 150);
|
|
112
|
+
* const y1 = line.get_y1(line); // Returns 100
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function get_y1(id: Line): number;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the second point's y coordinate (price level).
|
|
118
|
+
*
|
|
119
|
+
* @param id - Line object
|
|
120
|
+
* @returns Y coordinate (price) of the second point
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const line = line.new(10, 100, 50, 150);
|
|
125
|
+
* const y2 = line.get_y2(line); // Returns 150
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function get_y2(id: Line): number;
|
|
129
|
+
/**
|
|
130
|
+
* Creates a copy of the line object.
|
|
131
|
+
*
|
|
132
|
+
* @param id - Line object to copy
|
|
133
|
+
* @returns New line object with same properties
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* Creates a shallow copy of the line. Modifications to the copy won't affect the original.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const originalLine = line.new(0, 100, 50, 150);
|
|
141
|
+
* const copiedLine = line.copy(originalLine);
|
|
142
|
+
*
|
|
143
|
+
* // Modify copy without affecting original
|
|
144
|
+
* copiedLine.y2 = 200;
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function copy(id: Line): Line;
|
|
148
|
+
/**
|
|
149
|
+
* Sets the first point's x coordinate.
|
|
150
|
+
*
|
|
151
|
+
* @param id - Line object to modify
|
|
152
|
+
* @param x - New x coordinate (bar index or timestamp)
|
|
153
|
+
* @returns Modified line object
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const line = line.new(0, 100, 50, 150);
|
|
158
|
+
* line.set_x1(line, 10); // Move first point to bar 10
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare function set_x1(id: Line, x: number): Line;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the second point's x coordinate.
|
|
164
|
+
*
|
|
165
|
+
* @param id - Line object to modify
|
|
166
|
+
* @param x - New x coordinate (bar index or timestamp)
|
|
167
|
+
* @returns Modified line object
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const line = line.new(0, 100, 50, 150);
|
|
172
|
+
* line.set_x2(line, 60); // Move second point to bar 60
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function set_x2(id: Line, x: number): Line;
|
|
176
|
+
/**
|
|
177
|
+
* Sets the first point's y coordinate (price level).
|
|
178
|
+
*
|
|
179
|
+
* @param id - Line object to modify
|
|
180
|
+
* @param y - New y coordinate (price)
|
|
181
|
+
* @returns Modified line object
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const line = line.new(0, 100, 50, 150);
|
|
186
|
+
* line.set_y1(line, 110); // Move first point to price 110
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function set_y1(id: Line, y: number): Line;
|
|
190
|
+
/**
|
|
191
|
+
* Sets the second point's y coordinate (price level).
|
|
192
|
+
*
|
|
193
|
+
* @param id - Line object to modify
|
|
194
|
+
* @param y - New y coordinate (price)
|
|
195
|
+
* @returns Modified line object
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const line = line.new(0, 100, 50, 150);
|
|
200
|
+
* line.set_y2(line, 160); // Move second point to price 160
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare function set_y2(id: Line, y: number): Line;
|
|
204
|
+
/**
|
|
205
|
+
* Sets both coordinates of the first point.
|
|
206
|
+
*
|
|
207
|
+
* @param id - Line object to modify
|
|
208
|
+
* @param x - New x coordinate
|
|
209
|
+
* @param y - New y coordinate
|
|
210
|
+
* @returns Modified line object
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const line = line.new(0, 100, 50, 150);
|
|
215
|
+
* line.set_xy1(line, 5, 105); // Move first point to (5, 105)
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function set_xy1(id: Line, x: number, y: number): Line;
|
|
219
|
+
/**
|
|
220
|
+
* Sets both coordinates of the second point.
|
|
221
|
+
*
|
|
222
|
+
* @param id - Line object to modify
|
|
223
|
+
* @param x - New x coordinate
|
|
224
|
+
* @param y - New y coordinate
|
|
225
|
+
* @returns Modified line object
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const line = line.new(0, 100, 50, 150);
|
|
230
|
+
* line.set_xy2(line, 60, 160); // Move second point to (60, 160)
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export declare function set_xy2(id: Line, x: number, y: number): Line;
|
|
234
|
+
/**
|
|
235
|
+
* Sets the coordinate system for the line.
|
|
236
|
+
*
|
|
237
|
+
* @param id - Line object to modify
|
|
238
|
+
* @param x1 - New first point x coordinate
|
|
239
|
+
* @param x2 - New second point x coordinate
|
|
240
|
+
* @param xloc - New coordinate system ('bar_index' or 'bar_time')
|
|
241
|
+
* @returns Modified line object
|
|
242
|
+
*
|
|
243
|
+
* @remarks
|
|
244
|
+
* When changing xloc, you must provide appropriate x coordinates for the new system.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const line = line.new(0, 100, 50, 150);
|
|
249
|
+
* // Change to timestamp-based coordinates
|
|
250
|
+
* line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export declare function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line;
|
|
254
|
+
/**
|
|
255
|
+
* Sets the extension mode of the line.
|
|
256
|
+
*
|
|
257
|
+
* @param id - Line object to modify
|
|
258
|
+
* @param extend - New extension mode
|
|
259
|
+
* @returns Modified line object
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const line = line.new(0, 100, 50, 150);
|
|
264
|
+
* line.set_extend(line, 'right'); // Extend line to the right
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function set_extend(id: Line, extend: 'none' | 'left' | 'right' | 'both'): Line;
|
|
268
|
+
/**
|
|
269
|
+
* Sets the line color.
|
|
270
|
+
*
|
|
271
|
+
* @param id - Line object to modify
|
|
272
|
+
* @param color - New line color
|
|
273
|
+
* @returns Modified line object
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const line = line.new(0, 100, 50, 150);
|
|
278
|
+
* line.set_color(line, '#FF0000'); // Change to red
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function set_color(id: Line, lineColor: color): Line;
|
|
282
|
+
/**
|
|
283
|
+
* Sets the line style.
|
|
284
|
+
*
|
|
285
|
+
* @param id - Line object to modify
|
|
286
|
+
* @param style - New line style
|
|
287
|
+
* @returns Modified line object
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const line = line.new(0, 100, 50, 150);
|
|
292
|
+
* line.set_style(line, 'dashed'); // Change to dashed line
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export declare function set_style(id: Line, style: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both'): Line;
|
|
296
|
+
/**
|
|
297
|
+
* Sets the line width.
|
|
298
|
+
*
|
|
299
|
+
* @param id - Line object to modify
|
|
300
|
+
* @param width - New line width in pixels
|
|
301
|
+
* @returns Modified line object
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const line = line.new(0, 100, 50, 150);
|
|
306
|
+
* line.set_width(line, 3); // Make line thicker
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export declare function set_width(id: Line, width: number): Line;
|
|
310
|
+
/**
|
|
311
|
+
* Deletes the line object.
|
|
312
|
+
*
|
|
313
|
+
* @param id - Line object to delete
|
|
314
|
+
*
|
|
315
|
+
* @remarks
|
|
316
|
+
* Removes the line from `line.all()`. As in PineScript, the deleted line is `na`: its getters
|
|
317
|
+
* return NaN and its setters do nothing. Deleting it twice has no effect. Deleting a line also deletes the linefills that use it.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const line = line.new(0, 100, 50, 150);
|
|
322
|
+
* line.delete(line);
|
|
323
|
+
* // line.all() no longer contains it
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
export declare function delete_line(id: Line): void;
|
|
327
|
+
/**
|
|
328
|
+
* All live lines, in creation order (PineScript `line.all`). A new array: later changes do not affect it.
|
|
329
|
+
*/
|
|
330
|
+
export declare function all(): Line[];
|
|
331
|
+
/**
|
|
332
|
+
* Sets the first point of the line from a chart point: `point.index` for `bar_index` lines,
|
|
333
|
+
* `point.time` for `bar_time` lines (`na` when the point does not have it), and `point.price`.
|
|
334
|
+
*/
|
|
335
|
+
export declare function set_first_point(id: Line, point: ChartPoint): Line;
|
|
336
|
+
/**
|
|
337
|
+
* Sets the second point of the line from a chart point (see {@link set_first_point}).
|
|
338
|
+
*/
|
|
339
|
+
export declare function set_second_point(id: Line, point: ChartPoint): Line;
|
|
340
|
+
export { new_line as new };
|
|
341
|
+
export { delete_line as delete };
|
|
342
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEjE,KAAK,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;AACzC,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AACrD,KAAK,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC;AAE7F;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,UAAU,EACvB,YAAY,EAAE,UAAU,EACxB,IAAI,CAAC,EAAE,QAAQ,EACf,MAAM,CAAC,EAAE,UAAU,EACnB,SAAS,CAAC,EAAE,KAAK,EACjB,KAAK,CAAC,EAAE,SAAS,EAC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AAE,IAAI,GAAG,IAAI,CAE1C;AAQD;;GAEG;AACH,wBAAgB,GAAG,IAAI,IAAI,EAAE,CAE5B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAKjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAKlE;AAGD,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,CAAC;AAC3B,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all2) => {
|
|
7
|
+
for (var name in all2)
|
|
8
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var line_exports = {};
|
|
20
|
+
__export(line_exports, {
|
|
21
|
+
all: () => all,
|
|
22
|
+
copy: () => copy,
|
|
23
|
+
delete: () => delete_line,
|
|
24
|
+
delete_line: () => delete_line,
|
|
25
|
+
get_price: () => get_price,
|
|
26
|
+
get_x1: () => get_x1,
|
|
27
|
+
get_x2: () => get_x2,
|
|
28
|
+
get_y1: () => get_y1,
|
|
29
|
+
get_y2: () => get_y2,
|
|
30
|
+
new: () => new_line,
|
|
31
|
+
new_line: () => new_line,
|
|
32
|
+
set_color: () => set_color,
|
|
33
|
+
set_extend: () => set_extend,
|
|
34
|
+
set_first_point: () => set_first_point,
|
|
35
|
+
set_second_point: () => set_second_point,
|
|
36
|
+
set_style: () => set_style,
|
|
37
|
+
set_width: () => set_width,
|
|
38
|
+
set_x1: () => set_x1,
|
|
39
|
+
set_x2: () => set_x2,
|
|
40
|
+
set_xloc: () => set_xloc,
|
|
41
|
+
set_xy1: () => set_xy1,
|
|
42
|
+
set_xy2: () => set_xy2,
|
|
43
|
+
set_y1: () => set_y1,
|
|
44
|
+
set_y2: () => set_y2
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(line_exports);
|
|
47
|
+
var import_registry = require("../drawing/registry.js");
|
|
48
|
+
function new_line(...args) {
|
|
49
|
+
let x1, y1, x2, y2, rest;
|
|
50
|
+
if (typeof args[0] === "object" && args[0] !== null) {
|
|
51
|
+
const [p1, p2, ...others] = args;
|
|
52
|
+
const xloc2 = others[0] ?? "bar_index";
|
|
53
|
+
[x1, y1, x2, y2, rest] = [pointX(p1, xloc2), p1.price, pointX(p2, xloc2), p2.price, others];
|
|
54
|
+
} else {
|
|
55
|
+
[x1, y1, x2, y2] = args;
|
|
56
|
+
rest = args.slice(4);
|
|
57
|
+
}
|
|
58
|
+
const [xloc, extend, lineColor, style, width, force_overlay] = rest;
|
|
59
|
+
return (0, import_registry.register)("line", {
|
|
60
|
+
x1,
|
|
61
|
+
y1,
|
|
62
|
+
x2,
|
|
63
|
+
y2,
|
|
64
|
+
xloc: xloc ?? "bar_index",
|
|
65
|
+
extend: extend ?? "none",
|
|
66
|
+
color: lineColor,
|
|
67
|
+
style: style || "solid",
|
|
68
|
+
width: width || 1,
|
|
69
|
+
force_overlay: force_overlay ?? false
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function get_price(id, x) {
|
|
73
|
+
const { x1, y1, x2, y2, extend, xloc } = id;
|
|
74
|
+
if (xloc === "bar_time") {
|
|
75
|
+
throw new Error("line.get_price() only works with xloc.bar_index lines, not xloc.bar_time");
|
|
76
|
+
}
|
|
77
|
+
if (x2 === x1) {
|
|
78
|
+
return NaN;
|
|
79
|
+
}
|
|
80
|
+
const slope = (y2 - y1) / (x2 - x1);
|
|
81
|
+
const price = y1 + slope * (x - x1);
|
|
82
|
+
if (extend === "none") {
|
|
83
|
+
if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {
|
|
84
|
+
return NaN;
|
|
85
|
+
}
|
|
86
|
+
} else if (extend === "left") {
|
|
87
|
+
if (x > Math.max(x1, x2)) {
|
|
88
|
+
return NaN;
|
|
89
|
+
}
|
|
90
|
+
} else if (extend === "right") {
|
|
91
|
+
if (x < Math.min(x1, x2)) {
|
|
92
|
+
return NaN;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return price;
|
|
96
|
+
}
|
|
97
|
+
function get_x1(id) {
|
|
98
|
+
return id.x1;
|
|
99
|
+
}
|
|
100
|
+
function get_x2(id) {
|
|
101
|
+
return id.x2;
|
|
102
|
+
}
|
|
103
|
+
function get_y1(id) {
|
|
104
|
+
return id.y1;
|
|
105
|
+
}
|
|
106
|
+
function get_y2(id) {
|
|
107
|
+
return id.y2;
|
|
108
|
+
}
|
|
109
|
+
function copy(id) {
|
|
110
|
+
return (0, import_registry.register)("line", { ...id });
|
|
111
|
+
}
|
|
112
|
+
function set_x1(id, x) {
|
|
113
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
114
|
+
id.x1 = x;
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
function set_x2(id, x) {
|
|
118
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
119
|
+
id.x2 = x;
|
|
120
|
+
return id;
|
|
121
|
+
}
|
|
122
|
+
function set_y1(id, y) {
|
|
123
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
124
|
+
id.y1 = y;
|
|
125
|
+
return id;
|
|
126
|
+
}
|
|
127
|
+
function set_y2(id, y) {
|
|
128
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
129
|
+
id.y2 = y;
|
|
130
|
+
return id;
|
|
131
|
+
}
|
|
132
|
+
function set_xy1(id, x, y) {
|
|
133
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
134
|
+
id.x1 = x;
|
|
135
|
+
id.y1 = y;
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
function set_xy2(id, x, y) {
|
|
139
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
140
|
+
id.x2 = x;
|
|
141
|
+
id.y2 = y;
|
|
142
|
+
return id;
|
|
143
|
+
}
|
|
144
|
+
function set_xloc(id, x1, x2, xloc) {
|
|
145
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
146
|
+
id.x1 = x1;
|
|
147
|
+
id.x2 = x2;
|
|
148
|
+
id.xloc = xloc;
|
|
149
|
+
return id;
|
|
150
|
+
}
|
|
151
|
+
function set_extend(id, extend) {
|
|
152
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
153
|
+
id.extend = extend;
|
|
154
|
+
return id;
|
|
155
|
+
}
|
|
156
|
+
function set_color(id, lineColor) {
|
|
157
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
158
|
+
id.color = lineColor;
|
|
159
|
+
return id;
|
|
160
|
+
}
|
|
161
|
+
function set_style(id, style) {
|
|
162
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
163
|
+
id.style = style;
|
|
164
|
+
return id;
|
|
165
|
+
}
|
|
166
|
+
function set_width(id, width) {
|
|
167
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
168
|
+
id.width = width;
|
|
169
|
+
return id;
|
|
170
|
+
}
|
|
171
|
+
function delete_line(id) {
|
|
172
|
+
(0, import_registry.remove)("line", id);
|
|
173
|
+
}
|
|
174
|
+
function pointX(point, xloc) {
|
|
175
|
+
const x = xloc === "bar_time" ? point.time : point.index;
|
|
176
|
+
return x ?? NaN;
|
|
177
|
+
}
|
|
178
|
+
function all() {
|
|
179
|
+
return (0, import_registry.all)("line");
|
|
180
|
+
}
|
|
181
|
+
function set_first_point(id, point) {
|
|
182
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
183
|
+
id.x1 = pointX(point, id.xloc);
|
|
184
|
+
id.y1 = point.price;
|
|
185
|
+
return id;
|
|
186
|
+
}
|
|
187
|
+
function set_second_point(id, point) {
|
|
188
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
189
|
+
id.x2 = pointX(point, id.xloc);
|
|
190
|
+
id.y2 = point.price;
|
|
191
|
+
return id;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/line/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Line namespace\n * Functions for creating and manipulating line drawing objects.\n *\n * @remarks\n * While lines are primarily visual in PineScript, the line.get_price() function provides\n * computational value for algorithmic trading - calculating trend line breakouts,\n * support/resistance levels, and pattern recognition.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Line, color } from '../types/index.js';\n\ntype LineXloc = 'bar_index' | 'bar_time';\ntype LineExtend = 'none' | 'left' | 'right' | 'both';\ntype LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';\n\n/**\n * Creates a new line (PineScript `line.new`), with two chart points or with coordinates:\n *\n * - `line.new(first_point, second_point, xloc?, extend?, color?, style?, width?, force_overlay?)`\n * - `line.new(x1, y1, x2, y2, xloc?, extend?, color?, style?, width?, force_overlay?)`\n *\n * With chart points, x is `point.index` for `bar_index` lines and `point.time` for `bar_time` lines.\n *\n * @example\n * ```typescript\n * // Create a trend line from bar 0 (price 100) to bar 50 (price 150)\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n * const fromPoints = line.new(chartPoint.from_index(0, 100), chartPoint.from_index(50, 150));\n *\n * // Calculate price at bar 75 (extrapolated)\n * const price = line.get_price(trendLine, 75); // Returns 175\n * ```\n */\nexport function new_line(\n first_point: ChartPoint,\n second_point: ChartPoint,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(...args: unknown[]): Line {\n let x1: number, y1: number, x2: number, y2: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [p1, p2, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[0] as LineXloc | undefined) ?? 'bar_index';\n [x1, y1, x2, y2, rest] = [pointX(p1, xloc), p1.price, pointX(p2, xloc), p2.price, others];\n } else {\n [x1, y1, x2, y2] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [xloc, extend, lineColor, style, width, force_overlay] = rest as [\n LineXloc?, LineExtend?, color?, LineStyle?, number?, boolean?,\n ];\n return register('line', {\n x1,\n y1,\n x2,\n y2,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n color: lineColor,\n style: style || 'solid',\n width: width || 1,\n force_overlay: force_overlay ?? false,\n });\n}\n\n/**\n * Returns the price level of a line at a given bar index.\n *\n * @param id - Line object\n * @param x - Bar index to calculate price at\n * @returns Price level at the given bar index, or NaN if outside bounds and not extended\n *\n * @remarks\n * - **CRITICAL COMPUTATIONAL FUNCTION** - Enables trend line breakout detection\n * - Uses linear interpolation: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n * - Respects extend mode:\n * - 'none': Returns NaN if x is outside [x1, x2]\n * - 'left': Extends infinitely to the left (x < x1)\n * - 'right': Extends infinitely to the right (x > x2)\n * - 'both': Extends infinitely in both directions\n * - Only works with xloc='bar_index' lines (not xloc='bar_time')\n * - In PineScript, this function treats all lines as if extend='both' regardless of actual setting\n * For compatibility, we follow the actual extend setting\n *\n * @example\n * ```typescript\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n *\n * // Within segment\n * line.get_price(trendLine, 25); // Returns 125\n *\n * // Extended right\n * line.get_price(trendLine, 100); // Returns 200\n *\n * // Not extended left (with extend='right')\n * line.get_price(trendLine, -10); // Returns NaN\n *\n * // Use for breakout detection\n * const currentPrice = close[close.length - 1];\n * const linePrice = line.get_price(trendLine, close.length - 1);\n * if (currentPrice > linePrice) {\n * console.log('Breakout above trend line!');\n * }\n * ```\n */\nexport function get_price(id: Line, x: number): number {\n const { x1, y1, x2, y2, extend, xloc } = id;\n\n // Only works with bar_index xloc\n if (xloc === 'bar_time') {\n throw new Error('line.get_price() only works with xloc.bar_index lines, not xloc.bar_time');\n }\n\n // Avoid division by zero\n if (x2 === x1) {\n // Vertical line - return NaN or could return y1/y2\n return NaN;\n }\n\n // Linear interpolation formula: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n const slope = (y2 - y1) / (x2 - x1);\n const price = y1 + slope * (x - x1);\n\n // Check bounds based on extend mode\n if (extend === 'none') {\n // Only valid within the segment\n if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'left') {\n // Valid to the left and within, but not to the right\n if (x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'right') {\n // Valid to the right and within, but not to the left\n if (x < Math.min(x1, x2)) {\n return NaN;\n }\n }\n // extend === 'both': always valid\n\n return price;\n}\n\n/**\n * Returns the first point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x1 = line.get_x1(line); // Returns 10\n * ```\n */\nexport function get_x1(id: Line): number {\n return id.x1;\n}\n\n/**\n * Returns the second point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x2 = line.get_x2(line); // Returns 50\n * ```\n */\nexport function get_x2(id: Line): number {\n return id.x2;\n}\n\n/**\n * Returns the first point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y1 = line.get_y1(line); // Returns 100\n * ```\n */\nexport function get_y1(id: Line): number {\n return id.y1;\n}\n\n/**\n * Returns the second point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y2 = line.get_y2(line); // Returns 150\n * ```\n */\nexport function get_y2(id: Line): number {\n return id.y2;\n}\n\n/**\n * Creates a copy of the line object.\n *\n * @param id - Line object to copy\n * @returns New line object with same properties\n *\n * @remarks\n * Creates a shallow copy of the line. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalLine = line.new(0, 100, 50, 150);\n * const copiedLine = line.copy(originalLine);\n *\n * // Modify copy without affecting original\n * copiedLine.y2 = 200;\n * ```\n */\nexport function copy(id: Line): Line {\n return register('line', { ...id });\n}\n\n/**\n * Sets the first point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x1(line, 10); // Move first point to bar 10\n * ```\n */\nexport function set_x1(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n return id;\n}\n\n/**\n * Sets the second point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x2(line, 60); // Move second point to bar 60\n * ```\n */\nexport function set_x2(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n return id;\n}\n\n/**\n * Sets the first point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y1(line, 110); // Move first point to price 110\n * ```\n */\nexport function set_y1(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets the second point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y2(line, 160); // Move second point to price 160\n * ```\n */\nexport function set_y2(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the first point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy1(line, 5, 105); // Move first point to (5, 105)\n * ```\n */\nexport function set_xy1(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the second point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy2(line, 60, 160); // Move second point to (60, 160)\n * ```\n */\nexport function set_xy2(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets the coordinate system for the line.\n *\n * @param id - Line object to modify\n * @param x1 - New first point x coordinate\n * @param x2 - New second point x coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified line object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * // Change to timestamp-based coordinates\n * line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line {\n if (isDeleted(id)) return id;\n id.x1 = x1;\n id.x2 = x2;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the extension mode of the line.\n *\n * @param id - Line object to modify\n * @param extend - New extension mode\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_extend(line, 'right'); // Extend line to the right\n * ```\n */\nexport function set_extend(id: Line, extend: 'none' | 'left' | 'right' | 'both'): Line {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n/**\n * Sets the line color.\n *\n * @param id - Line object to modify\n * @param color - New line color\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_color(line, '#FF0000'); // Change to red\n * ```\n */\nexport function set_color(id: Line, lineColor: color): Line {\n if (isDeleted(id)) return id;\n id.color = lineColor;\n return id;\n}\n\n/**\n * Sets the line style.\n *\n * @param id - Line object to modify\n * @param style - New line style\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_style(line, 'dashed'); // Change to dashed line\n * ```\n */\nexport function set_style(id: Line, style: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both'): Line {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the line width.\n *\n * @param id - Line object to modify\n * @param width - New line width in pixels\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_width(line, 3); // Make line thicker\n * ```\n */\nexport function set_width(id: Line, width: number): Line {\n if (isDeleted(id)) return id;\n id.width = width;\n return id;\n}\n\n/**\n * Deletes the line object.\n *\n * @param id - Line object to delete\n *\n * @remarks\n * Removes the line from `line.all()`. As in PineScript, the deleted line is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect. Deleting a line also deletes the linefills that use it.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.delete(line);\n * // line.all() no longer contains it\n * ```\n */\nexport function delete_line(id: Line): void {\n remove('line', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live lines, in creation order (PineScript `line.all`). A new array: later changes do not affect it.\n */\nexport function all(): Line[] {\n return allDrawings('line');\n}\n\n/**\n * Sets the first point of the line from a chart point: `point.index` for `bar_index` lines,\n * `point.time` for `bar_time` lines (`na` when the point does not have it), and `point.price`.\n */\nexport function set_first_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x1 = pointX(point, id.xloc);\n id.y1 = point.price;\n return id;\n}\n\n/**\n * Sets the second point of the line from a chart point (see {@link set_first_point}).\n */\nexport function set_second_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x2 = pointX(point, id.xloc);\n id.y2 = point.price;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_line as new };\nexport { delete_line as delete };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AA+CzD,SAAS,YAAY,MAAuB;AACjD,MAAI,IAAY,IAAY,IAAY,IAAY;AACpD,MAAI,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