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,1397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Technical Analysis (ta) namespace
|
|
3
|
+
* Mirrors PineScript's ta.* functions for technical analysis indicators and calculations.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* All technical analysis functions in this namespace follow PineScript v6 API specifications.
|
|
7
|
+
*
|
|
8
|
+
* @version 6
|
|
9
|
+
*/
|
|
10
|
+
import type { series_float, series_bool, series_int, Source, simple_int, simple_float, simple_bool } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Simple Moving Average - returns the moving average (sum of last y values divided by y).
|
|
13
|
+
*
|
|
14
|
+
* @param source - Series of values to process
|
|
15
|
+
* @param length - Number of bars (length)
|
|
16
|
+
* @returns Simple moving average of source for length bars back
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* - `na` values (also +/-Infinity) in the source series are ignored: the mean of the last `length` non-`na`
|
|
20
|
+
* values, and a bar with an `na` source keeps the previous result (as in PineScript)
|
|
21
|
+
* - Returns NaN until `length` non-`na` values are available
|
|
22
|
+
* - The sum is a compensated running sum, as in PineScript, so the result can differ from the exact window mean in
|
|
23
|
+
* the last bits (bit for bit with PineScript)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const closePrices = [10, 11, 12, 13, 14];
|
|
28
|
+
* const sma5 = ta.sma(closePrices, 5); // Returns: [NaN, NaN, NaN, NaN, 12]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function sma(source: Source, length: simple_int): series_float;
|
|
32
|
+
/**
|
|
33
|
+
* Exponential Moving Average - returns the exponentially weighted moving average.
|
|
34
|
+
*
|
|
35
|
+
* @param source - Series of values to process
|
|
36
|
+
* @param length - Number of bars (length)
|
|
37
|
+
* @returns Exponential moving average of source with alpha = 2 / (length + 1)
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* - In EMA, weighting factors decrease exponentially
|
|
41
|
+
* - Formula: `EMA = alpha * source + (1 - alpha) * EMA[1]`, where `alpha = 2 / (length + 1)`
|
|
42
|
+
* - `na` values (also +/-Infinity) in the source series are ignored
|
|
43
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
44
|
+
* - May cause indicator repainting
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const closePrices = [10, 11, 12, 13, 14];
|
|
49
|
+
* const ema5 = ta.ema(closePrices, 5);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function ema(source: Source, length: simple_int): series_float;
|
|
53
|
+
/**
|
|
54
|
+
* Relative Strength Index - momentum oscillator measuring speed and magnitude of price changes.
|
|
55
|
+
*
|
|
56
|
+
* @param source - Series of values to process
|
|
57
|
+
* @param length - Number of bars (length)
|
|
58
|
+
* @returns RSI series (values range from 0 to 100)
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* - RSI values above 70 typically indicate overbought conditions
|
|
62
|
+
* - RSI values below 30 typically indicate oversold conditions
|
|
63
|
+
* - Uses `ta.rma()` (Relative Moving Average) for smoothing, matching PineScript v6
|
|
64
|
+
* - Formula: RSI = 100 - (100 / (1 + RS)), where RS = Average Gain / Average Loss
|
|
65
|
+
* - Average Gain and Average Loss are calculated using RMA (alpha = 1 / length)
|
|
66
|
+
* - `na` values in the source series are ignored
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const rsi14 = ta.rsi(closePrices, 14);
|
|
71
|
+
* // Identify overbought/oversold conditions
|
|
72
|
+
* const overbought = rsi14.map(v => v > 70);
|
|
73
|
+
* const oversold = rsi14.map(v => v < 30);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function rsi(source: Source, length: simple_int): series_float;
|
|
77
|
+
/**
|
|
78
|
+
* Moving Average Convergence Divergence - trend-following momentum indicator showing relationship
|
|
79
|
+
* between two moving averages.
|
|
80
|
+
*
|
|
81
|
+
* @param source - Series of values to process
|
|
82
|
+
* @param fastLength - Fast EMA length (typically 12)
|
|
83
|
+
* @param slowLength - Slow EMA length (typically 26)
|
|
84
|
+
* @param signalLength - Signal line EMA length (typically 9)
|
|
85
|
+
* @returns Tuple of [macdLine, signalLine, histogram]
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* - MACD Line = Fast EMA - Slow EMA
|
|
89
|
+
* - Signal Line = EMA of MACD Line
|
|
90
|
+
* - Histogram = MACD Line - Signal Line
|
|
91
|
+
* - Crossovers between MACD and signal line indicate potential buy/sell signals
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const [macdLine, signal, histogram] = ta.macd(closePrices, 12, 26, 9);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function macd(source: Source, fastLength: simple_int, slowLength: simple_int, signalLength: simple_int): [series_float, series_float, series_float];
|
|
99
|
+
/**
|
|
100
|
+
* Bollinger Bands - a technical analysis tool defined by lines plotted two standard deviations
|
|
101
|
+
* away from a simple moving average.
|
|
102
|
+
*
|
|
103
|
+
* @param series - Series of values to process
|
|
104
|
+
* @param length - Number of bars (length)
|
|
105
|
+
* @param mult - Standard deviation factor
|
|
106
|
+
* @returns Tuple of [middle, upper, lower] bands
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* - Middle band is the SMA of the source
|
|
110
|
+
* - Upper band = middle + (mult * standard deviation)
|
|
111
|
+
* - Lower band = middle - (mult * standard deviation)
|
|
112
|
+
* - `na` values in the source series are ignored
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const [middle, upper, lower] = ta.bb(closePrices, 20, 2);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function bb(series: Source, length: simple_int, mult: simple_float): [series_float, series_float, series_float];
|
|
120
|
+
/**
|
|
121
|
+
* Standard deviation over the last `length` non-na values.
|
|
122
|
+
*
|
|
123
|
+
* @param source - Series of values to process
|
|
124
|
+
* @param length - Number of values
|
|
125
|
+
* @param biased - true (default): biased estimate (divides by `length`); false: unbiased (by `length - 1`)
|
|
126
|
+
* @returns Standard deviation series (na until `length` non-na values exist)
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* As in PineScript: `na` values (also +/-Infinity) are skipped, the window holds the last
|
|
130
|
+
* `length` non-na values, and a bar whose own value is `na` keeps the previous result.
|
|
131
|
+
* The result is the square root of {@link variance} (0 when the variance is not positive), computed from
|
|
132
|
+
* compensated running sums of the values and of their squares, bit for bit as PineScript.
|
|
133
|
+
*/
|
|
134
|
+
export declare function stdev(source: Source, length: simple_int, biased?: simple_bool): series_float;
|
|
135
|
+
/**
|
|
136
|
+
* Crossover - returns true when series1 crosses over series2 (moves from below to above).
|
|
137
|
+
*
|
|
138
|
+
* @param series1 - First series
|
|
139
|
+
* @param series2 - Second series
|
|
140
|
+
* @returns Boolean series (true at crossover points)
|
|
141
|
+
*
|
|
142
|
+
* @remarks
|
|
143
|
+
* - True when: series1[i]! > series2[i]! AND series1[i-1] <= series2[i-1]
|
|
144
|
+
* - First value is always false (no previous value to compare)
|
|
145
|
+
* - Useful for detecting bullish signals (e.g., fast MA crossing over slow MA)
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const crossUp = ta.crossover(fastMA, slowMA);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function crossover(series1: Source, series2: Source): series_bool;
|
|
153
|
+
/**
|
|
154
|
+
* Crossunder - returns true when series1 crosses under series2 (moves from above to below).
|
|
155
|
+
*
|
|
156
|
+
* @param series1 - First series
|
|
157
|
+
* @param series2 - Second series
|
|
158
|
+
* @returns Boolean series (true at crossunder points)
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* - True when: series1[i]! < series2[i]! AND series1[i-1] >= series2[i-1]
|
|
162
|
+
* - First value is always false (no previous value to compare)
|
|
163
|
+
* - Useful for detecting bearish signals (e.g., fast MA crossing under slow MA)
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const crossDown = ta.crossunder(fastMA, slowMA);
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function crossunder(series1: Source, series2: Source): series_bool;
|
|
171
|
+
/**
|
|
172
|
+
* Change - calculates the difference between the current value and its value length bars ago.
|
|
173
|
+
*
|
|
174
|
+
* @param source - Series of values to process
|
|
175
|
+
* @param length - Number of bars back (default: 1)
|
|
176
|
+
* @returns Change series (source[i]! - source[i - length])
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* - Returns NaN for the first `length` values
|
|
180
|
+
* - Default length is 1 (difference from previous bar)
|
|
181
|
+
* - Positive values indicate increase, negative values indicate decrease
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const change1 = ta.change(closePrices); // Daily change
|
|
186
|
+
* const change5 = ta.change(closePrices, 5); // 5-day change
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export declare function change(source: Source, length?: simple_int): series_float;
|
|
190
|
+
/**
|
|
191
|
+
* True Range - measures market volatility by calculating the greatest of three price ranges.
|
|
192
|
+
*
|
|
193
|
+
* @param handle_na - Defines how the function calculates when previous close is na (default: false)
|
|
194
|
+
* @param high - High price series (required when not using context API)
|
|
195
|
+
* @param low - Low price series (required when not using context API)
|
|
196
|
+
* @param close - Close price series (required when not using context API)
|
|
197
|
+
* @returns True range series
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* - **PineScript v6 signature**: `ta.tr(handle_na?)` - uses implicit chart data
|
|
201
|
+
* - **JavaScript signature**: Requires explicit `high`, `low`, `close` OR use `createContext()`
|
|
202
|
+
* - True Range = max(high - low, abs(high - close[1]), abs(low - close[1]))
|
|
203
|
+
* - When `handle_na` is true: returns `high - low` if previous close is na
|
|
204
|
+
* - When `handle_na` is false: returns na if previous close is na
|
|
205
|
+
* - Used as a component in ATR calculations
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* // Direct call with explicit data
|
|
210
|
+
* const trueRange = ta.tr(false, high, low, close);
|
|
211
|
+
*
|
|
212
|
+
* // Or use context API for cleaner syntax
|
|
213
|
+
* const { ta } = createContext({ chart: { high, low, close } });
|
|
214
|
+
* const trueRange = ta.tr(); // Matches PineScript!
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare function tr(handle_na?: simple_bool, high?: Source, low?: Source, close?: Source): series_float;
|
|
218
|
+
/**
|
|
219
|
+
* Average True Range - returns the RMA (Relative Moving Average) of true range.
|
|
220
|
+
*
|
|
221
|
+
* @param length - Number of bars (length)
|
|
222
|
+
* @param high - High price series (required when not using context API)
|
|
223
|
+
* @param low - Low price series (required when not using context API)
|
|
224
|
+
* @param close - Close price series (required when not using context API)
|
|
225
|
+
* @returns Average true range series
|
|
226
|
+
*
|
|
227
|
+
* @remarks
|
|
228
|
+
* - **PineScript v6 signature**: `ta.atr(length)` - uses implicit chart data
|
|
229
|
+
* - **JavaScript signature**: Requires explicit `high`, `low`, `close` OR use `createContext()`
|
|
230
|
+
* - Uses `ta.rma()` (Relative Moving Average) for smoothing, matching PineScript v6
|
|
231
|
+
* - True range is max(high - low, abs(high - close[1]), abs(low - close[1]))
|
|
232
|
+
* - ATR is a measure of volatility, higher values indicate greater volatility
|
|
233
|
+
* - `na` values in the source series are ignored
|
|
234
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* // Direct call with explicit data
|
|
239
|
+
* const atr14 = ta.atr(14, high, low, close);
|
|
240
|
+
*
|
|
241
|
+
* // Or use context API for cleaner syntax
|
|
242
|
+
* const { ta } = createContext({ chart: { high, low, close } });
|
|
243
|
+
* const atr14 = ta.atr(14); // Matches PineScript!
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function atr(length: simple_int, high?: Source, low?: Source, close?: Source): series_float;
|
|
247
|
+
/**
|
|
248
|
+
* SuperTrend Indicator - a trend-following indicator that helps identify trend direction.
|
|
249
|
+
*
|
|
250
|
+
* @param factor - The multiplier by which the ATR will get multiplied (series int/float)
|
|
251
|
+
* @param atrPeriod - Length of ATR (simple int)
|
|
252
|
+
* @param high - High price series (required when not using context API)
|
|
253
|
+
* @param low - Low price series (required when not using context API)
|
|
254
|
+
* @param close - Close price series (required when not using context API)
|
|
255
|
+
* @param wicks - Whether to use wicks for trend reversal (NOT in PineScript v6 API, default: false)
|
|
256
|
+
* @returns Tuple of [supertrend, direction] where direction is 1 (downtrend) or -1 (uptrend)
|
|
257
|
+
*
|
|
258
|
+
* @remarks
|
|
259
|
+
* - **PineScript v6 signature**: `ta.supertrend(factor, atrPeriod)` - uses implicit chart data
|
|
260
|
+
* - **JavaScript signature**: Requires explicit `high`, `low`, `close` OR use `createContext()`
|
|
261
|
+
* - The `wicks` parameter is NOT part of the official PineScript v6 API
|
|
262
|
+
* - Direction: 1 = downtrend (red), -1 = uptrend (green)
|
|
263
|
+
* - Uses hl2 (average of high and low) as the source
|
|
264
|
+
* - SuperTrend helps identify the current market trend and potential reversal points
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* // Direct call with explicit data
|
|
269
|
+
* const [supertrend, direction] = ta.supertrend(3, 10, high, low, close);
|
|
270
|
+
* // Plot uptrend when direction < 0
|
|
271
|
+
* // Plot downtrend when direction > 0
|
|
272
|
+
*
|
|
273
|
+
* // Or use context API for cleaner syntax
|
|
274
|
+
* const { ta } = createContext({ chart: { high, low, close } });
|
|
275
|
+
* const [supertrend, direction] = ta.supertrend(3, 10); // Matches PineScript!
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare function supertrend(factor: simple_float, atrPeriod: simple_int, high?: Source, low?: Source, close?: Source, wicks?: simple_bool): [series_float, series_int];
|
|
279
|
+
/**
|
|
280
|
+
* Relative Moving Average (RMA) - exponentially weighted moving average with alpha = 1 / length.
|
|
281
|
+
*
|
|
282
|
+
* @param source - Series of values to process
|
|
283
|
+
* @param length - Number of bars (length)
|
|
284
|
+
* @returns RMA of source for length bars back
|
|
285
|
+
*
|
|
286
|
+
* @remarks
|
|
287
|
+
* - Moving average used in RSI calculation
|
|
288
|
+
* - Alpha = 1 / length (different from EMA which uses alpha = 2 / (length + 1))
|
|
289
|
+
* - First value is initialized with SMA, then uses exponential smoothing
|
|
290
|
+
* - Formula: `RMA = (source + (length - 1) * RMA[1]) / length`, evaluated in this order as in PineScript
|
|
291
|
+
* (equal to `alpha * source + (1 - alpha) * RMA[1]`, but bit for bit)
|
|
292
|
+
* - `na` values (also +/-Infinity) in the source series are ignored
|
|
293
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const rma14 = ta.rma(closePrices, 14);
|
|
298
|
+
* // Used internally by RSI:
|
|
299
|
+
* // avgGain = ta.rma(gains, 14);
|
|
300
|
+
* // avgLoss = ta.rma(losses, 14);
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export declare function rma(source: Source, length: simple_int): series_float;
|
|
304
|
+
/**
|
|
305
|
+
* Weighted Moving Average (WMA) - moving average with linearly decreasing weights.
|
|
306
|
+
*
|
|
307
|
+
* @param source - Series of values to process
|
|
308
|
+
* @param length - Number of bars (length)
|
|
309
|
+
* @returns WMA of source for length bars back
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
* - Weighting factors decrease in arithmetical progression
|
|
313
|
+
* - Most recent value has weight `length`, previous has `length-1`, etc.
|
|
314
|
+
* - Formula: `sum(source[i]! * (length - i)) / sum(length - i)` for i = 0 to length-1
|
|
315
|
+
* - As in PineScript: na on a bar whose source is `na` (also +/-Infinity) and until `length` non-`na` values were
|
|
316
|
+
* received; an `na` value inside the window is replaced by the previous non-`na` value
|
|
317
|
+
* - More responsive to recent price changes than SMA
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const wma20 = ta.wma(closePrices, 20);
|
|
322
|
+
* // WMA gives more weight to recent prices
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
export declare function wma(source: Source, length: simple_int): series_float;
|
|
326
|
+
/**
|
|
327
|
+
* Highest value over the last `length` bars.
|
|
328
|
+
*
|
|
329
|
+
* @param source - Series of values to process
|
|
330
|
+
* @param length - Number of bars
|
|
331
|
+
* @returns Highest value series (na on the first `length - 1` bars)
|
|
332
|
+
*
|
|
333
|
+
* @remarks
|
|
334
|
+
* As in PineScript: an `na` value ends the window, so only the values after the last `na`
|
|
335
|
+
* count, and a bar whose own value is `na` gives `na`.
|
|
336
|
+
* PineScript `ta.highest(length)` (source = high) is `ta.highest(length)` in the script API.
|
|
337
|
+
*/
|
|
338
|
+
export declare function highest(source: Source, length: simple_int): series_float;
|
|
339
|
+
/**
|
|
340
|
+
* Lowest value over the last `length` bars.
|
|
341
|
+
*
|
|
342
|
+
* @param source - Series of values to process
|
|
343
|
+
* @param length - Number of bars
|
|
344
|
+
* @returns Lowest value series (na on the first `length - 1` bars)
|
|
345
|
+
*
|
|
346
|
+
* @remarks
|
|
347
|
+
* As in PineScript: an `na` value ends the window, so only the values after the last `na`
|
|
348
|
+
* count, and a bar whose own value is `na` gives `na`.
|
|
349
|
+
*/
|
|
350
|
+
export declare function lowest(source: Source, length: simple_int): series_float;
|
|
351
|
+
/**
|
|
352
|
+
* Cumulative Sum - returns the total sum of all elements from the beginning.
|
|
353
|
+
*
|
|
354
|
+
* @param source - Series of values to process
|
|
355
|
+
* @returns Series containing the cumulative sum at each bar
|
|
356
|
+
*
|
|
357
|
+
* @remarks
|
|
358
|
+
* - Returns the running total of all values from index 0 to current index
|
|
359
|
+
* - As in PineScript: an `na` value adds nothing to the sum,
|
|
360
|
+
* and the result is `na` on that bar only; the sum continues on the next bars
|
|
361
|
+
* - Useful for calculating total volume, total trades, etc.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* const cumulativeVolume = ta.cum(volume);
|
|
366
|
+
* const totalGains = ta.cum(gains);
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
export declare function cum(source: Source): series_float;
|
|
370
|
+
/**
|
|
371
|
+
* Cross - returns true when two series cross each other (either direction).
|
|
372
|
+
*
|
|
373
|
+
* @param source1 - First series
|
|
374
|
+
* @param source2 - Second series
|
|
375
|
+
* @returns Boolean series (true at cross points)
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
* - True when: (source1[i]! > source2[i]! AND source1[i-1] <= source2[i-1]) OR
|
|
379
|
+
* (source1[i]! < source2[i]! AND source1[i-1] >= source2[i-1])
|
|
380
|
+
* - First value is always false (no previous value to compare)
|
|
381
|
+
* - Detects any crossing (either over or under)
|
|
382
|
+
* - Use `ta.crossover()` or `ta.crossunder()` for directional crosses
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* const crossed = ta.cross(fastMA, slowMA);
|
|
387
|
+
* // Detect any MA crossover
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
export declare function cross(source1: Source, source2: Source): series_bool;
|
|
391
|
+
/**
|
|
392
|
+
* Rising - returns true if source is rising for length bars.
|
|
393
|
+
*
|
|
394
|
+
* @param source - Series of values to process
|
|
395
|
+
* @param length - Number of bars (length)
|
|
396
|
+
* @returns Boolean series (true when rising)
|
|
397
|
+
*
|
|
398
|
+
* @remarks
|
|
399
|
+
* PineScript rules:
|
|
400
|
+
* - each of the `length` steps is a rise larger than the 1e-10 tolerance
|
|
401
|
+
* - `na` values are skipped: the steps are between the last `length + 1` non-`na` values up to the current bar
|
|
402
|
+
* (on an `na` bar, the result of the last non-`na` bar)
|
|
403
|
+
* - false while there are fewer than `length + 1` non-`na` values
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* const isRising = ta.rising(close, 3);
|
|
408
|
+
* // Detect upward momentum
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
export declare function rising(source: Source, length: simple_int): series_bool;
|
|
412
|
+
/**
|
|
413
|
+
* Falling - returns true if source is falling for length bars.
|
|
414
|
+
*
|
|
415
|
+
* @param source - Series of values to process
|
|
416
|
+
* @param length - Number of bars (length)
|
|
417
|
+
* @returns Boolean series (true when falling)
|
|
418
|
+
*
|
|
419
|
+
* @remarks
|
|
420
|
+
* PineScript rules:
|
|
421
|
+
* - each of the `length` steps is a fall larger than the 1e-10 tolerance
|
|
422
|
+
* - `na` values are skipped: the steps are between the last `length + 1` non-`na` values up to the current bar
|
|
423
|
+
* (on an `na` bar, the result of the last non-`na` bar)
|
|
424
|
+
* - false while there are fewer than `length + 1` non-`na` values
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const isFalling = ta.falling(close, 3);
|
|
429
|
+
* // Detect downward momentum
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
export declare function falling(source: Source, length: simple_int): series_bool;
|
|
433
|
+
/**
|
|
434
|
+
* Rate of Change (ROC) - percentage change between current value and value length bars ago.
|
|
435
|
+
*
|
|
436
|
+
* @param source - Series of values to process
|
|
437
|
+
* @param length - Number of bars (length)
|
|
438
|
+
* @returns ROC series as percentage
|
|
439
|
+
*
|
|
440
|
+
* @remarks
|
|
441
|
+
* - Formula: `100 * change(source, length) / source[length]`
|
|
442
|
+
* - Equivalent to: `100 * (source - source[length]) / source[length]`
|
|
443
|
+
* - Returns percentage change, e.g., 5.0 means 5% increase
|
|
444
|
+
* - `na` values in the source series are included in calculations and will produce an `na` result
|
|
445
|
+
* - Useful for momentum analysis and trend strength measurement
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const roc10 = ta.roc(closePrices, 10);
|
|
450
|
+
* // Positive ROC indicates upward momentum
|
|
451
|
+
* // Negative ROC indicates downward momentum
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
export declare function roc(source: Source, length: simple_int): series_float;
|
|
455
|
+
/**
|
|
456
|
+
* Momentum (MOM) - difference between current value and value length bars ago.
|
|
457
|
+
*
|
|
458
|
+
* @param source - Series of values to process
|
|
459
|
+
* @param length - Offset from current bar to previous bar
|
|
460
|
+
* @returns Momentum series
|
|
461
|
+
*
|
|
462
|
+
* @remarks
|
|
463
|
+
* - Formula: `source - source[length]`
|
|
464
|
+
* - Equivalent to `ta.change(source, length)`
|
|
465
|
+
* - Positive momentum indicates upward movement
|
|
466
|
+
* - Negative momentum indicates downward movement
|
|
467
|
+
* - `na` values in the source series are included in calculations and will produce an `na` result
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* const mom10 = ta.mom(closePrices, 10);
|
|
472
|
+
* // Measures raw price momentum over 10 bars
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
export declare function mom(source: Source, length: simple_int): series_float;
|
|
476
|
+
/**
|
|
477
|
+
* Mean Absolute Deviation - measure of difference between series and its SMA.
|
|
478
|
+
*
|
|
479
|
+
* @param source - Series of values to process
|
|
480
|
+
* @param length - Number of bars (length)
|
|
481
|
+
* @returns Mean absolute deviation series
|
|
482
|
+
*
|
|
483
|
+
* @remarks
|
|
484
|
+
* - Measures average absolute distance from the mean
|
|
485
|
+
* - Formula: `sum(abs(source[i]! - sma)) / length` for i in 0 to length-1
|
|
486
|
+
* - Less sensitive to outliers than standard deviation
|
|
487
|
+
* - `na` values in the source series are ignored
|
|
488
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* const dev10 = ta.dev(closePrices, 10);
|
|
493
|
+
* // Measures volatility using mean absolute deviation
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
export declare function dev(source: Source, length: simple_int): series_float;
|
|
497
|
+
/**
|
|
498
|
+
* Variance - expectation of squared deviation from mean.
|
|
499
|
+
*
|
|
500
|
+
* @param source - Series of values to process
|
|
501
|
+
* @param length - Number of bars (length)
|
|
502
|
+
* @param biased - Use biased (true) or unbiased (false) estimate (default: true)
|
|
503
|
+
* @returns Variance series
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
* - Measures how far values are spread out from their mean
|
|
507
|
+
* - If `biased` is true: divides by `length` (population variance)
|
|
508
|
+
* - If `biased` is false: divides by `length - 1` (sample variance)
|
|
509
|
+
* - Formula (biased): `sum((source[i]! - mean)^2) / length`
|
|
510
|
+
* - Formula (unbiased): `sum((source[i]! - mean)^2) / (length - 1)`
|
|
511
|
+
* - `na` values in the source series are ignored
|
|
512
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
513
|
+
* - Relationship: `stdev = sqrt(variance)`
|
|
514
|
+
* - Computed as PineScript, bit for bit, from compensated running sums of the values and of their squares:
|
|
515
|
+
* biased `sumSq / length - mean * mean`, unbiased `sumSq / (length - 1) - mean * sum / (length - 1)`
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* const variance20 = ta.variance(closePrices, 20);
|
|
520
|
+
* const sampleVariance = ta.variance(closePrices, 20, false);
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
export declare function variance(source: Source, length: simple_int, biased?: simple_bool): series_float;
|
|
524
|
+
/**
|
|
525
|
+
* Median - returns the median (middle value) of the series.
|
|
526
|
+
*
|
|
527
|
+
* @param source - Series of values to process
|
|
528
|
+
* @param length - Number of bars (length)
|
|
529
|
+
* @returns Median series
|
|
530
|
+
*
|
|
531
|
+
* @remarks
|
|
532
|
+
* - Returns the middle value when values are sorted
|
|
533
|
+
* - For an even length, returns the average of the two middle values
|
|
534
|
+
* - As in PineScript: `na` values are skipped, the window holds the last `length` non-na values
|
|
535
|
+
* (going back as many bars as needed), and a bar whose own value is `na` still gets a result
|
|
536
|
+
* - Returns NaN until `length` non-na values exist
|
|
537
|
+
* - More robust to outliers than mean (SMA)
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* const median20 = ta.median(closePrices, 20);
|
|
542
|
+
* // Median is less affected by extreme values than SMA
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
export declare function median(source: Source, length: simple_int): series_float;
|
|
546
|
+
/**
|
|
547
|
+
* Symmetrically Weighted Moving Average (SWMA) - fixed length 4 with symmetric weights.
|
|
548
|
+
*
|
|
549
|
+
* @param source - Series of values to process
|
|
550
|
+
* @returns SWMA series
|
|
551
|
+
*
|
|
552
|
+
* @remarks
|
|
553
|
+
* - Fixed length of 4 bars
|
|
554
|
+
* - Weights: [1/6, 2/6, 2/6, 1/6] (symmetric)
|
|
555
|
+
* - Formula: `source[3] * 1/6 + source[2] * 2/6 + source[1] * 2/6 + source[0] * 1/6`
|
|
556
|
+
* - More weight given to middle values
|
|
557
|
+
* - `na` values in the source series are included in calculations and will produce an `na` result
|
|
558
|
+
* - Returns NaN for the first 3 bars
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```typescript
|
|
562
|
+
* const swma = ta.swma(closePrices);
|
|
563
|
+
* // Smoothed price with symmetric weighting
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
export declare function swma(source: Source): series_float;
|
|
567
|
+
/**
|
|
568
|
+
* Volume Weighted Moving Average (VWMA) - moving average weighted by volume.
|
|
569
|
+
*
|
|
570
|
+
* @param source - Series of values to process
|
|
571
|
+
* @param length - Number of bars (length)
|
|
572
|
+
* @param volume - Volume series (required when not using context API)
|
|
573
|
+
* @returns VWMA series
|
|
574
|
+
*
|
|
575
|
+
* @remarks
|
|
576
|
+
* - **PineScript v6 signature**: `ta.vwma(source, length)` - uses implicit volume data
|
|
577
|
+
* - **JavaScript signature**: Requires explicit `volume` OR use `createContext()`
|
|
578
|
+
* - Formula: `sma(source * volume, length) / sma(volume, length)`
|
|
579
|
+
* - Gives more weight to bars with higher volume
|
|
580
|
+
* - `na` values in the source series are ignored
|
|
581
|
+
* - Useful for price analysis considering volume significance
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* // Direct call with explicit volume
|
|
586
|
+
* const vwma20 = ta.vwma(closePrices, 20, volumeData);
|
|
587
|
+
*
|
|
588
|
+
* // Or use context API for cleaner syntax
|
|
589
|
+
* const { ta } = createContext({ chart: { high, low, close, volume } });
|
|
590
|
+
* const vwma20 = ta.vwma(close, 20); // Matches PineScript!
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
export declare function vwma(source: Source, length: simple_int, volume?: Source): series_float;
|
|
594
|
+
/**
|
|
595
|
+
* Linear Regression - line that best fits prices using least squares method.
|
|
596
|
+
*
|
|
597
|
+
* @param source - Series of values to process
|
|
598
|
+
* @param length - Number of bars (length)
|
|
599
|
+
* @param offset - Offset (default: 0)
|
|
600
|
+
* @returns Linear regression value
|
|
601
|
+
*
|
|
602
|
+
* @remarks
|
|
603
|
+
* - Calculates line of best fit using least squares method
|
|
604
|
+
* - Formula: `linreg = intercept + slope * (length - 1 - offset)`
|
|
605
|
+
* - offset=0 gives current fitted value, offset<0 gives future projection
|
|
606
|
+
* - `na` values in the source series are included in calculations and will produce an `na` result
|
|
607
|
+
* - Useful for trend detection and prediction
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* const linreg20 = ta.linreg(closePrices, 20, 0);
|
|
612
|
+
* const linregFuture = ta.linreg(closePrices, 20, -5); // Project 5 bars ahead
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
export declare function linreg(source: Source, length: simple_int, offset?: simple_int): series_float;
|
|
616
|
+
/**
|
|
617
|
+
* Correlation Coefficient - measures degree to which two series deviate from their means together.
|
|
618
|
+
*
|
|
619
|
+
* @param source1 - First series
|
|
620
|
+
* @param source2 - Second series
|
|
621
|
+
* @param length - Number of bars (length)
|
|
622
|
+
* @returns Correlation coefficient (-1 to +1)
|
|
623
|
+
*
|
|
624
|
+
* @remarks
|
|
625
|
+
* - Returns value between -1 and +1
|
|
626
|
+
* - +1 = perfect positive correlation
|
|
627
|
+
* - -1 = perfect negative correlation
|
|
628
|
+
* - 0 = no correlation
|
|
629
|
+
* - Measures linear relationship between two series
|
|
630
|
+
* - `na` values in the source series are ignored
|
|
631
|
+
* - The function calculates on the `length` quantity of non-`na` values
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const corr = ta.correlation(series1, series2, 20);
|
|
636
|
+
* // Values close to +1 or -1 indicate strong relationship
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
export declare function correlation(source1: Source, source2: Source, length: simple_int): series_float;
|
|
640
|
+
/**
|
|
641
|
+
* Percent Rank - percentage of how many previous values were less than or equal to current value.
|
|
642
|
+
*
|
|
643
|
+
* @param source - Series of values to process
|
|
644
|
+
* @param length - Number of bars (length)
|
|
645
|
+
* @returns Percent rank (0 to 100)
|
|
646
|
+
*
|
|
647
|
+
* @remarks
|
|
648
|
+
* - Returns value between 0 and 100
|
|
649
|
+
* - 0 = current value is lowest in the period
|
|
650
|
+
* - 100 = current value is highest in the period
|
|
651
|
+
* - 50 = current value is at median
|
|
652
|
+
* - Useful for identifying relative strength within a period
|
|
653
|
+
*
|
|
654
|
+
* PineScript rules:
|
|
655
|
+
* - percentrank = count(source[k] <= source, k = 1..length) / length * 100
|
|
656
|
+
* - a value from bar `length` on, when the current source is not `na`; an `na` value in the window counts as not
|
|
657
|
+
* `<=` the current value
|
|
658
|
+
* - the comparison uses the 1e-10 tolerance
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const pctrank = ta.percentrank(closePrices, 100);
|
|
663
|
+
* // Values near 100 indicate recent strength
|
|
664
|
+
* // Values near 0 indicate recent weakness
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
export declare function percentrank(source: Source, length: simple_int): series_float;
|
|
668
|
+
/**
|
|
669
|
+
* Commodity Channel Index (CCI) - measures deviation from average price.
|
|
670
|
+
*
|
|
671
|
+
* @param source - Series of values to process
|
|
672
|
+
* @param length - Number of bars (length)
|
|
673
|
+
* @returns CCI series
|
|
674
|
+
*
|
|
675
|
+
* @remarks
|
|
676
|
+
* - CCI = (Typical Price - SMA of TP) / (0.015 * Mean Deviation)
|
|
677
|
+
* - Typical Price = (High + Low + Close) / 3
|
|
678
|
+
* - Mean Deviation = Average of absolute differences from mean
|
|
679
|
+
* - Scaled by 0.015 to provide more readable numbers
|
|
680
|
+
* - Values above +100 indicate overbought conditions
|
|
681
|
+
* - Values below -100 indicate oversold conditions
|
|
682
|
+
* - \`na\` values in the source series are ignored
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* \`\`\`typescript
|
|
686
|
+
* const cci20 = ta.cci(typicalPrice, 20);
|
|
687
|
+
* // Overbought when cci > 100
|
|
688
|
+
* // Oversold when cci < -100
|
|
689
|
+
* \`\`\`
|
|
690
|
+
*/
|
|
691
|
+
export declare function cci(source: Source, length: simple_int): series_float;
|
|
692
|
+
/**
|
|
693
|
+
* Stochastic Oscillator - momentum indicator comparing closing price to price range.
|
|
694
|
+
*
|
|
695
|
+
* @param source - Source series (typically close)
|
|
696
|
+
* @param high - High price series
|
|
697
|
+
* @param low - Low price series
|
|
698
|
+
* @param length - Number of bars (length)
|
|
699
|
+
* @returns Stochastic %K series (values range from 0 to 100)
|
|
700
|
+
*
|
|
701
|
+
* @remarks
|
|
702
|
+
* - Formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
|
|
703
|
+
* - Measures where close is relative to the high-low range
|
|
704
|
+
* - Values above 80 typically indicate overbought
|
|
705
|
+
* - Values below 20 typically indicate oversold
|
|
706
|
+
* - Returns NaN when range is zero (high equals low)
|
|
707
|
+
* - \`na\` values in the source series are ignored
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* \`\`\`typescript
|
|
711
|
+
* const stochK = ta.stoch(close, high, low, 14);
|
|
712
|
+
* // Smooth with SMA for %D line:
|
|
713
|
+
* const stochD = ta.sma(stochK, 3);
|
|
714
|
+
* \`\`\`
|
|
715
|
+
*/
|
|
716
|
+
export declare function stoch(source: Source, high: Source, low: Source, length: simple_int): series_float;
|
|
717
|
+
/**
|
|
718
|
+
* Money Flow Index (MFI) - volume-weighted RSI measuring buying and selling pressure.
|
|
719
|
+
*
|
|
720
|
+
* @param source - Source series (typically hlc3 or close)
|
|
721
|
+
* @param length - Number of bars (length)
|
|
722
|
+
* @param volume - Volume series (required when not using context API)
|
|
723
|
+
* @returns MFI series (values range from 0 to 100)
|
|
724
|
+
*
|
|
725
|
+
* @remarks
|
|
726
|
+
* - **PineScript v6 signature**: `ta.mfi(source, length)` - uses implicit volume data
|
|
727
|
+
* - **JavaScript signature**: Requires explicit `volume` OR use `createContext()`
|
|
728
|
+
* - Combines price and volume to identify overbought/oversold conditions
|
|
729
|
+
* - Formula: 100 - (100 / (1 + Positive Money Flow / Negative Money Flow))
|
|
730
|
+
* - Values above 80 indicate overbought
|
|
731
|
+
* - Values below 20 indicate oversold
|
|
732
|
+
* - `na` values in the source series are ignored
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```typescript
|
|
736
|
+
* // Direct call with explicit volume
|
|
737
|
+
* const mfi14 = ta.mfi(hlc3, 14, volume);
|
|
738
|
+
*
|
|
739
|
+
* // Or use context API for cleaner syntax
|
|
740
|
+
* const { ta } = createContext({ chart: { high, low, close, volume } });
|
|
741
|
+
* const mfi14 = ta.mfi(hlc3, 14); // Matches PineScript!
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
export declare function mfi(source: Source, length: simple_int, volume?: Source): series_float;
|
|
745
|
+
/**
|
|
746
|
+
* Hull Moving Average (HMA) - improved moving average with reduced lag.
|
|
747
|
+
*
|
|
748
|
+
* @param source - Series of values to process
|
|
749
|
+
* @param length - Number of bars (length)
|
|
750
|
+
* @returns Hull moving average series
|
|
751
|
+
*
|
|
752
|
+
* @remarks
|
|
753
|
+
* - Formula: WMA(2 * WMA(src, len/2) - WMA(src, len), sqrt(len))
|
|
754
|
+
* - Significantly reduces lag compared to traditional moving averages
|
|
755
|
+
* - Smoother than WMA while being more responsive
|
|
756
|
+
* - Created by Alan Hull
|
|
757
|
+
* - `na` values in the source series are ignored
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const hma20 = ta.hma(closePrices, 20);
|
|
762
|
+
* // Faster response to price changes than SMA or EMA
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
export declare function hma(source: Source, length: simple_int): series_float;
|
|
766
|
+
/**
|
|
767
|
+
* Parabolic SAR (Stop and Reverse) - trend-following indicator.
|
|
768
|
+
*
|
|
769
|
+
* @param start - Acceleration factor start value (typically 0.02)
|
|
770
|
+
* @param inc - Acceleration factor increment (typically 0.02)
|
|
771
|
+
* @param max - Maximum acceleration factor (typically 0.2)
|
|
772
|
+
* @param high - High price series (required when not using context API)
|
|
773
|
+
* @param low - Low price series (required when not using context API)
|
|
774
|
+
* @param close - Close price series (required when not using context API)
|
|
775
|
+
* @returns SAR series
|
|
776
|
+
*
|
|
777
|
+
* @remarks
|
|
778
|
+
* - **PineScript v6 signature**: `ta.sar(start, inc, max)` - uses implicit chart data
|
|
779
|
+
* - **JavaScript signature**: Requires explicit `high`, `low`, `close` OR use `createContext()`
|
|
780
|
+
* - SAR below price indicates uptrend, above price indicates downtrend
|
|
781
|
+
* - Created by J. Welles Wilder Jr.
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```typescript
|
|
785
|
+
* const sar = ta.sar(0.02, 0.02, 0.2, high, low, close);
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
export declare function sar(start: simple_float, inc: simple_float, max: simple_float, high?: Source, low?: Source, close?: Source): series_float;
|
|
789
|
+
/**
|
|
790
|
+
* Pivot High - detects pivot high points in the price series.
|
|
791
|
+
*
|
|
792
|
+
* @param sourceOrLeftbars - Source series or leftbars (overloaded)
|
|
793
|
+
* @param leftbarsOrRightbars - Leftbars or rightbars (overloaded)
|
|
794
|
+
* @param rightbars - Number of bars to the right (optional)
|
|
795
|
+
* @param high - High price series (used in 2-param version)
|
|
796
|
+
* @returns Series with the pivot high value on the bar where the pivot is confirmed
|
|
797
|
+
* (`rightbars` bars after the pivot bar), NaN elsewhere
|
|
798
|
+
*
|
|
799
|
+
* @remarks
|
|
800
|
+
* - As in PineScript, the value appears `rightbars` bars after the pivot bar: the pivot bar
|
|
801
|
+
* index is `i - rightbars`
|
|
802
|
+
* - A pivot high may equal values on its left but must be higher than all values on its right
|
|
803
|
+
* - An `na` neighbour ends the check on its side
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```typescript
|
|
807
|
+
* const pivotHighs = ta.pivothigh(high, 2, 2);
|
|
808
|
+
* // pivotHighs[i] is high[i - 2] when bar i - 2 is a pivot high
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
export declare function pivothigh(sourceOrLeftbars: Source | simple_int, leftbarsOrRightbars: simple_int, rightbars?: simple_int, high?: Source): series_float;
|
|
812
|
+
/**
|
|
813
|
+
* Pivot Low - detects pivot low points in the price series.
|
|
814
|
+
*
|
|
815
|
+
* @param sourceOrLeftbars - Source series or leftbars (overloaded)
|
|
816
|
+
* @param leftbarsOrRightbars - Leftbars or rightbars (overloaded)
|
|
817
|
+
* @param rightbars - Number of bars to the right (optional)
|
|
818
|
+
* @param low - Low price series (used in 2-param version)
|
|
819
|
+
* @returns Series with the pivot low value on the bar where the pivot is confirmed
|
|
820
|
+
* (`rightbars` bars after the pivot bar), NaN elsewhere
|
|
821
|
+
*
|
|
822
|
+
* @remarks
|
|
823
|
+
* - As in PineScript, the value appears `rightbars` bars after the pivot bar: the pivot bar
|
|
824
|
+
* index is `i - rightbars`
|
|
825
|
+
* - A pivot low may equal values on its left but must be lower than all values on its right
|
|
826
|
+
* - An `na` neighbour ends the check on its side
|
|
827
|
+
*
|
|
828
|
+
* @example
|
|
829
|
+
* ```typescript
|
|
830
|
+
* const pivotLows = ta.pivotlow(low, 2, 2);
|
|
831
|
+
* // pivotLows[i] is low[i - 2] when bar i - 2 is a pivot low
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
export declare function pivotlow(sourceOrLeftbars: Source | simple_int, leftbarsOrRightbars: simple_int, rightbars?: simple_int, low?: Source): series_float;
|
|
835
|
+
/**
|
|
836
|
+
* Bars Since - returns number of bars since condition was true.
|
|
837
|
+
*
|
|
838
|
+
* @param condition - Boolean series condition
|
|
839
|
+
* @returns Series with number of bars since condition was last true
|
|
840
|
+
*
|
|
841
|
+
* @remarks
|
|
842
|
+
* - Returns 0 when condition is currently true
|
|
843
|
+
* - Increments by 1 for each bar condition remains false
|
|
844
|
+
* - Returns NaN if condition has never been true
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```typescript
|
|
848
|
+
* const crossovers = ta.crossover(fastMA, slowMA);
|
|
849
|
+
* const barsSinceCross = ta.barssince(crossovers);
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
export declare function barssince(condition: series_bool): series_float;
|
|
853
|
+
/**
|
|
854
|
+
* Value When - returns the value when condition was true.
|
|
855
|
+
*
|
|
856
|
+
* @param condition - Boolean series condition
|
|
857
|
+
* @param source - Source series to get value from
|
|
858
|
+
* @param occurrence - Which occurrence to get (0 = most recent)
|
|
859
|
+
* @returns Series with values from when condition was true
|
|
860
|
+
*
|
|
861
|
+
* @remarks
|
|
862
|
+
* - occurrence=0 returns value from most recent true condition
|
|
863
|
+
* - occurrence=1 returns value from second most recent, etc.
|
|
864
|
+
* - Returns NaN if condition hasn't been true occurrence+1 times yet
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```typescript
|
|
868
|
+
* const crossovers = ta.crossover(fastMA, slowMA);
|
|
869
|
+
* const lastCrossPrice = ta.valuewhen(crossovers, close, 0);
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
export declare function valuewhen(condition: series_bool, source: Source, occurrence: simple_int): series_float;
|
|
873
|
+
/**
|
|
874
|
+
* Directional Movement Index - returns Directional Movement indicators.
|
|
875
|
+
*
|
|
876
|
+
* @param diLength - DI averaging length
|
|
877
|
+
* @param adxSmoothing - ADX smoothing length
|
|
878
|
+
* @returns Tuple of [plusDI, minusDI, ADX]
|
|
879
|
+
*
|
|
880
|
+
* @remarks
|
|
881
|
+
* - +DI and -DI measure directional movement
|
|
882
|
+
* - ADX measures trend strength (0-100)
|
|
883
|
+
* - ADX above 25 typically indicates strong trend
|
|
884
|
+
* - Requires high, low, and close data from context
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```typescript
|
|
888
|
+
* const [plusDI, minusDI, adx] = ta.dmi(14, 14);
|
|
889
|
+
* // When +DI > -DI and ADX > 25, strong uptrend
|
|
890
|
+
* // When -DI > +DI and ADX > 25, strong downtrend
|
|
891
|
+
* ```
|
|
892
|
+
*/
|
|
893
|
+
export declare function dmi(diLength: simple_int, adxSmoothing: simple_int, high: Source, low: Source, close: Source): [series_float, series_float, series_float];
|
|
894
|
+
/**
|
|
895
|
+
* True Strength Index - momentum oscillator based on double smoothed momentum.
|
|
896
|
+
*
|
|
897
|
+
* @param source - Series of values to process
|
|
898
|
+
* @param shortLength - Short smoothing length
|
|
899
|
+
* @param longLength - Long smoothing length
|
|
900
|
+
* @returns TSI series
|
|
901
|
+
*
|
|
902
|
+
* @remarks
|
|
903
|
+
* - TSI oscillates between +100 and -100
|
|
904
|
+
* - Positive values indicate bullish momentum
|
|
905
|
+
* - Negative values indicate bearish momentum
|
|
906
|
+
* - Crossovers of zero line can signal trend changes
|
|
907
|
+
* - Less sensitive to short-term price fluctuations than RSI
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```typescript
|
|
911
|
+
* const tsi = ta.tsi(close, 13, 25);
|
|
912
|
+
* // TSI > 0: bullish momentum
|
|
913
|
+
* // TSI < 0: bearish momentum
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
export declare function tsi(source: Source, shortLength: simple_int, longLength: simple_int): series_float;
|
|
917
|
+
/**
|
|
918
|
+
* Chande Momentum Oscillator - momentum indicator similar to RSI.
|
|
919
|
+
*
|
|
920
|
+
* @param source - Series of values to process
|
|
921
|
+
* @param length - Number of bars
|
|
922
|
+
* @returns CMO series
|
|
923
|
+
*
|
|
924
|
+
* @remarks
|
|
925
|
+
* - CMO oscillates between +100 and -100
|
|
926
|
+
* - CMO > +50: overbought conditions
|
|
927
|
+
* - CMO < -50: oversold conditions
|
|
928
|
+
* - Unlike RSI, CMO uses sum of gains/losses instead of averages
|
|
929
|
+
* - More volatile than RSI
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```typescript
|
|
933
|
+
* const cmo = ta.cmo(close, 14);
|
|
934
|
+
* // CMO > 50: overbought
|
|
935
|
+
* // CMO < -50: oversold
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
export declare function cmo(source: Source, length: simple_int): series_float;
|
|
939
|
+
/**
|
|
940
|
+
* Keltner Channels - volatility-based envelope indicator.
|
|
941
|
+
*
|
|
942
|
+
* @param source - Series of values to process
|
|
943
|
+
* @param length - Number of bars for EMA
|
|
944
|
+
* @param mult - Multiplier for the range
|
|
945
|
+
* @param useTrueRange - Use True Range (default: true) or high-low
|
|
946
|
+
* @returns Tuple of [middle, upper, lower]
|
|
947
|
+
*
|
|
948
|
+
* @remarks
|
|
949
|
+
* - Middle band is EMA of source
|
|
950
|
+
* - Upper/lower bands are middle ± (range EMA × multiplier)
|
|
951
|
+
* - When useTrueRange=true, uses ATR for volatility
|
|
952
|
+
* - When useTrueRange=false, uses high-low range
|
|
953
|
+
* - Price breaking out of bands may signal trend continuation
|
|
954
|
+
* - Requires high, low, close data from context when useTrueRange=true
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* const [middle, upper, lower] = ta.kc(close, 20, 2, true);
|
|
959
|
+
* // Price above upper: potential uptrend
|
|
960
|
+
* // Price below lower: potential downtrend
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
export declare function kc(source: Source, length: simple_int, mult: simple_float, useTrueRange?: simple_bool, high?: Source, low?: Source, close?: Source): [series_float, series_float, series_float];
|
|
964
|
+
/**
|
|
965
|
+
* Bollinger Bands Width - measures the width of Bollinger Bands.
|
|
966
|
+
*
|
|
967
|
+
* @param source - Series of values to process
|
|
968
|
+
* @param length - Number of bars
|
|
969
|
+
* @param mult - Standard deviation multiplier
|
|
970
|
+
* @returns BBW series (percentage)
|
|
971
|
+
*
|
|
972
|
+
* @remarks
|
|
973
|
+
* - BBW = ((upper band - lower band) / middle band) × 100
|
|
974
|
+
* - Low BBW values indicate low volatility (potential breakout setup)
|
|
975
|
+
* - High BBW values indicate high volatility
|
|
976
|
+
* - BBW squeeze (narrowing bands) often precedes strong moves
|
|
977
|
+
* - Works with existing bb() function
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```typescript
|
|
981
|
+
* const bbw = ta.bbw(close, 20, 2);
|
|
982
|
+
* // Low BBW: potential breakout coming
|
|
983
|
+
* // High BBW: high volatility period
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
export declare function bbw(source: Source, length: simple_int, mult: simple_float): series_float;
|
|
987
|
+
/**
|
|
988
|
+
* Williams %R (Williams Percent Range)
|
|
989
|
+
*
|
|
990
|
+
* Williams %R is a momentum indicator that measures overbought/oversold levels.
|
|
991
|
+
* It compares the closing price to the high-low range over a specified period.
|
|
992
|
+
*
|
|
993
|
+
* Values range from -100 (oversold) to 0 (overbought):
|
|
994
|
+
* - Above -20: Overbought
|
|
995
|
+
* - Below -80: Oversold
|
|
996
|
+
*
|
|
997
|
+
* @param high - High price series
|
|
998
|
+
* @param low - Low price series
|
|
999
|
+
* @param close - Close price series
|
|
1000
|
+
* @param length - Lookback period (default: 14)
|
|
1001
|
+
* @returns Williams %R series
|
|
1002
|
+
*
|
|
1003
|
+
* @example
|
|
1004
|
+
* ```typescript
|
|
1005
|
+
* const wpr = ta.wpr(high, low, close, 14);
|
|
1006
|
+
* // wpr < -80: oversold
|
|
1007
|
+
* // wpr > -20: overbought
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
export declare function wpr(high: Source, low: Source, close: Source, length?: simple_int): series_float;
|
|
1011
|
+
/**
|
|
1012
|
+
* Volume Weighted Average Price, restarted on each bar where `anchor` is true.
|
|
1013
|
+
*
|
|
1014
|
+
* @param source - Source series (PineScript default `hlc3`)
|
|
1015
|
+
* @param volume - Volume series
|
|
1016
|
+
* @param anchor - Reset condition per bar (PineScript `anchor`). Without it the sums never restart;
|
|
1017
|
+
* PineScript's default anchor is a new day (`timeframe.change("1D")`), which needs the exchange session
|
|
1018
|
+
* @param stdev_mult - When given, also returns the bands `vwap ± stdev_mult × stdev`
|
|
1019
|
+
* @returns The VWAP series, or `[vwap, upper, lower]` when `stdev_mult` is given
|
|
1020
|
+
*
|
|
1021
|
+
* @remarks
|
|
1022
|
+
* As in PineScript: the sums restart on anchor bars; the standard deviation is
|
|
1023
|
+
* `sqrt(Σ(volume × source²) / Σvolume − vwap²)`.
|
|
1024
|
+
*/
|
|
1025
|
+
export declare function vwap(source: Source, volume: Source, anchor?: ArrayLike<boolean | number>): series_float;
|
|
1026
|
+
export declare function vwap(source: Source, volume: Source, anchor: ArrayLike<boolean | number> | undefined, stdev_mult: simple_float): [series_float, series_float, series_float];
|
|
1027
|
+
/**
|
|
1028
|
+
* Arnaud Legoux Moving Average (ALMA)
|
|
1029
|
+
*
|
|
1030
|
+
* ALMA uses a Gaussian distribution for weighting, reducing lag while maintaining smoothness.
|
|
1031
|
+
* It's particularly good at tracking price action with minimal lag.
|
|
1032
|
+
*
|
|
1033
|
+
* @param source - Source series
|
|
1034
|
+
* @param length - Window size (default: 9)
|
|
1035
|
+
* @param offset - Controls the center of the Gaussian curve. 0.85 = focus on recent prices (default: 0.85)
|
|
1036
|
+
* @param sigma - Standard deviation of the Gaussian. Controls smoothness (default: 6)
|
|
1037
|
+
* @returns ALMA series
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* ```typescript
|
|
1041
|
+
* const alma = ta.alma(close, 9, 0.85, 6);
|
|
1042
|
+
* // offset closer to 1: more responsive
|
|
1043
|
+
* // offset closer to 0: smoother
|
|
1044
|
+
* ```
|
|
1045
|
+
*/
|
|
1046
|
+
export declare function alma(source: Source, length?: simple_int, offset?: simple_float, sigma?: simple_float, floor?: boolean): series_float;
|
|
1047
|
+
/**
|
|
1048
|
+
* Keltner Channels Width (KCW)
|
|
1049
|
+
*
|
|
1050
|
+
* Measures the width of Keltner Channels as a percentage of the middle line.
|
|
1051
|
+
* Similar to BBW but uses ATR instead of standard deviation.
|
|
1052
|
+
*
|
|
1053
|
+
* Low KCW suggests consolidation/low volatility.
|
|
1054
|
+
* High KCW suggests expansion/high volatility.
|
|
1055
|
+
*
|
|
1056
|
+
* @param source - Source series
|
|
1057
|
+
* @param length - Number of bars for EMA and ATR (default: 20)
|
|
1058
|
+
* @param mult - ATR multiplier (default: 2)
|
|
1059
|
+
* @param useTrueRange - Use True Range instead of high-low (default: true)
|
|
1060
|
+
* @param high - High price series
|
|
1061
|
+
* @param low - Low price series
|
|
1062
|
+
* @param close - Close price series
|
|
1063
|
+
* @returns KCW series
|
|
1064
|
+
*
|
|
1065
|
+
* @example
|
|
1066
|
+
* ```typescript
|
|
1067
|
+
* const kcw = ta.kcw(close, 20, 2, true, high, low, close);
|
|
1068
|
+
* // Low KCW: potential breakout coming
|
|
1069
|
+
* // High KCW: high volatility period
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
1072
|
+
export declare function kcw(source: Source, length?: simple_int, mult?: simple_float, useTrueRange?: simple_bool, high?: Source, low?: Source, close?: Source): series_float;
|
|
1073
|
+
/**
|
|
1074
|
+
* Difference between the highest and the lowest value over the last `length` non-na values
|
|
1075
|
+
* (PineScript `ta.range(source, length)`).
|
|
1076
|
+
*
|
|
1077
|
+
* @remarks
|
|
1078
|
+
* As in PineScript: `na` values are skipped (the window holds the last `length` non-na
|
|
1079
|
+
* values), and a bar whose own value is `na` still gets a result.
|
|
1080
|
+
*/
|
|
1081
|
+
export declare function range(source: Source, length: simple_int): series_float;
|
|
1082
|
+
/**
|
|
1083
|
+
* Offset to the bar with the highest value over the last `length` bars: 0 for the current bar,
|
|
1084
|
+
* -1 for the previous bar, and so on (as in PineScript, the offset is negative).
|
|
1085
|
+
*
|
|
1086
|
+
* @remarks
|
|
1087
|
+
* As in PineScript: on equal values the oldest bar wins; an `na` value ends the window;
|
|
1088
|
+
* 0 when the window has no value.
|
|
1089
|
+
*/
|
|
1090
|
+
export declare function highestbars(source: Source, length: simple_int): series_int;
|
|
1091
|
+
/**
|
|
1092
|
+
* Offset to the bar with the lowest value over the last `length` bars: 0 for the current bar,
|
|
1093
|
+
* -1 for the previous bar, and so on (as in PineScript, the offset is negative).
|
|
1094
|
+
*
|
|
1095
|
+
* @remarks
|
|
1096
|
+
* As in PineScript: on equal values the oldest bar wins; an `na` value ends the window;
|
|
1097
|
+
* 0 when the window has no value.
|
|
1098
|
+
*/
|
|
1099
|
+
export declare function lowestbars(source: Source, length: simple_int): series_int;
|
|
1100
|
+
/**
|
|
1101
|
+
* All-time highest value of `source` up to each bar (PineScript `ta.max(source)`).
|
|
1102
|
+
*
|
|
1103
|
+
* @remarks
|
|
1104
|
+
* As in PineScript: `na` values are skipped, the value carries over `na` bars, and the
|
|
1105
|
+
* result is `na` until the first non-na value.
|
|
1106
|
+
*/
|
|
1107
|
+
export declare function max(source: Source): series_float;
|
|
1108
|
+
/**
|
|
1109
|
+
* All-time lowest value of `source` up to each bar (PineScript `ta.min(source)`).
|
|
1110
|
+
*
|
|
1111
|
+
* @remarks
|
|
1112
|
+
* As in PineScript: `na` values are skipped, the value carries over `na` bars, and the
|
|
1113
|
+
* result is `na` until the first non-na value.
|
|
1114
|
+
*/
|
|
1115
|
+
export declare function min(source: Source): series_float;
|
|
1116
|
+
/**
|
|
1117
|
+
* Center of Gravity (COG)
|
|
1118
|
+
*
|
|
1119
|
+
* The Center of Gravity indicator is an oscillator developed by John Ehlers.
|
|
1120
|
+
* It identifies turning points with minimal lag and provides clear signals.
|
|
1121
|
+
*
|
|
1122
|
+
* The COG calculates a weighted average where more recent prices have higher weights,
|
|
1123
|
+
* similar to a moving average but with a focus on momentum shifts.
|
|
1124
|
+
*
|
|
1125
|
+
* @param source - Source series (typically close)
|
|
1126
|
+
* @param length - Lookback period (default: 10)
|
|
1127
|
+
* @returns COG series
|
|
1128
|
+
*
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```typescript
|
|
1131
|
+
* const cogValue = ta.cog(close, 10);
|
|
1132
|
+
* // Use COG crossovers as signals:
|
|
1133
|
+
* // - COG crossing above 0: potential buy signal
|
|
1134
|
+
* // - COG crossing below 0: potential sell signal
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
export declare function cog(source: Source, length?: simple_int): series_float;
|
|
1138
|
+
/**
|
|
1139
|
+
* Mode (Most Frequent Value)
|
|
1140
|
+
*
|
|
1141
|
+
* Returns the mode of the series - the most frequently occurring value.
|
|
1142
|
+
* If there are several values with the same frequency, it returns the smallest value.
|
|
1143
|
+
*
|
|
1144
|
+
* @param source - Series of values to process
|
|
1145
|
+
* @param length - Number of bars to look back
|
|
1146
|
+
* @returns The most frequently occurring value
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```typescript
|
|
1150
|
+
* const values = [1, 2, 2, 3, 3, 3, 4, 4];
|
|
1151
|
+
* const modeValue = ta.mode(values, 8); // Returns 3 (most frequent)
|
|
1152
|
+
* ```
|
|
1153
|
+
*
|
|
1154
|
+
* @remarks
|
|
1155
|
+
* - `na` values in the source series are ignored
|
|
1156
|
+
* - If no mode exists, returns the smallest value
|
|
1157
|
+
* - Returns NaN for the first (length - 1) values where there's insufficient data
|
|
1158
|
+
*/
|
|
1159
|
+
export declare function mode(source: Source, length: simple_int): series_float;
|
|
1160
|
+
/**
|
|
1161
|
+
* Percentile (Linear Interpolation Method)
|
|
1162
|
+
*
|
|
1163
|
+
* Calculates the percentile using the method of linear interpolation between
|
|
1164
|
+
* the two nearest ranks. This method may return values that are not members
|
|
1165
|
+
* of the input data set.
|
|
1166
|
+
*
|
|
1167
|
+
* @param source - Series of values to process
|
|
1168
|
+
* @param length - Number of bars to look back
|
|
1169
|
+
* @param percentage - Percentile to calculate (0-100)
|
|
1170
|
+
* @returns The calculated percentile value
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* const p50 = ta.percentile_linear_interpolation(close, 20, 50); // Median
|
|
1175
|
+
* const p75 = ta.percentile_linear_interpolation(close, 20, 75); // 75th percentile
|
|
1176
|
+
* ```
|
|
1177
|
+
*
|
|
1178
|
+
* @remarks
|
|
1179
|
+
* - The result will NOT always be a member of the input data set
|
|
1180
|
+
* - Uses linear interpolation between adjacent values when needed
|
|
1181
|
+
* - Returns NaN for the first (length - 1) values where there's insufficient data
|
|
1182
|
+
*
|
|
1183
|
+
* PineScript rules:
|
|
1184
|
+
* - position in the sorted window: `percentage / 100 * length - 0.5`, clamped to the first / last value, linear
|
|
1185
|
+
* interpolation between the two neighbours (na when a neighbour is na, also at an exact position)
|
|
1186
|
+
* - `na` values stay in the window (window size = `length`). The window is kept sorted from bar to bar: the new
|
|
1187
|
+
* value is inserted before the first value `>=` it, passing the `na` values (an `na` goes last), then the value
|
|
1188
|
+
* leaving the window is removed. So the place of an `na` depends on the history: at the start of a series the
|
|
1189
|
+
* `na` values are before all numbers
|
|
1190
|
+
*/
|
|
1191
|
+
export declare function percentile_linear_interpolation(source: Source, length: simple_int, percentage: number): series_float;
|
|
1192
|
+
/**
|
|
1193
|
+
* Percentile (Nearest Rank Method)
|
|
1194
|
+
*
|
|
1195
|
+
* Calculates the percentile using the Nearest Rank method. This method
|
|
1196
|
+
* always returns a value that is a member of the input data set.
|
|
1197
|
+
*
|
|
1198
|
+
* @param source - Series of values to process
|
|
1199
|
+
* @param length - Number of bars to look back
|
|
1200
|
+
* @param percentage - Percentile to calculate (0-100)
|
|
1201
|
+
* @returns The calculated percentile value
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```typescript
|
|
1205
|
+
* const p50 = ta.percentile_nearest_rank(close, 20, 50); // Median
|
|
1206
|
+
* const p90 = ta.percentile_nearest_rank(close, 20, 90); // 90th percentile
|
|
1207
|
+
* ```
|
|
1208
|
+
*
|
|
1209
|
+
* @remarks
|
|
1210
|
+
* - The result will ALWAYS be a member of the input data set
|
|
1211
|
+
* - The 100th percentile is defined as the largest value
|
|
1212
|
+
* - Using this method on lengths < 100 may result in the same value for multiple percentiles
|
|
1213
|
+
* - Returns NaN for the first (length - 1) values where there's insufficient data
|
|
1214
|
+
*
|
|
1215
|
+
* PineScript rules:
|
|
1216
|
+
* - the value at rank `ceil(percentage / 100 * length)` of the sorted window (na when that rank holds an `na`)
|
|
1217
|
+
* - `na` values stay in the window, sorted from bar to bar as in `ta.percentile_linear_interpolation`
|
|
1218
|
+
*/
|
|
1219
|
+
export declare function percentile_nearest_rank(source: Source, length: simple_int, percentage: number): series_float;
|
|
1220
|
+
/**
|
|
1221
|
+
* Rank Correlation Index (RCI)
|
|
1222
|
+
*
|
|
1223
|
+
* Calculates the Rank Correlation Index using Spearman's rank correlation coefficient.
|
|
1224
|
+
* RCI measures the directional consistency of price movements, indicating whether
|
|
1225
|
+
* the source consistently increased (positive values) or decreased (negative values).
|
|
1226
|
+
*
|
|
1227
|
+
* @param source - Series of values to process
|
|
1228
|
+
* @param length - Number of bars to look back
|
|
1229
|
+
* @returns RCI value scaled to range -100 to 100
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```typescript
|
|
1233
|
+
* const rci9 = ta.rci(close, 9);
|
|
1234
|
+
* // RCI near +100: strong upward consistency
|
|
1235
|
+
* // RCI near -100: strong downward consistency
|
|
1236
|
+
* // RCI near 0: no clear trend
|
|
1237
|
+
* ```
|
|
1238
|
+
*
|
|
1239
|
+
* @remarks
|
|
1240
|
+
* - Result is scaled to -100 to 100 range
|
|
1241
|
+
* - +100 indicates source consistently increased over the period
|
|
1242
|
+
* - -100 indicates source consistently decreased over the period
|
|
1243
|
+
* - 0 indicates no directional consistency
|
|
1244
|
+
* - Returns NaN for the first (length - 1) values where there's insufficient data
|
|
1245
|
+
*/
|
|
1246
|
+
export declare function rci(source: Source, length: simple_int): series_float;
|
|
1247
|
+
/**
|
|
1248
|
+
* Pivot Point Levels
|
|
1249
|
+
*
|
|
1250
|
+
* Calculates pivot point levels using various calculation methods.
|
|
1251
|
+
* Returns an array containing: [P, R1, S1, R2, S2, R3, S3, R4, S4, R5, S5]
|
|
1252
|
+
*
|
|
1253
|
+
* @param type - Calculation type: "Traditional", "Fibonacci", "Woodie", "Classic", "DM", "Camarilla"
|
|
1254
|
+
* @param anchor - Condition that triggers reset of calculations
|
|
1255
|
+
* @param developing - If true, pivots recalculate continuously; if false, use last anchor values
|
|
1256
|
+
* @param high - High price series (optional, uses context if not provided)
|
|
1257
|
+
* @param low - Low price series (optional, uses context if not provided)
|
|
1258
|
+
* @param close - Close price series (optional, uses context if not provided)
|
|
1259
|
+
* @param open - Open price series (optional, uses context if not provided)
|
|
1260
|
+
* @returns Array of 11 pivot levels
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* ```typescript
|
|
1264
|
+
* const weekChange = [false, false, false, false, true, false, ...]; // Weekly anchor
|
|
1265
|
+
* const pivots = ta.pivot_point_levels("Traditional", weekChange, false, high, low, close);
|
|
1266
|
+
* // pivots[i]! = [P, R1, S1, R2, S2, R3, S3, R4, S4, R5, S5]
|
|
1267
|
+
* ```
|
|
1268
|
+
*
|
|
1269
|
+
* @remarks
|
|
1270
|
+
* - Woodie type cannot use developing=true (will error in PineScript)
|
|
1271
|
+
* - DM type only calculates P, R1, S1 (other levels are NaN)
|
|
1272
|
+
* - All calculations follow PineScript v6 specifications
|
|
1273
|
+
*/
|
|
1274
|
+
export declare function pivot_point_levels(type: series_float | string, anchor: series_bool, developing?: series_bool | boolean, high?: Source, low?: Source, close?: Source, open?: Source): series_float[];
|
|
1275
|
+
/**
|
|
1276
|
+
* Ichimoku Kinko Hyo (Ichimoku Cloud) - Japanese charting technique for trend identification.
|
|
1277
|
+
*
|
|
1278
|
+
* @param conversionPeriods - Period for Tenkan-sen (Conversion Line), default: 9
|
|
1279
|
+
* @param basePeriods - Period for Kijun-sen (Base Line), default: 26
|
|
1280
|
+
* @param laggingSpan2Periods - Period for Senkou Span B (Leading Span B), default: 52
|
|
1281
|
+
* @param displacement - Displacement for Senkou Spans and Chikou Span, default: 26
|
|
1282
|
+
* @param high - High price series
|
|
1283
|
+
* @param low - Low price series
|
|
1284
|
+
* @param close - Close price series
|
|
1285
|
+
* @returns Tuple of [tenkanSen, kijunSen, senkouSpanA, senkouSpanB, chikouSpan]
|
|
1286
|
+
*
|
|
1287
|
+
* @remarks
|
|
1288
|
+
* - **Tenkan-sen (Conversion Line)**: `(highest(high, conversionPeriods) + lowest(low, conversionPeriods)) / 2`
|
|
1289
|
+
* - **Kijun-sen (Base Line)**: `(highest(high, basePeriods) + lowest(low, basePeriods)) / 2`
|
|
1290
|
+
* - **Senkou Span A (Leading Span A)**: `(tenkan + kijun) / 2` offset forward by `displacement` periods
|
|
1291
|
+
* - **Senkou Span B (Leading Span B)**: `(highest(high, laggingSpan2Periods) + lowest(low, laggingSpan2Periods)) / 2` offset forward by `displacement` periods
|
|
1292
|
+
* - **Chikou Span (Lagging Span)**: `close` offset backward by `displacement` periods
|
|
1293
|
+
*
|
|
1294
|
+
* The forward offset for Senkou Spans means they are projected into the future (NaN values at the end).
|
|
1295
|
+
* The backward offset for Chikou Span means it shows past prices (NaN values at the beginning).
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* const [tenkan, kijun, senkouA, senkouB, chikou] = ta.ichimoku(9, 26, 52, 26, high, low, close);
|
|
1300
|
+
*
|
|
1301
|
+
* // Tenkan-sen crosses above Kijun-sen = bullish signal
|
|
1302
|
+
* const bullishSignal = ta.crossover(tenkan, kijun);
|
|
1303
|
+
*
|
|
1304
|
+
* // Price above cloud = bullish trend
|
|
1305
|
+
* // Cloud = area between senkouSpanA and senkouSpanB
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
export declare function ichimoku(conversionPeriods: simple_int, basePeriods: simple_int, laggingSpan2Periods: simple_int, displacement: simple_int, high: Source, low: Source, close: Source): [series_float, series_float, series_float, series_float, series_float];
|
|
1309
|
+
/**
|
|
1310
|
+
* ZigZag indicator - identifies significant trend reversals by filtering out minor price movements.
|
|
1311
|
+
*
|
|
1312
|
+
* @param deviation - Minimum percentage price change to form a new pivot (default: 5.0)
|
|
1313
|
+
* @param depth - Minimum bars between pivots for pivot detection (default: 10)
|
|
1314
|
+
* @param backstep - Bars to look back for confirmation (default: 3)
|
|
1315
|
+
* @param source - Price source (optional, typically close)
|
|
1316
|
+
* @param high - High price series (optional, for high/low mode)
|
|
1317
|
+
* @param low - Low price series (optional, for high/low mode)
|
|
1318
|
+
* @returns Tuple of [zigzag values, direction, pivot flags (boolean)]
|
|
1319
|
+
*
|
|
1320
|
+
* @remarks
|
|
1321
|
+
* - **Parameter order differs from PineScript**: JavaScript signature puts deviation first,
|
|
1322
|
+
* while PineScript uses `ta.zigzag(source, deviation, depth, backstep)`. This allows
|
|
1323
|
+
* deviation to have a default value and makes the API more ergonomic for JS users.
|
|
1324
|
+
* - **JavaScript signature**: Requires explicit `source`, `high`, `low` OR use `createContext()`
|
|
1325
|
+
* - Returns the pivot price at pivot points, NaN for non-pivot bars
|
|
1326
|
+
* - Direction: 1 = uptrend (from low to high), -1 = downtrend (from high to low)
|
|
1327
|
+
* - The ZigZag indicator **repaints** by design - the last segment can change as new data arrives
|
|
1328
|
+
* - Supports two modes:
|
|
1329
|
+
* - Single source mode: uses same series for highs and lows
|
|
1330
|
+
* - High/Low mode: uses high for pivot highs, low for pivot lows
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```typescript
|
|
1334
|
+
* // Using high/low for more accurate pivots
|
|
1335
|
+
* const [zigzag, direction, isPivot] = ta.zigzag(5, 10, 3, undefined, high, low);
|
|
1336
|
+
*
|
|
1337
|
+
* // Find pivot prices
|
|
1338
|
+
* for (let i = 0; i < zigzag.length; i++) {
|
|
1339
|
+
* if (!isNaN(zigzag[i]!)) {
|
|
1340
|
+
* console.log(`Pivot at bar ${i}: ${zigzag[i]!}, direction: ${direction[i]! === 1 ? 'UP' : 'DOWN'}`);
|
|
1341
|
+
* }
|
|
1342
|
+
* }
|
|
1343
|
+
* ```
|
|
1344
|
+
*/
|
|
1345
|
+
export declare function zigzag(deviation?: simple_float, depth?: simple_int, backstep?: simple_int, source?: Source, high?: Source, low?: Source): [series_float, series_int, series_bool];
|
|
1346
|
+
/**
|
|
1347
|
+
* On Balance Volume: `ta.cum(math.sign(ta.change(close)) * volume)`.
|
|
1348
|
+
*
|
|
1349
|
+
* @param close - Close price series
|
|
1350
|
+
* @param volume - Volume series
|
|
1351
|
+
* @returns OBV series (`na` on the first bar, and on bars without volume)
|
|
1352
|
+
*/
|
|
1353
|
+
export declare function obv(close: Source, volume: Source): series_float;
|
|
1354
|
+
/**
|
|
1355
|
+
* Price-Volume Trend: `ta.cum((ta.change(close) / close[1]) * volume)`.
|
|
1356
|
+
*
|
|
1357
|
+
* @param close - Close price series
|
|
1358
|
+
* @param volume - Volume series
|
|
1359
|
+
* @returns PVT series (`na` on the first bar, and on bars without volume)
|
|
1360
|
+
*/
|
|
1361
|
+
export declare function pvt(close: Source, volume: Source): series_float;
|
|
1362
|
+
/**
|
|
1363
|
+
* Accumulation/Distribution index: the running sum of
|
|
1364
|
+
* `(2 * close - low - high) / (high - low) * volume`, with 0 on bars where `high == low`.
|
|
1365
|
+
*/
|
|
1366
|
+
export declare function accdist(high: Source, low: Source, close: Source, volume: Source): series_float;
|
|
1367
|
+
/**
|
|
1368
|
+
* Intraday Intensity Index: `(2 * close - high - low) / (high - low) * volume`.
|
|
1369
|
+
*
|
|
1370
|
+
* The PineScript built-in value is this formula. The formula shown in the PineScript reference,
|
|
1371
|
+
* `(2 * close - high - low) / ((high - low) * volume)`, gives other values.
|
|
1372
|
+
*
|
|
1373
|
+
* @returns III series (`na` where `high == low`)
|
|
1374
|
+
*/
|
|
1375
|
+
export declare function iii(high: Source, low: Source, close: Source, volume: Source): series_float;
|
|
1376
|
+
/**
|
|
1377
|
+
* Williams Variable Accumulation/Distribution: `(close - open) / (high - low) * volume`.
|
|
1378
|
+
*
|
|
1379
|
+
* @returns WVAD series (`na` where `high == low`)
|
|
1380
|
+
*/
|
|
1381
|
+
export declare function wvad(open: Source, high: Source, low: Source, close: Source, volume: Source): series_float;
|
|
1382
|
+
/**
|
|
1383
|
+
* Williams Accumulation/Distribution: the running sum of `close - min(low, close[1])` on up
|
|
1384
|
+
* closes, `close - max(high, close[1])` on down closes, and 0 otherwise (first bar included).
|
|
1385
|
+
*/
|
|
1386
|
+
export declare function wad(high: Source, low: Source, close: Source): series_float;
|
|
1387
|
+
/**
|
|
1388
|
+
* Negative Volume Index: moves with the close change only on bars where volume falls.
|
|
1389
|
+
* Starts at 1.
|
|
1390
|
+
*/
|
|
1391
|
+
export declare function nvi(close: Source, volume: Source): series_float;
|
|
1392
|
+
/**
|
|
1393
|
+
* Positive Volume Index: moves with the close change only on bars where volume rises.
|
|
1394
|
+
* Starts at 1.
|
|
1395
|
+
*/
|
|
1396
|
+
export declare function pvi(close: Source, volume: Source): series_float;
|
|
1397
|
+
//# sourceMappingURL=index.d.ts.map
|