react-klinecharts-ui 0.1.0 → 0.2.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/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { Dispatch, RefObject, ReactNode, ReactElement } from 'react';
3
- import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader } from 'react-klinecharts';
3
+ import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader, IndicatorTemplate } from 'react-klinecharts';
4
4
  import { OrderLineExtendData } from './extensions.cjs';
5
- export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, orderLine, overlays, registerExtensions } from './extensions.cjs';
5
+ export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, indicators, orderLine, overlays, registerExtensions } from './extensions.cjs';
6
6
 
7
7
  interface TerminalPeriod extends Period {
8
8
  label: string;
@@ -102,12 +102,19 @@ type KlinechartsUIAction = {
102
102
  type: "SET_SCREENSHOT_URL";
103
103
  url: string | null;
104
104
  };
105
+ /** Callback pushed by useUndoRedo so other hooks can record actions. */
106
+ type UndoRedoListener = (action: {
107
+ type: string;
108
+ data: unknown;
109
+ }) => void;
105
110
  /** The stable, dispatch-only slice of the context (never changes after mount). */
106
111
  interface KlinechartsUIDispatchValue {
107
112
  dispatch: Dispatch<KlinechartsUIAction>;
108
113
  datafeed: Datafeed;
109
114
  onSettingsChange?: (settings: Record<string, unknown>) => void;
110
115
  fullscreenContainerRef: RefObject<HTMLElement | null>;
116
+ /** Ref populated by useUndoRedo; other hooks call it to record actions. */
117
+ undoRedoListenerRef: RefObject<UndoRedoListener | null>;
111
118
  }
112
119
  /** Combined context value returned by `useKlinechartsUI()`. */
113
120
  interface KlinechartsUIContextValue extends KlinechartsUIDispatchValue {
@@ -358,6 +365,135 @@ interface UseOrderLinesReturn {
358
365
  }
359
366
  declare function useOrderLines(): UseOrderLinesReturn;
360
367
 
368
+ type UndoRedoActionType = "overlay_added" | "overlays_removed" | "indicator_toggled";
369
+ interface UndoRedoAction {
370
+ type: UndoRedoActionType;
371
+ /** Snapshot data needed to undo/redo this action */
372
+ data: any;
373
+ }
374
+ interface UseUndoRedoReturn {
375
+ /** Whether there are actions to undo */
376
+ canUndo: boolean;
377
+ /** Whether there are actions to redo */
378
+ canRedo: boolean;
379
+ /** Undo the last action */
380
+ undo: () => void;
381
+ /** Redo the last undone action */
382
+ redo: () => void;
383
+ /** Push a new action onto the undo stack (clears redo stack) */
384
+ pushAction: (action: UndoRedoAction) => void;
385
+ /** Clear all undo/redo history */
386
+ clear: () => void;
387
+ }
388
+ /**
389
+ * Headless hook for undo/redo of drawing overlays and indicator toggles.
390
+ *
391
+ * Supports keyboard shortcuts: Ctrl+Z (undo), Ctrl+Y / Ctrl+Shift+Z (redo).
392
+ */
393
+ declare function useUndoRedo(): UseUndoRedoReturn;
394
+
395
+ interface ChartLayoutState {
396
+ version: string;
397
+ meta: {
398
+ symbol: string;
399
+ period: string;
400
+ timestamp: number;
401
+ lastModified: number;
402
+ };
403
+ indicators: Array<{
404
+ paneId: string;
405
+ name: string;
406
+ calcParams: any[];
407
+ visible: boolean;
408
+ styles?: any;
409
+ }>;
410
+ drawings: Array<{
411
+ name: string;
412
+ points: any[];
413
+ styles?: any;
414
+ extendData?: any;
415
+ }>;
416
+ }
417
+ interface LayoutEntry {
418
+ id: string;
419
+ name: string;
420
+ symbol: string;
421
+ period: string;
422
+ timestamp: number;
423
+ lastModified: number;
424
+ state: ChartLayoutState;
425
+ }
426
+ interface UseLayoutManagerReturn {
427
+ /** List of saved layout entries */
428
+ layouts: LayoutEntry[];
429
+ /** Save current chart state as a named layout */
430
+ saveLayout: (name: string) => string | null;
431
+ /** Load a layout by ID and apply to the chart */
432
+ loadLayout: (id: string) => boolean;
433
+ /** Delete a layout by ID */
434
+ deleteLayout: (id: string) => void;
435
+ /** Rename a layout */
436
+ renameLayout: (id: string, name: string) => boolean;
437
+ /** Refresh the layouts list from localStorage */
438
+ refreshLayouts: () => void;
439
+ /** Whether auto-save is enabled */
440
+ autoSaveEnabled: boolean;
441
+ /** Toggle auto-save on/off */
442
+ setAutoSaveEnabled: (enabled: boolean) => void;
443
+ }
444
+ /**
445
+ * Headless hook for saving, loading, and managing named chart layouts
446
+ * via localStorage. Supports auto-save with 5-second debounce.
447
+ */
448
+ declare function useLayoutManager(): UseLayoutManagerReturn;
449
+
450
+ type ScriptPlacement = "main" | "sub";
451
+ interface UseScriptEditorReturn {
452
+ /** Current script source code */
453
+ code: string;
454
+ setCode: (code: string) => void;
455
+ /** Display name of the script */
456
+ scriptName: string;
457
+ setScriptName: (name: string) => void;
458
+ /** Comma-separated numeric params (e.g. "14, 26, 9") */
459
+ params: string;
460
+ setParams: (params: string) => void;
461
+ /** Where to place the indicator */
462
+ placement: ScriptPlacement;
463
+ setPlacement: (p: ScriptPlacement) => void;
464
+ /** Last error message (empty = no error) */
465
+ error: string;
466
+ /** Last status message */
467
+ status: string;
468
+ /** Whether the script is currently running */
469
+ isRunning: boolean;
470
+ /** Whether there is a script indicator currently on the chart */
471
+ hasActiveScript: boolean;
472
+ /** Execute the script and register the indicator */
473
+ runScript: () => void;
474
+ /** Remove the current script indicator from the chart */
475
+ removeScript: () => void;
476
+ /** Reset code to the default template */
477
+ resetCode: () => void;
478
+ /** Export the current code as a downloadable .js file */
479
+ exportScript: () => void;
480
+ /** Import a script from a File object */
481
+ importScript: (file: File) => void;
482
+ /** The default template code */
483
+ defaultScript: string;
484
+ }
485
+ /**
486
+ * Headless hook for a Pine Script-style custom indicator editor.
487
+ *
488
+ * Scripts are plain JavaScript function bodies that receive:
489
+ * - `TA` — technical analysis math library
490
+ * - `dataList` — KLineData[] (open, high, low, close, volume, timestamp)
491
+ * - `params` — number[] from the params input
492
+ *
493
+ * Must return an array of objects, one per candle. Each key = one chart series.
494
+ */
495
+ declare function useScriptEditor(): UseScriptEditorReturn;
496
+
361
497
  interface TimezoneOption {
362
498
  key: string;
363
499
  localeKey: string;
@@ -389,6 +525,76 @@ declare const INDICATOR_PARAMS: Record<string, IndicatorDefinition>;
389
525
  */
390
526
  declare function createDataLoader(datafeed: Datafeed, dispatch: Dispatch<KlinechartsUIAction>): DataLoader;
391
527
 
528
+ /**
529
+ * Technical Analysis (TA) Utility Library
530
+ * Ported logic to match TradingView / Pine Script calculations.
531
+ */
532
+ declare const TA: {
533
+ /**
534
+ * Simple Moving Average (SMA)
535
+ * Optimized with running sum.
536
+ */
537
+ sma: (data: number[], period: number) => (number | null)[];
538
+ /**
539
+ * Exponential Moving Average (EMA)
540
+ * alpha = 2 / (period + 1)
541
+ */
542
+ ema: (data: number[], period: number) => (number | null)[];
543
+ /**
544
+ * Running Moving Average (RMA / Wilder's MA)
545
+ * Used in RSI, alpha = 1 / period
546
+ */
547
+ rma: (data: number[], period: number) => (number | null)[];
548
+ /**
549
+ * Standard Deviation
550
+ */
551
+ stdev: (data: number[], period: number) => (number | null)[];
552
+ /**
553
+ * Relative Strength Index (RSI)
554
+ */
555
+ rsi: (data: number[], period: number) => (number | null)[];
556
+ /**
557
+ * Moving Average Convergence Divergence (MACD)
558
+ */
559
+ macd: (data: number[], fastPeriod: number, slowPeriod: number, signalPeriod: number) => {
560
+ dif: (number | null)[];
561
+ dea: (number | null)[];
562
+ macd: (number | null)[];
563
+ };
564
+ /**
565
+ * Bollinger Bands (BOLL)
566
+ */
567
+ bollinger: (data: number[], period: number, multiplier: number) => {
568
+ mid: (number | null)[];
569
+ upper: (number | null)[];
570
+ lower: (number | null)[];
571
+ };
572
+ /**
573
+ * Weighted Moving Average (WMA)
574
+ */
575
+ wma: (data: number[], period: number) => (number | null)[];
576
+ /**
577
+ * True Range (TR)
578
+ */
579
+ tr: (highs: number[], lows: number[], closes: number[]) => number[];
580
+ /**
581
+ * Average True Range (ATR)
582
+ */
583
+ atr: (highs: number[], lows: number[], closes: number[], period: number) => (number | null)[];
584
+ /**
585
+ * Volume Weighted Average Price (VWAP)
586
+ */
587
+ vwap: (highs: number[], lows: number[], closes: number[], volumes: number[]) => (number | null)[];
588
+ /**
589
+ * Commodity Channel Index (CCI)
590
+ */
591
+ cci: (highs: number[], lows: number[], closes: number[], period: number) => (number | null)[];
592
+ /**
593
+ * Hull Moving Average (HMA)
594
+ */
595
+ hma: (data: number[], period: number) => (number | null)[];
596
+ };
597
+
392
598
  declare const arrow: OverlayTemplate;
393
599
 
394
600
  declare const circle: OverlayTemplate;
@@ -409,8 +615,12 @@ declare const fibonacciSpeedResistanceFan: OverlayTemplate;
409
615
 
410
616
  declare const fibonacciExtension: OverlayTemplate;
411
617
 
618
+ declare const fibRetracement: OverlayTemplate;
619
+
412
620
  declare const gannBox: OverlayTemplate;
413
621
 
622
+ declare const gannFan: OverlayTemplate;
623
+
414
624
  declare const threeWaves: OverlayTemplate;
415
625
 
416
626
  declare const fiveWaves: OverlayTemplate;
@@ -419,8 +629,48 @@ declare const eightWaves: OverlayTemplate;
419
629
 
420
630
  declare const anyWaves: OverlayTemplate;
421
631
 
632
+ declare const elliottWave: OverlayTemplate;
633
+
422
634
  declare const abcd: OverlayTemplate;
423
635
 
424
636
  declare const xabcd: OverlayTemplate;
425
637
 
426
- export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, circle, createDataLoader, eightWaves, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, parallelogram, rect, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useOrderLines, usePeriods, useScreenshot, useSymbolSearch, useTimezone, xabcd };
638
+ declare const ray: OverlayTemplate;
639
+
640
+ declare const parallelChannel: OverlayTemplate;
641
+
642
+ declare const longPosition: OverlayTemplate;
643
+
644
+ declare const shortPosition: OverlayTemplate;
645
+
646
+ declare const measure: OverlayTemplate;
647
+
648
+ declare const brush: OverlayTemplate;
649
+
650
+ declare const bollTv: IndicatorTemplate;
651
+
652
+ declare const cci: IndicatorTemplate;
653
+
654
+ declare const hma: IndicatorTemplate;
655
+
656
+ declare const ichimoku: IndicatorTemplate;
657
+
658
+ declare const maRibbon: IndicatorTemplate;
659
+
660
+ declare const macdTv: IndicatorTemplate;
661
+
662
+ declare const pivotPoints: IndicatorTemplate;
663
+
664
+ /**
665
+ * TradingView-style RSI with RMA-based calculation,
666
+ * dashed level lines at 70/50/30, and gradient fills.
667
+ */
668
+ declare const rsiTv: IndicatorTemplate;
669
+
670
+ declare const stochastic: IndicatorTemplate;
671
+
672
+ declare const superTrend: IndicatorTemplate;
673
+
674
+ declare const vwap: IndicatorTemplate;
675
+
676
+ export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useOrderLines, usePeriods, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, vwap, xabcd };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { Dispatch, RefObject, ReactNode, ReactElement } from 'react';
3
- import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader } from 'react-klinecharts';
3
+ import { Period, SymbolInfo, KLineData, Chart, DeepPartial, Styles, OverlayTemplate, DataLoader, IndicatorTemplate } from 'react-klinecharts';
4
4
  import { OrderLineExtendData } from './extensions.js';
