pinets 0.3.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +50 -3
  2. package/dist/pinets.dev.browser.js +6429 -1434
  3. package/dist/pinets.dev.cjs +6525 -1418
  4. package/dist/pinets.dev.cjs.map +1 -1
  5. package/dist/pinets.dev.es.js +6527 -1415
  6. package/dist/pinets.dev.es.js.map +1 -1
  7. package/dist/pinets.min.browser.js +16 -11
  8. package/dist/pinets.min.cjs +16 -11
  9. package/dist/pinets.min.es.js +6 -1
  10. package/dist/types/Context.class.d.ts +79 -17
  11. package/dist/types/PineTS.class.d.ts +13 -1
  12. package/dist/types/marketData/Binance/BinanceProvider.class.d.ts +2 -1
  13. package/dist/types/marketData/IProvider.d.ts +43 -0
  14. package/dist/types/marketData/Mock/MockProvider.class.d.ts +13 -1
  15. package/dist/types/namespaces/Barstate.d.ts +13 -0
  16. package/dist/types/namespaces/Core.d.ts +16 -0
  17. package/dist/types/namespaces/Log.d.ts +10 -0
  18. package/dist/types/namespaces/Str.d.ts +23 -0
  19. package/dist/types/namespaces/Timeframe.d.ts +17 -0
  20. package/dist/types/namespaces/Types.d.ts +86 -0
  21. package/dist/types/namespaces/array/PineArrayObject.d.ts +102 -1
  22. package/dist/types/namespaces/array/array.index.d.ts +1 -129
  23. package/dist/types/namespaces/array/methods/avg.d.ts +2 -1
  24. package/dist/types/namespaces/array/methods/binary_search.d.ts +2 -0
  25. package/dist/types/namespaces/array/methods/binary_search_leftmost.d.ts +2 -0
  26. package/dist/types/namespaces/array/methods/binary_search_rightmost.d.ts +2 -0
  27. package/dist/types/namespaces/array/methods/covariance.d.ts +2 -1
  28. package/dist/types/namespaces/array/methods/every.d.ts +1 -1
  29. package/dist/types/namespaces/array/methods/fill.d.ts +2 -1
  30. package/dist/types/namespaces/array/methods/from.d.ts +1 -1
  31. package/dist/types/namespaces/array/methods/join.d.ts +5 -0
  32. package/dist/types/namespaces/array/methods/median.d.ts +2 -0
  33. package/dist/types/namespaces/array/methods/mode.d.ts +2 -0
  34. package/dist/types/namespaces/array/methods/new.d.ts +2 -1
  35. package/dist/types/namespaces/array/methods/new_float.d.ts +2 -1
  36. package/dist/types/namespaces/array/methods/new_int.d.ts +2 -1
  37. package/dist/types/namespaces/array/methods/percentile_linear_interpolation.d.ts +3 -0
  38. package/dist/types/namespaces/array/methods/percentile_nearest_rank.d.ts +2 -0
  39. package/dist/types/namespaces/array/methods/percentrank.d.ts +2 -0
  40. package/dist/types/namespaces/array/methods/push.d.ts +2 -1
  41. package/dist/types/namespaces/array/methods/range.d.ts +2 -1
  42. package/dist/types/namespaces/array/methods/set.d.ts +2 -1
  43. package/dist/types/namespaces/array/methods/some.d.ts +1 -1
  44. package/dist/types/namespaces/array/methods/sort.d.ts +2 -1
  45. package/dist/types/namespaces/array/methods/sort_indices.d.ts +2 -1
  46. package/dist/types/namespaces/array/methods/stdev.d.ts +2 -1
  47. package/dist/types/namespaces/array/methods/sum.d.ts +2 -1
  48. package/dist/types/namespaces/array/methods/unshift.d.ts +2 -1
  49. package/dist/types/namespaces/array/methods/variance.d.ts +2 -1
  50. package/dist/types/namespaces/array/utils.d.ts +5 -0
  51. package/dist/types/namespaces/input/methods/any.d.ts +1 -2
  52. package/dist/types/namespaces/input/methods/bool.d.ts +1 -2
  53. package/dist/types/namespaces/input/methods/color.d.ts +1 -2
  54. package/dist/types/namespaces/input/methods/enum.d.ts +1 -2
  55. package/dist/types/namespaces/input/methods/float.d.ts +1 -2
  56. package/dist/types/namespaces/input/methods/int.d.ts +1 -2
  57. package/dist/types/namespaces/input/methods/param.d.ts +1 -1
  58. package/dist/types/namespaces/input/methods/price.d.ts +1 -2
  59. package/dist/types/namespaces/input/methods/session.d.ts +1 -2
  60. package/dist/types/namespaces/input/methods/source.d.ts +1 -2
  61. package/dist/types/namespaces/input/methods/string.d.ts +1 -2
  62. package/dist/types/namespaces/input/methods/symbol.d.ts +1 -2
  63. package/dist/types/namespaces/input/methods/text_area.d.ts +1 -2
  64. package/dist/types/namespaces/input/methods/time.d.ts +1 -2
  65. package/dist/types/namespaces/input/methods/timeframe.d.ts +1 -2
  66. package/dist/types/namespaces/input/types.d.ts +12 -1
  67. package/dist/types/namespaces/input/utils.d.ts +14 -0
  68. package/dist/types/namespaces/map/PineMapObject.d.ts +26 -0
  69. package/dist/types/namespaces/map/map.index.d.ts +7 -0
  70. package/dist/types/namespaces/map/methods/clear.d.ts +3 -0
  71. package/dist/types/namespaces/map/methods/contains.d.ts +3 -0
  72. package/dist/types/namespaces/map/methods/copy.d.ts +3 -0
  73. package/dist/types/namespaces/map/methods/get.d.ts +3 -0
  74. package/dist/types/namespaces/map/methods/keys.d.ts +4 -0
  75. package/dist/types/namespaces/map/methods/new.d.ts +3 -0
  76. package/dist/types/namespaces/map/methods/param.d.ts +1 -0
  77. package/dist/types/namespaces/map/methods/put.d.ts +3 -0
  78. package/dist/types/namespaces/map/methods/put_all.d.ts +3 -0
  79. package/dist/types/namespaces/map/methods/remove.d.ts +3 -0
  80. package/dist/types/namespaces/map/methods/size.d.ts +3 -0
  81. package/dist/types/namespaces/map/methods/values.d.ts +4 -0
  82. package/dist/types/namespaces/math/math.index.d.ts +18 -0
  83. package/dist/types/namespaces/math/methods/abs.d.ts +2 -1
  84. package/dist/types/namespaces/math/methods/e.d.ts +5 -0
  85. package/dist/types/namespaces/math/methods/phi.d.ts +5 -0
  86. package/dist/types/namespaces/math/methods/pi.d.ts +5 -0
  87. package/dist/types/namespaces/math/methods/round_to_mintick.d.ts +2 -0
  88. package/dist/types/namespaces/math/methods/rphi.d.ts +5 -0
  89. package/dist/types/namespaces/math/methods/sign.d.ts +2 -0
  90. package/dist/types/namespaces/matrix/PineMatrixObject.d.ts +102 -0
  91. package/dist/types/namespaces/matrix/matrix.index.d.ts +7 -0
  92. package/dist/types/namespaces/matrix/methods/add_col.d.ts +3 -0
  93. package/dist/types/namespaces/matrix/methods/add_row.d.ts +3 -0
  94. package/dist/types/namespaces/matrix/methods/avg.d.ts +3 -0
  95. package/dist/types/namespaces/matrix/methods/col.d.ts +4 -0
  96. package/dist/types/namespaces/matrix/methods/columns.d.ts +3 -0
  97. package/dist/types/namespaces/matrix/methods/concat.d.ts +3 -0
  98. package/dist/types/namespaces/matrix/methods/copy.d.ts +3 -0
  99. package/dist/types/namespaces/matrix/methods/det.d.ts +3 -0
  100. package/dist/types/namespaces/matrix/methods/diff.d.ts +3 -0
  101. package/dist/types/namespaces/matrix/methods/eigenvalues.d.ts +4 -0
  102. package/dist/types/namespaces/matrix/methods/eigenvectors.d.ts +3 -0
  103. package/dist/types/namespaces/matrix/methods/elements_count.d.ts +3 -0
  104. package/dist/types/namespaces/matrix/methods/fill.d.ts +3 -0
  105. package/dist/types/namespaces/matrix/methods/get.d.ts +3 -0
  106. package/dist/types/namespaces/matrix/methods/inv.d.ts +3 -0
  107. package/dist/types/namespaces/matrix/methods/is_antidiagonal.d.ts +3 -0
  108. package/dist/types/namespaces/matrix/methods/is_antisymmetric.d.ts +3 -0
  109. package/dist/types/namespaces/matrix/methods/is_binary.d.ts +3 -0
  110. package/dist/types/namespaces/matrix/methods/is_diagonal.d.ts +3 -0
  111. package/dist/types/namespaces/matrix/methods/is_identity.d.ts +3 -0
  112. package/dist/types/namespaces/matrix/methods/is_square.d.ts +3 -0
  113. package/dist/types/namespaces/matrix/methods/is_stochastic.d.ts +3 -0
  114. package/dist/types/namespaces/matrix/methods/is_symmetric.d.ts +3 -0
  115. package/dist/types/namespaces/matrix/methods/is_triangular.d.ts +3 -0
  116. package/dist/types/namespaces/matrix/methods/is_zero.d.ts +3 -0
  117. package/dist/types/namespaces/matrix/methods/kron.d.ts +3 -0
  118. package/dist/types/namespaces/matrix/methods/max.d.ts +3 -0
  119. package/dist/types/namespaces/matrix/methods/median.d.ts +3 -0
  120. package/dist/types/namespaces/matrix/methods/min.d.ts +3 -0
  121. package/dist/types/namespaces/matrix/methods/mode.d.ts +3 -0
  122. package/dist/types/namespaces/matrix/methods/mult.d.ts +4 -0
  123. package/dist/types/namespaces/matrix/methods/new.d.ts +3 -0
  124. package/dist/types/namespaces/matrix/methods/param.d.ts +1 -0
  125. package/dist/types/namespaces/matrix/methods/pinv.d.ts +3 -0
  126. package/dist/types/namespaces/matrix/methods/pow.d.ts +3 -0
  127. package/dist/types/namespaces/matrix/methods/rank.d.ts +3 -0
  128. package/dist/types/namespaces/matrix/methods/remove_col.d.ts +4 -0
  129. package/dist/types/namespaces/matrix/methods/remove_row.d.ts +4 -0
  130. package/dist/types/namespaces/matrix/methods/reshape.d.ts +3 -0
  131. package/dist/types/namespaces/matrix/methods/reverse.d.ts +3 -0
  132. package/dist/types/namespaces/matrix/methods/row.d.ts +4 -0
  133. package/dist/types/namespaces/matrix/methods/rows.d.ts +3 -0
  134. package/dist/types/namespaces/matrix/methods/set.d.ts +3 -0
  135. package/dist/types/namespaces/matrix/methods/sort.d.ts +3 -0
  136. package/dist/types/namespaces/matrix/methods/submatrix.d.ts +3 -0
  137. package/dist/types/namespaces/matrix/methods/sum.d.ts +3 -0
  138. package/dist/types/namespaces/matrix/methods/swap_columns.d.ts +3 -0
  139. package/dist/types/namespaces/matrix/methods/swap_rows.d.ts +3 -0
  140. package/dist/types/namespaces/matrix/methods/trace.d.ts +3 -0
  141. package/dist/types/namespaces/matrix/methods/transpose.d.ts +3 -0
  142. package/dist/types/namespaces/request/methods/security.d.ts +1 -1
  143. package/dist/types/namespaces/request/methods/security_lower_tf.d.ts +9 -0
  144. package/dist/types/namespaces/request/request.index.d.ts +3 -0
  145. package/dist/types/namespaces/request/types/barmerge.type.d.ts +7 -0
  146. package/dist/types/namespaces/request/utils/findLTFContextIdx.d.ts +1 -0
  147. package/dist/types/namespaces/ta/getters/obv.d.ts +12 -0
  148. package/dist/types/namespaces/ta/methods/accdist.d.ts +7 -0
  149. package/dist/types/namespaces/ta/methods/alma.d.ts +18 -0
  150. package/dist/types/namespaces/ta/methods/atr.d.ts +2 -1
  151. package/dist/types/namespaces/ta/methods/barssince.d.ts +6 -0
  152. package/dist/types/namespaces/ta/methods/bb.d.ts +17 -0
  153. package/dist/types/namespaces/ta/methods/bbw.d.ts +9 -0
  154. package/dist/types/namespaces/ta/methods/cci.d.ts +20 -0
  155. package/dist/types/namespaces/ta/methods/cmo.d.ts +17 -0
  156. package/dist/types/namespaces/ta/methods/cog.d.ts +18 -0
  157. package/dist/types/namespaces/ta/methods/correlation.d.ts +7 -0
  158. package/dist/types/namespaces/ta/methods/cross.d.ts +15 -0
  159. package/dist/types/namespaces/ta/methods/cum.d.ts +14 -0
  160. package/dist/types/namespaces/ta/methods/dmi.d.ts +24 -0
  161. package/dist/types/namespaces/ta/methods/falling.d.ts +15 -0
  162. package/dist/types/namespaces/ta/methods/highestbars.d.ts +7 -0
  163. package/dist/types/namespaces/ta/methods/iii.d.ts +7 -0
  164. package/dist/types/namespaces/ta/methods/kc.d.ts +12 -0
  165. package/dist/types/namespaces/ta/methods/kcw.d.ts +11 -0
  166. package/dist/types/namespaces/ta/methods/lowestbars.d.ts +7 -0
  167. package/dist/types/namespaces/ta/methods/macd.d.ts +18 -0
  168. package/dist/types/namespaces/ta/methods/mfi.d.ts +15 -0
  169. package/dist/types/namespaces/ta/methods/mode.d.ts +6 -0
  170. package/dist/types/namespaces/ta/methods/nvi.d.ts +10 -0
  171. package/dist/types/namespaces/ta/methods/obv.d.ts +12 -0
  172. package/dist/types/namespaces/ta/methods/percentile_linear_interpolation.d.ts +6 -0
  173. package/dist/types/namespaces/ta/methods/percentile_nearest_rank.d.ts +7 -0
  174. package/dist/types/namespaces/ta/methods/percentrank.d.ts +6 -0
  175. package/dist/types/namespaces/ta/methods/pvi.d.ts +10 -0
  176. package/dist/types/namespaces/ta/methods/pvt.d.ts +12 -0
  177. package/dist/types/namespaces/ta/methods/range.d.ts +7 -0
  178. package/dist/types/namespaces/ta/methods/rising.d.ts +15 -0
  179. package/dist/types/namespaces/ta/methods/sar.d.ts +12 -0
  180. package/dist/types/namespaces/ta/methods/stoch.d.ts +21 -0
  181. package/dist/types/namespaces/ta/methods/supertrend.d.ts +23 -0
  182. package/dist/types/namespaces/ta/methods/swma.d.ts +14 -0
  183. package/dist/types/namespaces/ta/methods/tr.d.ts +2 -0
  184. package/dist/types/namespaces/ta/methods/tsi.d.ts +17 -0
  185. package/dist/types/namespaces/ta/methods/valuewhen.d.ts +6 -0
  186. package/dist/types/namespaces/ta/methods/vwap.d.ts +14 -0
  187. package/dist/types/namespaces/ta/methods/wad.d.ts +11 -0
  188. package/dist/types/namespaces/ta/methods/wpr.d.ts +17 -0
  189. package/dist/types/namespaces/ta/methods/wvad.d.ts +7 -0
  190. package/dist/types/namespaces/ta/ta.index.d.ts +120 -5
  191. package/dist/types/transpiler/analysis/ScopeManager.d.ts +11 -0
  192. package/dist/types/transpiler/index.d.ts +4 -1
  193. package/dist/types/transpiler/settings.d.ts +4 -0
  194. package/dist/types/transpiler/transformers/InjectionTransformer.d.ts +6 -0
  195. package/dist/types/transpiler/transformers/MainTransformer.d.ts +4 -1
  196. package/dist/types/transpiler/transformers/NormalizationTransformer.d.ts +15 -0
  197. package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +9 -0
  198. package/dist/types/transpiler/utils/ASTFactory.d.ts +2 -0
  199. package/dist/types/types/PineTypes.d.ts +11 -0
  200. package/package.json +6 -4
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Cumulative Sum (CUM)
3
+ *
4
+ * Returns the cumulative sum of the source values from the first bar to the current bar.
5
+ * The cumulative sum is the running total of all values.
6
+ *
7
+ * Formula:
8
+ * - CUM[0] = source[0]
9
+ * - CUM[n] = CUM[n-1] + source[n]
10
+ *
11
+ * @param source - The data source to accumulate
12
+ * @returns The cumulative sum up to the current bar
13
+ */
14
+ export declare function cum(context: any): (source: any, _callId?: string) => any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Directional Movement Index (DMI)
3
+ *
4
+ * The DMI function returns the directional movement index.
5
+ *
6
+ * Formula:
7
+ * up = high - high[1]
8
+ * down = low[1] - low
9
+ * plusDM = (up > down && up > 0) ? up : 0
10
+ * minusDM = (down > up && down > 0) ? down : 0
11
+ * tr = ta.tr
12
+ * tru = rma(tr, diLength)
13
+ * plus = rma(plusDM, diLength)
14
+ * minus = rma(minusDM, diLength)
15
+ * plusDI = 100 * plus / tru
16
+ * minusDI = 100 * minus / tru
17
+ * dx = 100 * abs(plusDI - minusDI) / (plusDI + minusDI)
18
+ * adx = rma(dx, adxSmoothing)
19
+ *
20
+ * @param diLength - DI Period
21
+ * @param adxSmoothing - ADX Smoothing Period
22
+ * @returns Tuple of three DMI series: [+DI, -DI, ADX]
23
+ */
24
+ export declare function dmi(context: any): (_diLength: any, _adxSmoothing: any, _callId?: string) => any[][];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Falling Detection
3
+ *
4
+ * Tests if the source series is now falling for length bars long.
5
+ * Returns true if the series has been consecutively falling for length bars.
6
+ *
7
+ * Formula:
8
+ * For length=2: source[0] < source[1] AND source[1] < source[2]
9
+ * For length=n: source[i] < source[i+1] for all i from 0 to n-1
10
+ *
11
+ * @param source - Series of values to process
12
+ * @param length - Number of bars to check (lookback period)
13
+ * @returns true if consecutively falling for length bars, false otherwise
14
+ */
15
+ export declare function falling(context: any): (source: any, _length: any, _callId?: string) => boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Highest Bars
3
+ *
4
+ * Returns the offset to the highest value over a given length.
5
+ * Formula: Offset to the highest bar (negative value).
6
+ */
7
+ export declare function highestbars(context: any): (source: any, _length: any, _callId?: string) => number;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Intraday Intensity Index (III)
3
+ *
4
+ * Formula:
5
+ * (2 * close - high - low) / ((high - low) * volume)
6
+ */
7
+ export declare function iii(context: any): (_callId?: string) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Keltner Channels (KC)
3
+ *
4
+ * Formula:
5
+ * basis = ta.ema(src, length)
6
+ * span = useTrueRange ? ta.tr : (high - low)
7
+ * rangeEma = ta.ema(span, length)
8
+ * upper = basis + rangeEma * mult
9
+ * lower = basis - rangeEma * mult
10
+ * Returns [basis, upper, lower]
11
+ */
12
+ export declare function kc(context: any): (source: any, _length: any, _mult: any, _useTrueRange?: any, _callId?: string) => any[][];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Keltner Channels Width (KCW)
3
+ *
4
+ * Formula:
5
+ * basis = ta.ema(src, length)
6
+ * span = useTrueRange ? ta.tr : (high - low)
7
+ * rangeEma = ta.ema(span, length)
8
+ * kcw = ((basis + rangeEma * mult) - (basis - rangeEma * mult)) / basis
9
+ * = (2 * rangeEma * mult) / basis
10
+ */
11
+ export declare function kcw(context: any): (source: any, _length: any, _mult: any, _useTrueRange?: any, _callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Lowest Bars
3
+ *
4
+ * Returns the offset to the lowest value over a given length.
5
+ * Formula: Offset to the lowest bar (negative value).
6
+ */
7
+ export declare function lowestbars(context: any): (source: any, _length: any, _callId?: string) => number;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * MACD - Moving Average Convergence Divergence
3
+ *
4
+ * MACD is a trend-following momentum indicator that shows the relationship between
5
+ * two moving averages of a security's price.
6
+ *
7
+ * Formula:
8
+ * - MACD Line = EMA(source, fastLength) - EMA(source, slowLength)
9
+ * - Signal Line = EMA(MACD Line, signalLength)
10
+ * - Histogram = MACD Line - Signal Line
11
+ *
12
+ * @param source - The data source (typically close price)
13
+ * @param fastLength - The short period (default 12)
14
+ * @param slowLength - The long period (default 26)
15
+ * @param signalLength - The signal period (default 9)
16
+ * @returns [macdLine, signalLine, histLine]
17
+ */
18
+ export declare function macd(context: any): (source: any, _fastLength: any, _slowLength: any, _signalLength: any, _callId?: string) => any[][];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Money Flow Index (MFI)
3
+ *
4
+ * MFI is a momentum indicator that uses price and volume to identify overbought or oversold conditions.
5
+ *
6
+ * Pine Script Formula:
7
+ * upper = sum(volume * (change(src) <= 0 ? 0 : src), length)
8
+ * lower = sum(volume * (change(src) >= 0 ? 0 : src), length)
9
+ * mfi = 100.0 - (100.0 / (1.0 + upper / lower))
10
+ *
11
+ * @param source - Source series (typically hlc3)
12
+ * @param length - Number of bars back (lookback period)
13
+ * @returns MFI value (0-100)
14
+ */
15
+ export declare function mfi(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Mode
3
+ *
4
+ * Returns the mode of the series. If there are several values with the same frequency, returns the smallest value.
5
+ */
6
+ export declare function mode(context: any): (source: any, _length: any, _callId?: string) => number;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Negative Volume Index (NVI)
3
+ *
4
+ * Formula:
5
+ * If close or close[1] is 0, nvi = nvi[1]
6
+ * Else if volume < volume[1], nvi = nvi[1] + ((close - close[1]) / close[1]) * nvi[1]
7
+ * Else nvi = nvi[1]
8
+ * Initial value is 1.0
9
+ */
10
+ export declare function nvi(context: any): (_callId?: string) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * On-Balance Volume (OBV)
3
+ * Cumulative indicator that adds volume on up days and subtracts on down days
4
+ *
5
+ * Logic:
6
+ * - If close > close[1]: OBV = OBV[1] + volume
7
+ * - If close < close[1]: OBV = OBV[1] - volume
8
+ * - If close == close[1]: OBV = OBV[1]
9
+ *
10
+ * Note: OBV starts at 0 on the first bar (when there's no previous close to compare)
11
+ */
12
+ export declare function obv(context: any): () => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Percentile Linear Interpolation
3
+ *
4
+ * Calculates percentile using method of linear interpolation between the two nearest ranks.
5
+ */
6
+ export declare function percentile_linear_interpolation(context: any): (source: any, _length: any, _percentage: any, _callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Percentile Nearest Rank
3
+ *
4
+ * Calculates percentile using method of Nearest Rank.
5
+ * A percentile calculated using the Nearest Rank method will always be a member of the input data set.
6
+ */
7
+ export declare function percentile_nearest_rank(context: any): (source: any, _length: any, _percentage: any, _callId?: string) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Percent Rank
3
+ *
4
+ * Returns the percentage of values in the last length previous bars that are less than or equal to the current value.
5
+ */
6
+ export declare function percentrank(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Positive Volume Index (PVI)
3
+ *
4
+ * Formula:
5
+ * If close or close[1] is 0, pvi = pvi[1]
6
+ * Else if volume > volume[1], pvi = pvi[1] + ((close - close[1]) / close[1]) * pvi[1]
7
+ * Else pvi = pvi[1]
8
+ * Initial value is 1.0
9
+ */
10
+ export declare function pvi(context: any): (_callId?: string) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Price-Volume Trend (PVT)
3
+ *
4
+ * The PVT function calculates the Price-Volume Trend, which is a cumulative
5
+ * total of volume adjusted by the percentage change in price.
6
+ *
7
+ * Formula:
8
+ * PVT = Previous PVT + ((Current Close - Previous Close) / Previous Close) * Volume
9
+ *
10
+ * @returns The PVT series
11
+ */
12
+ export declare function pvt(context: any): (_callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Range
3
+ *
4
+ * Returns the difference between the highest and lowest values of a series over a given length.
5
+ * Formula: ta.highest(source, length) - ta.lowest(source, length)
6
+ */
7
+ export declare function range(context: any): (source: any, _length: any, _callId?: string) => any;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Rising Detection
3
+ *
4
+ * Tests if the source series is now rising for length bars long.
5
+ * Returns true if the series has been consecutively rising for length bars.
6
+ *
7
+ * Formula:
8
+ * For length=2: source[0] > source[1] AND source[1] > source[2]
9
+ * For length=n: source[i] > source[i+1] for all i from 0 to n-1
10
+ *
11
+ * @param source - Series of values to process
12
+ * @param length - Number of bars to check (lookback period)
13
+ * @returns true if consecutively rising for length bars, false otherwise
14
+ */
15
+ export declare function rising(context: any): (source: any, _length: any, _callId?: string) => boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parabolic SAR (Stop and Reverse)
3
+ *
4
+ * Parabolic SAR is a method devised by J. Welles Wilder, Jr., to find potential reversals
5
+ * in the market price direction.
6
+ *
7
+ * @param start - Start acceleration factor
8
+ * @param inc - Increment acceleration factor
9
+ * @param max - Maximum acceleration factor
10
+ * @returns Parabolic SAR value
11
+ */
12
+ export declare function sar(context: any): (_start: any, _inc: any, _max: any, _callId?: string) => any;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Stochastic Oscillator (STOCH)
3
+ *
4
+ * The Stochastic Oscillator is a momentum indicator that shows the location of the close
5
+ * relative to the high-low range over a set number of periods.
6
+ *
7
+ * Formula:
8
+ * STOCH = 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
9
+ *
10
+ * @param source - Source series (typically close price)
11
+ * @param high - Series of high prices
12
+ * @param low - Series of low prices
13
+ * @param length - Number of bars back (lookback period)
14
+ * @returns Stochastic value (0-100)
15
+ *
16
+ * @remarks
17
+ * - NaN values in the source series are ignored
18
+ * - Returns NaN during initialization period (when not enough data)
19
+ * - Returns NaN if highest equals lowest (to avoid division by zero)
20
+ */
21
+ export declare function stoch(context: any): (source: any, high: any, low: any, _length: any, _callId?: string) => any;
@@ -1 +1,24 @@
1
+ /**
2
+ * SuperTrend Indicator
3
+ *
4
+ * The Supertrend is a trend following indicator based on ATR.
5
+ *
6
+ * Pine Script Formula:
7
+ * src = hl2
8
+ * atr = ta.atr(atrPeriod)
9
+ * upperBand = src + factor * atr
10
+ * lowerBand = src - factor * atr
11
+ * prevLowerBand = nz(lowerBand[1])
12
+ * prevUpperBand = nz(upperBand[1])
13
+ *
14
+ * lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
15
+ * upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
16
+ *
17
+ * direction: 1 (down/bearish), -1 (up/bullish)
18
+ * superTrend := direction == -1 ? lowerBand : upperBand
19
+ *
20
+ * @param factor - The multiplier by which the ATR will get multiplied
21
+ * @param atrPeriod - Length of ATR
22
+ * @returns Tuple [supertrend, direction] where direction is 1 (down) or -1 (up)
23
+ */
1
24
  export declare function supertrend(context: any): (_factor: any, _atrPeriod: any, _callId?: string) => any[][];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SWMA - Symmetrically Weighted Moving Average
3
+ *
4
+ * Pine Script's ta.swma() uses a fixed period of 4 bars with symmetric weights.
5
+ * The weights are applied symmetrically: the current and 3 previous bars.
6
+ *
7
+ * Weights for 4-bar period: [1, 2, 2, 1]
8
+ * Formula: SWMA = (price[3]*1 + price[2]*2 + price[1]*2 + price[0]*1) / 6
9
+ *
10
+ * @param source - The data source (typically close price)
11
+ *
12
+ * Note: Unlike other moving averages, SWMA has a fixed period of 4 in Pine Script
13
+ */
14
+ export declare function swma(context: any): (source: any, _callId?: string) => any;
@@ -0,0 +1,2 @@
1
+ import { Context } from '../../../Context.class';
2
+ export declare function tr(context: Context): (handle_na?: boolean, _callId?: string) => number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * True Strength Index (TSI)
3
+ *
4
+ * True strength index uses moving averages of the underlying momentum of a financial instrument.
5
+ *
6
+ * Formula:
7
+ * pc = change(source) // Price change
8
+ * double_smoothed_pc = ema(ema(pc, long_length), short_length)
9
+ * double_smoothed_abs_pc = ema(ema(abs(pc), long_length), short_length)
10
+ * tsi = double_smoothed_pc / double_smoothed_abs_pc
11
+ *
12
+ * @param source - Source series (typically close)
13
+ * @param shortLength - Short EMA length
14
+ * @param longLength - Long EMA length
15
+ * @returns TSI value in range [-1, 1]
16
+ */
17
+ export declare function tsi(context: any): (source: any, _shortLength: any, _longLength: any, _callId?: string) => any;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Value When
3
+ *
4
+ * Returns the value of the source series on the bar where the condition was true on the nth most recent occurrence.
5
+ */
6
+ export declare function valuewhen(context: any): (condition: any, source: any, _occurrence: any, _callId?: string) => any;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * VWAP - Volume Weighted Average Price
3
+ *
4
+ * VWAP calculates the average price weighted by volume for a trading session.
5
+ * It resets at the start of each new session (typically daily).
6
+ *
7
+ * Formula: VWAP = Σ(Price × Volume) / Σ(Volume)
8
+ *
9
+ * @param source - The price source (typically close, hlc3, or ohlc4)
10
+ *
11
+ * Note: This implementation resets VWAP at the start of each trading session
12
+ * based on detecting new trading days (when openTime changes to a new day).
13
+ */
14
+ export declare function vwap(context: any): (source: any, _callId?: string) => any;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Williams Accumulation/Distribution (WAD)
3
+ *
4
+ * Formula:
5
+ * trueHigh = math.max(high, close[1])
6
+ * trueLow = math.min(low, close[1])
7
+ * mom = ta.change(close)
8
+ * gain = (mom > 0) ? close - trueLow : (mom < 0) ? close - trueHigh : 0
9
+ * ta.cum(gain)
10
+ */
11
+ export declare function wad(context: any): (_callId?: string) => any;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Williams %R (WPR)
3
+ *
4
+ * The oscillator shows the current closing price in relation to the high and low
5
+ * of the past 'length' bars.
6
+ *
7
+ * Formula:
8
+ * %R = (Highest High - Close) / (Highest High - Lowest Low) * -100
9
+ *
10
+ * Note: Williams %R produces values between -100 and 0
11
+ * - Values near -100 indicate oversold conditions
12
+ * - Values near 0 indicate overbought conditions
13
+ *
14
+ * @param length - Number of bars (lookback period)
15
+ * @returns Williams %R value (-100 to 0)
16
+ */
17
+ export declare function wpr(context: any): (_length: any, _callId?: string) => any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Williams Variable Accumulation/Distribution (WVAD)
3
+ *
4
+ * Formula:
5
+ * (close - open) / (high - low) * volume
6
+ */
7
+ export declare function wvad(context: any): (_callId?: string) => any;
@@ -1,84 +1,199 @@
1
- import { tr } from './getters/tr';
1
+ import { accdist } from './methods/accdist';
2
+ import { alma } from './methods/alma';
2
3
  import { atr } from './methods/atr';
4
+ import { barssince } from './methods/barssince';
5
+ import { bb } from './methods/bb';
6
+ import { bbw } from './methods/bbw';
7
+ import { cci } from './methods/cci';
3
8
  import { change } from './methods/change';
9
+ import { cmo } from './methods/cmo';
10
+ import { cog } from './methods/cog';
11
+ import { correlation } from './methods/correlation';
12
+ import { cross } from './methods/cross';
4
13
  import { crossover } from './methods/crossover';
5
14
  import { crossunder } from './methods/crossunder';
15
+ import { cum } from './methods/cum';
6
16
  import { dev } from './methods/dev';
17
+ import { dmi } from './methods/dmi';
7
18
  import { ema } from './methods/ema';
19
+ import { falling } from './methods/falling';
8
20
  import { highest } from './methods/highest';
21
+ import { highestbars } from './methods/highestbars';
9
22
  import { hma } from './methods/hma';
23
+ import { iii } from './methods/iii';
24
+ import { kc } from './methods/kc';
25
+ import { kcw } from './methods/kcw';
10
26
  import { linreg } from './methods/linreg';
11
27
  import { lowest } from './methods/lowest';
28
+ import { lowestbars } from './methods/lowestbars';
29
+ import { macd } from './methods/macd';
12
30
  import { median } from './methods/median';
31
+ import { mfi } from './methods/mfi';
32
+ import { mode } from './methods/mode';
13
33
  import { mom } from './methods/mom';
34
+ import { nvi } from './methods/nvi';
35
+ import { obv } from './methods/obv';
14
36
  import { param } from './methods/param';
37
+ import { percentile_linear_interpolation } from './methods/percentile_linear_interpolation';
38
+ import { percentile_nearest_rank } from './methods/percentile_nearest_rank';
39
+ import { percentrank } from './methods/percentrank';
15
40
  import { pivothigh } from './methods/pivothigh';
16
41
  import { pivotlow } from './methods/pivotlow';
42
+ import { pvi } from './methods/pvi';
43
+ import { pvt } from './methods/pvt';
44
+ import { range } from './methods/range';
45
+ import { rising } from './methods/rising';
17
46
  import { rma } from './methods/rma';
18
47
  import { roc } from './methods/roc';
19
48
  import { rsi } from './methods/rsi';
49
+ import { sar } from './methods/sar';
20
50
  import { sma } from './methods/sma';
21
51
  import { stdev } from './methods/stdev';
52
+ import { stoch } from './methods/stoch';
22
53
  import { supertrend } from './methods/supertrend';
54
+ import { swma } from './methods/swma';
55
+ import { tr } from './methods/tr';
56
+ import { tsi } from './methods/tsi';
57
+ import { valuewhen } from './methods/valuewhen';
23
58
  import { variance } from './methods/variance';
59
+ import { vwap } from './methods/vwap';
24
60
  import { vwma } from './methods/vwma';
61
+ import { wad } from './methods/wad';
25
62
  import { wma } from './methods/wma';
26
- declare const getters: {
27
- tr: typeof tr;
28
- };
63
+ import { wpr } from './methods/wpr';
64
+ import { wvad } from './methods/wvad';
29
65
  declare const methods: {
66
+ accdist: typeof accdist;
67
+ alma: typeof alma;
30
68
  atr: typeof atr;
69
+ barssince: typeof barssince;
70
+ bb: typeof bb;
71
+ bbw: typeof bbw;
72
+ cci: typeof cci;
31
73
  change: typeof change;
74
+ cmo: typeof cmo;
75
+ cog: typeof cog;
76
+ correlation: typeof correlation;
77
+ cross: typeof cross;
32
78
  crossover: typeof crossover;
33
79
  crossunder: typeof crossunder;
80
+ cum: typeof cum;
34
81
  dev: typeof dev;
82
+ dmi: typeof dmi;
35
83
  ema: typeof ema;
84
+ falling: typeof falling;
36
85
  highest: typeof highest;
86
+ highestbars: typeof highestbars;
37
87
  hma: typeof hma;
88
+ iii: typeof iii;
89
+ kc: typeof kc;
90
+ kcw: typeof kcw;
38
91
  linreg: typeof linreg;
39
92
  lowest: typeof lowest;
93
+ lowestbars: typeof lowestbars;
94
+ macd: typeof macd;
40
95
  median: typeof median;
96
+ mfi: typeof mfi;
97
+ mode: typeof mode;
41
98
  mom: typeof mom;
99
+ nvi: typeof nvi;
100
+ obv: typeof obv;
42
101
  param: typeof param;
102
+ percentile_linear_interpolation: typeof percentile_linear_interpolation;
103
+ percentile_nearest_rank: typeof percentile_nearest_rank;
104
+ percentrank: typeof percentrank;
43
105
  pivothigh: typeof pivothigh;
44
106
  pivotlow: typeof pivotlow;
107
+ pvi: typeof pvi;
108
+ pvt: typeof pvt;
109
+ range: typeof range;
110
+ rising: typeof rising;
45
111
  rma: typeof rma;
46
112
  roc: typeof roc;
47
113
  rsi: typeof rsi;
114
+ sar: typeof sar;
48
115
  sma: typeof sma;
49
116
  stdev: typeof stdev;
117
+ stoch: typeof stoch;
50
118
  supertrend: typeof supertrend;
119
+ swma: typeof swma;
120
+ tr: typeof tr;
121
+ tsi: typeof tsi;
122
+ valuewhen: typeof valuewhen;
51
123
  variance: typeof variance;
124
+ vwap: typeof vwap;
52
125
  vwma: typeof vwma;
126
+ wad: typeof wad;
53
127
  wma: typeof wma;
128
+ wpr: typeof wpr;
129
+ wvad: typeof wvad;
54
130
  };
55
131
  export declare class TechnicalAnalysis {
56
132
  private context;
57
- readonly tr: ReturnType<ReturnType<typeof getters.tr>>;
133
+ accdist: ReturnType<typeof methods.accdist>;
134
+ alma: ReturnType<typeof methods.alma>;
58
135
  atr: ReturnType<typeof methods.atr>;
136
+ barssince: ReturnType<typeof methods.barssince>;
137
+ bb: ReturnType<typeof methods.bb>;
138
+ bbw: ReturnType<typeof methods.bbw>;
139
+ cci: ReturnType<typeof methods.cci>;
59
140
  change: ReturnType<typeof methods.change>;
141
+ cmo: ReturnType<typeof methods.cmo>;
142
+ cog: ReturnType<typeof methods.cog>;
143
+ correlation: ReturnType<typeof methods.correlation>;
144
+ cross: ReturnType<typeof methods.cross>;
60
145
  crossover: ReturnType<typeof methods.crossover>;
61
146
  crossunder: ReturnType<typeof methods.crossunder>;
147
+ cum: ReturnType<typeof methods.cum>;
62
148
  dev: ReturnType<typeof methods.dev>;
149
+ dmi: ReturnType<typeof methods.dmi>;
63
150
  ema: ReturnType<typeof methods.ema>;
151
+ falling: ReturnType<typeof methods.falling>;
64
152
  highest: ReturnType<typeof methods.highest>;
153
+ highestbars: ReturnType<typeof methods.highestbars>;
65
154
  hma: ReturnType<typeof methods.hma>;
155
+ iii: ReturnType<typeof methods.iii>;
156
+ kc: ReturnType<typeof methods.kc>;
157
+ kcw: ReturnType<typeof methods.kcw>;
66
158
  linreg: ReturnType<typeof methods.linreg>;
67
159
  lowest: ReturnType<typeof methods.lowest>;
160
+ lowestbars: ReturnType<typeof methods.lowestbars>;
161
+ macd: ReturnType<typeof methods.macd>;
68
162
  median: ReturnType<typeof methods.median>;
163
+ mfi: ReturnType<typeof methods.mfi>;
164
+ mode: ReturnType<typeof methods.mode>;
69
165
  mom: ReturnType<typeof methods.mom>;
166
+ nvi: ReturnType<typeof methods.nvi>;
167
+ obv: ReturnType<typeof methods.obv>;
70
168
  param: ReturnType<typeof methods.param>;
169
+ percentile_linear_interpolation: ReturnType<typeof methods.percentile_linear_interpolation>;
170
+ percentile_nearest_rank: ReturnType<typeof methods.percentile_nearest_rank>;
171
+ percentrank: ReturnType<typeof methods.percentrank>;
71
172
  pivothigh: ReturnType<typeof methods.pivothigh>;
72
173
  pivotlow: ReturnType<typeof methods.pivotlow>;
174
+ pvi: ReturnType<typeof methods.pvi>;
175
+ pvt: ReturnType<typeof methods.pvt>;
176
+ range: ReturnType<typeof methods.range>;
177
+ rising: ReturnType<typeof methods.rising>;
73
178
  rma: ReturnType<typeof methods.rma>;
74
179
  roc: ReturnType<typeof methods.roc>;
75
180
  rsi: ReturnType<typeof methods.rsi>;
181
+ sar: ReturnType<typeof methods.sar>;
76
182
  sma: ReturnType<typeof methods.sma>;
77
183
  stdev: ReturnType<typeof methods.stdev>;
184
+ stoch: ReturnType<typeof methods.stoch>;
78
185
  supertrend: ReturnType<typeof methods.supertrend>;
186
+ swma: ReturnType<typeof methods.swma>;
187
+ tr: ReturnType<typeof methods.tr>;
188
+ tsi: ReturnType<typeof methods.tsi>;
189
+ valuewhen: ReturnType<typeof methods.valuewhen>;
79
190
  variance: ReturnType<typeof methods.variance>;
191
+ vwap: ReturnType<typeof methods.vwap>;
80
192
  vwma: ReturnType<typeof methods.vwma>;
193
+ wad: ReturnType<typeof methods.wad>;
81
194
  wma: ReturnType<typeof methods.wma>;
195
+ wpr: ReturnType<typeof methods.wpr>;
196
+ wvad: ReturnType<typeof methods.wvad>;
82
197
  constructor(context: any);
83
198
  }
84
199
  export default TechnicalAnalysis;
@@ -5,6 +5,7 @@ export declare class ScopeManager {
5
5
  private contextBoundVars;
6
6
  private arrayPatternElements;
7
7
  private rootParams;
8
+ private localSeriesVars;
8
9
  private varKinds;
9
10
  private loopVars;
10
11
  private loopVarNames;
@@ -12,6 +13,8 @@ export declare class ScopeManager {
12
13
  private cacheIdCounter;
13
14
  private tempVarCounter;
14
15
  private taCallIdCounter;
16
+ private hoistingStack;
17
+ private suppressHoisting;
15
18
  get nextParamIdArg(): any;
16
19
  get nextCacheIdArg(): any;
17
20
  getNextTACallId(): any;
@@ -20,6 +23,8 @@ export declare class ScopeManager {
20
23
  popScope(): void;
21
24
  getCurrentScopeType(): string;
22
25
  getCurrentScopeCount(): number;
26
+ addLocalSeriesVar(name: string): void;
27
+ isLocalSeriesVar(name: string): boolean;
23
28
  addContextBoundVar(name: string, isRootParam?: boolean): void;
24
29
  removeContextBoundVar(name: any): void;
25
30
  addArrayPatternElement(name: string): void;
@@ -32,5 +37,11 @@ export declare class ScopeManager {
32
37
  addVariable(name: string, kind: string): string;
33
38
  getVariable(name: string): [string, string];
34
39
  generateTempVar(): string;
40
+ enterHoistingScope(): void;
41
+ exitHoistingScope(): any[];
42
+ addHoistedStatement(stmt: any): void;
43
+ setSuppressHoisting(suppress: boolean): void;
44
+ shouldSuppressHoisting(): boolean;
45
+ generateParamId(): string;
35
46
  }
36
47
  export default ScopeManager;