5
- export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, orderLine, overlays, registerExtensions } from './extensions.js';
5
+ export { OrderLineFontStyle, OrderLineLabelStyle, OrderLineLineStyle, OrderLineMarkStyle, OrderLinePadding, indicators, orderLine, overlays, registerExtensions } from './extensions.js';
6
6
 
7
7
  interface TerminalPeriod extends Period {
8
8
  label: string;
@@ -102,12 +102,19 @@ type KlinechartsUIAction = {
102
102
  type: "SET_SCREENSHOT_URL";
103
103
  url: string | null;
104
104
  };
105
+ /** Callback pushed by useUndoRedo so other hooks can record actions. */
106
+ type UndoRedoListener = (action: {
107
+ type: string;
108
+ data: unknown;
109
+ }) => void;
105
110
  /** The stable, dispatch-only slice of the context (never changes after mount). */
106
111
  interface KlinechartsUIDispatchValue {
107
112
  dispatch: Dispatch<KlinechartsUIAction>;
108
113
  datafeed: Datafeed;
109
114
  onSettingsChange?: (settings: Record<string, unknown>) => void;
110
115
  fullscreenContainerRef: RefObject<HTMLElement | null>;
116
+ /** Ref populated by useUndoRedo; other hooks call it to record actions. */
117
+ undoRedoListenerRef: RefObject<UndoRedoListener | null>;
111
118
  }
112
119
  /** Combined context value returned by `useKlinechartsUI()`. */
113
120
  interface KlinechartsUIContextValue extends KlinechartsUIDispatchValue {
@@ -358,6 +365,135 @@ interface UseOrderLinesReturn {
358
365
  }
359
366
  declare function useOrderLines(): UseOrderLinesReturn;
360
367
 
368
+ type UndoRedoActionType = "overlay_added" | "overlays_removed" | "indicator_toggled";
369
+ interface UndoRedoAction {
370
+ type: UndoRedoActionType;
371
+ /** Snapshot data needed to undo/redo this action */
372
+ data: any;
373
+ }
374
+ interface UseUndoRedoReturn {
375
+ /** Whether there are actions to undo */
376
+ canUndo: boolean;
377
+ /** Whether there are actions to redo */
378
+ canRedo: boolean;
379
+ /** Undo the last action */
380
+ undo: () => void;
381
+ /** Redo the last undone action */
382
+ redo: () => void;
383
+ /** Push a new action onto the undo stack (clears redo stack) */
384
+ pushAction: (action: UndoRedoAction) => void;
385
+ /** Clear all undo/redo history */
386
+ clear: () => void;
387
+ }
388
+ /**
389
+ * Headless hook for undo/redo of drawing overlays and indicator toggles.
390
+ *
391
+ * Supports keyboard shortcuts: Ctrl+Z (undo), Ctrl+Y / Ctrl+Shift+Z (redo).
392
+ */
393
+ declare function useUndoRedo(): UseUndoRedoReturn;
394
+
395
+ interface ChartLayoutState {
396
+ version: string;
397
+ meta: {
398
+ symbol: string;
399
+ period: string;
400
+ timestamp: number;
401
+ lastModified: number;
402
+ };
403
+ indicators: Array<{
404
+ paneId: string;
405
+ name: string;
406
+ calcParams: any[];
407
+ visible: boolean;
408
+ styles?: any;
409
+ }>;
410
+ drawings: Array<{
411
+ name: string;
412
+ points: any[];
413
+ styles?: any;
414
+ extendData?: any;
415
+ }>;
416
+ }
417
+ interface LayoutEntry {
418
+ id: string;
419
+ name: string;
420
+ symbol: string;
421
+ period: string;
422
+ timestamp: number;
423
+ lastModified: number;
424
+ state: ChartLayoutState;
425
+ }
426
+ interface UseLayoutManagerReturn {
427
+ /** List of saved layout entries */
428
+ layouts: LayoutEntry[];
429
+ /** Save current chart state as a named layout */
430
+ saveLayout: (name: string) => string | null;
431
+ /** Load a layout by ID and apply to the chart */
432
+ loadLayout: (id: string) => boolean;
433
+ /** Delete a layout by ID */
434
+ deleteLayout: (id: string) => void;
435
+ /** Rename a layout */
436
+ renameLayout: (id: string, name: string) => boolean;
437
+ /** Refresh the layouts list from localStorage */
438
+ refreshLayouts: () => void;
439
+ /** Whether auto-save is enabled */
440
+ autoSaveEnabled: boolean;
441
+ /** Toggle auto-save on/off */
442
+ setAutoSaveEnabled: (enabled: boolean) => void;
443
+ }
444
+ /**
445
+ * Headless hook for saving, loading, and managing named chart layouts
446
+ * via localStorage. Supports auto-save with 5-second debounce.
447
+ */
448
+ declare function useLayoutManager(): UseLayoutManagerReturn;
449
+
450
+ type ScriptPlacement = "main" | "sub";
451
+ interface UseScriptEditorReturn {
452
+ /** Current script source code */
453
+ code: string;
454
+ setCode: (code: string) => void;
455
+ /** Display name of the script */
456
+ scriptName: string;
457
+ setScriptName: (name: string) => void;
458
+ /** Comma-separated numeric params (e.g. "14, 26, 9") */
459
+ params: string;
460
+ setParams: (params: string) => void;
461
+ /** Where to place the indicator */
462
+ placement: ScriptPlacement;
463
+ setPlacement: (p: ScriptPlacement) => void;
464
+ /** Last error message (empty = no error) */
465
+ error: string;
466
+ /** Last status message */
467
+ status: string;
468
+ /** Whether the script is currently running */
469
+ isRunning: boolean;
470
+ /** Whether there is a script indicator currently on the chart */
471
+ hasActiveScript: boolean;
472
+ /** Execute the script and register the indicator */
473
+ runScript: () => void;
474
+ /** Remove the current script indicator from the chart */
475
+ removeScript: () => void;
476
+ /** Reset code to the default template */
477
+ resetCode: () => void;
478
+ /** Export the current code as a downloadable .js file */
479
+ exportScript: () => void;
480
+ /** Import a script from a File object */
481
+ importScript: (file: File) => void;
482
+ /** The default template code */
483
+ defaultScript: string;
484
+ }
485
+ /**
486
+ * Headless hook for a Pine Script-style custom indicator editor.
487
+ *
488
+ * Scripts are plain JavaScript function bodies that receive:
489
+ * - `TA` — technical analysis math library
490
+ * - `dataList` — KLineData[] (open, high, low, close, volume, timestamp)
491
+ * - `params` — number[] from the params input
492
+ *
493
+ * Must return an array of objects, one per candle. Each key = one chart series.
494
+ */
495
+ declare function useScriptEditor(): UseScriptEditorReturn;
496
+
361
497
  interface TimezoneOption {
362
498
  key: string;
363
499
  localeKey: string;
@@ -389,6 +525,76 @@ declare const INDICATOR_PARAMS: Record<string, IndicatorDefinition>;
389
525
  */
390
526
  declare function createDataLoader(datafeed: Datafeed, dispatch: Dispatch<KlinechartsUIAction>): DataLoader;
391
527
 
528
+ /**
529
+ * Technical Analysis (TA) Utility Library
530
+ * Ported logic to match TradingView / Pine Script calculations.
531
+ */
532
+ declare const TA: {
533
+ /**
534
+ * Simple Moving Average (SMA)
535
+ * Optimized with running sum.
536
+ */
537
+ sma: (data: number[], period: number) => (number | null)[];
538
+ /**
539
+ * Exponential Moving Average (EMA)
540
+ * alpha = 2 / (period + 1)
541
+ */
542
+ ema: (data: number[], period: number) => (number | null)[];
543
+ /**
544
+ * Running Moving Average (RMA / Wilder's MA)
545
+ * Used in RSI, alpha = 1 / period
546
+ */
547
+ rma: (data: number[], period: number) => (number | null)[];
548
+ /**
549
+ * Standard Deviation
550
+ */
551
+ stdev: (data: number[], period: number) => (number | null)[];
552
+ /**
553
+ * Relative Strength Index (RSI)
554
+ */
555
+ rsi: (data: number[], period: number) => (number | null)[];
556
+ /**
557
+ * Moving Average Convergence Divergence (MACD)
558
+ */
559
+ macd: (data: number[], fastPeriod: number, slowPeriod: number, signalPeriod: number) => {
560
+ dif: (number | null)[];
561
+ dea: (number | null)[];
562
+ macd: (number | null)[];
563
+ };
564
+ /**
565
+ * Bollinger Bands (BOLL)
566
+ */
567
+ bollinger: (data: number[], period: number, multiplier: number) => {
568
+ mid: (number | null)[];
569
+ upper: (number | null)[];
570
+ lower: (number | null)[];
571
+ };
572
+ /**
573
+ * Weighted Moving Average (WMA)
574
+ */
575
+ wma: (data: number[], period: number) => (number | null)[];
576
+ /**
577
+ * True Range (TR)
578
+ */
579
+ tr: (highs: number[], lows: number[], closes: number[]) => number[];
580
+ /**
581
+ * Average True Range (ATR)
582
+ */
583
+ atr: (highs: number[], lows: number[], closes: number[], period: number) => (number | null)[];
584
+ /**
585
+ * Volume Weighted Average Price (VWAP)
586
+ */
587
+ vwap: (highs: number[], lows: number[], closes: number[], volumes: number[]) => (number | null)[];
588
+ /**
589
+ * Commodity Channel Index (CCI)
590
+ */
591
+ cci: (highs: number[], lows: number[], closes: number[], period: number) => (number | null)[];
592
+ /**
593
+ * Hull Moving Average (HMA)
594
+ */
595
+ hma: (data: number[], period: number) => (number | null)[];
596
+ };
597
+
392
598
  declare const arrow: OverlayTemplate;
393
599
 
394
600
  declare const circle: OverlayTemplate;
@@ -409,8 +615,12 @@ declare const fibonacciSpeedResistanceFan: OverlayTemplate;
409
615
 
410
616
  declare const fibonacciExtension: OverlayTemplate;
411
617
 
618
+ declare const fibRetracement: OverlayTemplate;
619
+
412
620
  declare const gannBox: OverlayTemplate;
413
621
 
622
+ declare const gannFan: OverlayTemplate;
623
+
414
624
  declare const threeWaves: OverlayTemplate;
415
625
 
416
626
  declare const fiveWaves: OverlayTemplate;
@@ -419,8 +629,48 @@ declare const eightWaves: OverlayTemplate;
419
629
 
420
630
  declare const anyWaves: OverlayTemplate;
421
631
 
632
+ declare const elliottWave: OverlayTemplate;
633
+
422
634
  declare const abcd: OverlayTemplate;
423
635
 
424
636
  declare const xabcd: OverlayTemplate;
425
637
 
426
- export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, circle, createDataLoader, eightWaves, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, parallelogram, rect, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useOrderLines, usePeriods, useScreenshot, useSymbolSearch, useTimezone, xabcd };
638
+ declare const ray: OverlayTemplate;
639
+
640
+ declare const parallelChannel: OverlayTemplate;
641
+
642
+ declare const longPosition: OverlayTemplate;
643
+
644
+ declare const shortPosition: OverlayTemplate;
645
+
646
+ declare const measure: OverlayTemplate;
647
+
648
+ declare const brush: OverlayTemplate;
649
+
650
+ declare const bollTv: IndicatorTemplate;
651
+
652
+ declare const cci: IndicatorTemplate;
653
+
654
+ declare const hma: IndicatorTemplate;
655
+
656
+ declare const ichimoku: IndicatorTemplate;
657
+
658
+ declare const maRibbon: IndicatorTemplate;
659
+
660
+ declare const macdTv: IndicatorTemplate;
661
+
662
+ declare const pivotPoints: IndicatorTemplate;
663
+
664
+ /**
665
+ * TradingView-style RSI with RMA-based calculation,
666
+ * dashed level lines at 70/50/30, and gradient fills.
667
+ */
668
+ declare const rsiTv: IndicatorTemplate;
669
+
670
+ declare const stochastic: IndicatorTemplate;
671
+
672
+ declare const superTrend: IndicatorTemplate;
673
+
674
+ declare const vwap: IndicatorTemplate;
675
+
676
+ export { CANDLE_TYPES, COMPARE_RULES, type CandleTypeItem, type CandleTypeOption, type ChartLayoutState, type CompareRule, DEFAULT_PERIODS, DRAWING_CATEGORIES, type Datafeed, type DrawingCategoryItem, type DrawingTool, type DrawingToolCategory, type DrawingToolItem, INDICATOR_PARAMS, type IndicatorDefinition, type IndicatorInfo, type IndicatorParamConfig, type KlinechartsUIAction, type KlinechartsUIContextValue, KlinechartsUIDispatchContext, type KlinechartsUIDispatchValue, type KlinechartsUIOptions, KlinechartsUIProvider, type KlinechartsUISettingsState, type KlinechartsUIState, KlinechartsUIStateContext, type LayoutEntry, MAIN_INDICATORS, type MagnetMode, OrderLineExtendData, type OrderLineOptions, PRICE_AXIS_TYPES, type PartialSymbolInfo, type PriceAxisType, SUB_INDICATORS, type ScriptPlacement, TA, TIMEZONES, TOOLTIP_SHOW_RULES, type TerminalPeriod, type TimezoneItem, type TimezoneOption, type TooltipShowRule, type UndoRedoAction, type UndoRedoActionType, type UseDrawingToolsReturn, type UseFullscreenReturn, type UseIndicatorsReturn, type UseKlinechartsUILoadingReturn, type UseKlinechartsUISettingsReturn, type UseKlinechartsUIThemeReturn, type UseLayoutManagerReturn, type UseOrderLinesReturn, type UsePeriodsReturn, type UseScreenshotReturn, type UseScriptEditorReturn, type UseSymbolSearchReturn, type UseTimezoneReturn, type UseUndoRedoReturn, YAXIS_POSITIONS, type YAxisPosition, abcd, anyWaves, arrow, bollTv, brush, cci, circle, createDataLoader, eightWaves, elliottWave, fibRetracement, fibonacciCircle, fibonacciExtension, fibonacciSegment, fibonacciSpeedResistanceFan, fibonacciSpiral, fiveWaves, gannBox, gannFan, hma, ichimoku, longPosition, maRibbon, macdTv, measure, parallelChannel, parallelogram, pivotPoints, ray, rect, rsiTv, shortPosition, stochastic, superTrend, threeWaves, triangle, useDrawingTools, useFullscreen, useIndicators, useKlinechartsUI, useKlinechartsUILoading, useKlinechartsUISettings, useKlinechartsUITheme, useLayoutManager, useOrderLines, usePeriods, useScreenshot, useScriptEditor, useSymbolSearch, useTimezone, useUndoRedo, vwap, xabcd };