pinets 0.3.0 → 0.5.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/README.md +3 -0
- package/dist/pinets.dev.browser.js +3739 -1372
- package/dist/pinets.dev.cjs +3734 -1368
- package/dist/pinets.dev.cjs.map +1 -1
- package/dist/pinets.dev.es.js +3688 -1326
- package/dist/pinets.dev.es.js.map +1 -1
- package/dist/pinets.min.browser.js +15 -11
- package/dist/pinets.min.cjs +15 -11
- package/dist/pinets.min.es.js +5 -1
- package/dist/types/Context.class.d.ts +61 -15
- package/dist/types/PineTS.class.d.ts +11 -1
- package/dist/types/namespaces/Core.d.ts +1 -0
- package/dist/types/namespaces/array/methods/from.d.ts +1 -1
- package/dist/types/namespaces/request/methods/security.d.ts +1 -1
- package/dist/types/namespaces/request/types/barmerge.type.d.ts +7 -0
- package/dist/types/namespaces/request/utils/findLTFContextIdx.d.ts +1 -0
- package/dist/types/namespaces/ta/getters/obv.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/accdist.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/alma.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/barssince.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/bb.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/bbw.d.ts +9 -0
- package/dist/types/namespaces/ta/methods/cci.d.ts +20 -0
- package/dist/types/namespaces/ta/methods/cmo.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/cog.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/correlation.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/cross.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/cum.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/dmi.d.ts +24 -0
- package/dist/types/namespaces/ta/methods/falling.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/highestbars.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/iii.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/kc.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/kcw.d.ts +11 -0
- package/dist/types/namespaces/ta/methods/lowestbars.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/macd.d.ts +18 -0
- package/dist/types/namespaces/ta/methods/mfi.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/mode.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/nvi.d.ts +10 -0
- package/dist/types/namespaces/ta/methods/obv.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/percentile_linear_interpolation.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/percentile_nearest_rank.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/percentrank.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/pvi.d.ts +10 -0
- package/dist/types/namespaces/ta/methods/pvt.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/range.d.ts +7 -0
- package/dist/types/namespaces/ta/methods/rising.d.ts +15 -0
- package/dist/types/namespaces/ta/methods/sar.d.ts +12 -0
- package/dist/types/namespaces/ta/methods/stoch.d.ts +21 -0
- package/dist/types/namespaces/ta/methods/supertrend.d.ts +23 -0
- package/dist/types/namespaces/ta/methods/swma.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/tr.d.ts +1 -0
- package/dist/types/namespaces/ta/methods/tsi.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/valuewhen.d.ts +6 -0
- package/dist/types/namespaces/ta/methods/vwap.d.ts +14 -0
- package/dist/types/namespaces/ta/methods/wad.d.ts +11 -0
- package/dist/types/namespaces/ta/methods/wpr.d.ts +17 -0
- package/dist/types/namespaces/ta/methods/wvad.d.ts +7 -0
- package/dist/types/namespaces/ta/ta.index.d.ts +120 -5
- package/dist/types/transpiler/analysis/ScopeManager.d.ts +11 -0
- package/dist/types/transpiler/index.d.ts +4 -1
- package/dist/types/transpiler/transformers/InjectionTransformer.d.ts +6 -0
- package/dist/types/transpiler/transformers/MainTransformer.d.ts +4 -1
- package/dist/types/transpiler/transformers/NormalizationTransformer.d.ts +15 -0
- package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +9 -0
- package/dist/types/transpiler/utils/ASTFactory.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ALMA - Arnaud Legoux Moving Average
|
|
3
|
+
*
|
|
4
|
+
* ALMA uses a Gaussian distribution to weight the moving average,
|
|
5
|
+
* reducing lag while maintaining smoothness.
|
|
6
|
+
*
|
|
7
|
+
* @param source - The data source (typically close price)
|
|
8
|
+
* @param period - The number of periods (window size)
|
|
9
|
+
* @param offset - Position of Gaussian peak (0-1, default 0.85). Higher = more responsive
|
|
10
|
+
* @param sigma - Width of Gaussian curve (default 6). Higher = smoother
|
|
11
|
+
*
|
|
12
|
+
* Formula:
|
|
13
|
+
* - m = offset * (period - 1)
|
|
14
|
+
* - s = period / sigma
|
|
15
|
+
* - weight[i] = exp(-((i - m)^2) / (2 * s^2))
|
|
16
|
+
* - ALMA = sum(weight[i] * price[i]) / sum(weight[i])
|
|
17
|
+
*/
|
|
18
|
+
export declare function alma(context: any): (source: any, _period: any, _offset: any, _sigma: any, _callId?: string) => any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bollinger Bands (BB)
|
|
3
|
+
*
|
|
4
|
+
* Bollinger Bands are volatility bands placed above and below a moving average.
|
|
5
|
+
* Volatility is based on the standard deviation, which changes as volatility increases and decreases.
|
|
6
|
+
*
|
|
7
|
+
* Formula:
|
|
8
|
+
* - Middle Band = SMA(source, length)
|
|
9
|
+
* - Upper Band = Middle Band + (multiplier × Standard Deviation)
|
|
10
|
+
* - Lower Band = Middle Band - (multiplier × Standard Deviation)
|
|
11
|
+
*
|
|
12
|
+
* @param source - The data source (typically close price)
|
|
13
|
+
* @param length - The period for SMA and standard deviation (default 20)
|
|
14
|
+
* @param mult - The multiplier for standard deviation (default 2)
|
|
15
|
+
* @returns [upper, middle, lower]
|
|
16
|
+
*/
|
|
17
|
+
export declare function bb(context: any): (source: any, _length: any, _mult: any, _callId?: string) => any[][];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bollinger Bands Width (BBW)
|
|
3
|
+
*
|
|
4
|
+
* Formula:
|
|
5
|
+
* basis = ta.sma(source, length)
|
|
6
|
+
* dev = mult * ta.stdev(source, length)
|
|
7
|
+
* bbw = (((basis + dev) - (basis - dev)) / basis) * 100
|
|
8
|
+
*/
|
|
9
|
+
export declare function bbw(context: any): (source: any, _length: any, _mult: any, _callId?: string) => any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commodity Channel Index (CCI)
|
|
3
|
+
*
|
|
4
|
+
* CCI measures the deviation of the price from its average price.
|
|
5
|
+
* It's used to identify cyclical trends and overbought/oversold conditions.
|
|
6
|
+
*
|
|
7
|
+
* Formula:
|
|
8
|
+
* - Typical Price (TP) = (high + low + close) / 3
|
|
9
|
+
* - CCI = (TP - SMA(TP, length)) / (0.015 × Mean Deviation)
|
|
10
|
+
* - Mean Deviation = Average of |TP - SMA(TP)| over length periods
|
|
11
|
+
*
|
|
12
|
+
* @param source - Source series (typically close price, but can be any price)
|
|
13
|
+
* @param length - Number of bars back (lookback period)
|
|
14
|
+
* @returns CCI value
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - Returns NaN during initialization period (when not enough data)
|
|
18
|
+
* - The constant 0.015 ensures approximately 70-80% of values fall between -100 and +100
|
|
19
|
+
*/
|
|
20
|
+
export declare function cci(context: any): (source: any, _length: any, _callId?: string) => any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chande Momentum Oscillator (CMO)
|
|
3
|
+
*
|
|
4
|
+
* Calculates the difference between the sum of recent gains and the sum of recent losses
|
|
5
|
+
* and then divides the result by the sum of all price movement over the same period.
|
|
6
|
+
*
|
|
7
|
+
* Pine Script Formula:
|
|
8
|
+
* mom = change(src)
|
|
9
|
+
* sm1 = sum((mom >= 0) ? mom : 0.0, length)
|
|
10
|
+
* sm2 = sum((mom >= 0) ? 0.0 : -mom, length)
|
|
11
|
+
* cmo = 100 * (sm1 - sm2) / (sm1 + sm2)
|
|
12
|
+
*
|
|
13
|
+
* @param source - Source series (typically close)
|
|
14
|
+
* @param length - Number of bars (lookback period)
|
|
15
|
+
* @returns CMO value (-100 to +100)
|
|
16
|
+
*/
|
|
17
|
+
export declare function cmo(context: any): (source: any, _length: any, _callId?: string) => any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Center of Gravity (COG)
|
|
3
|
+
*
|
|
4
|
+
* The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
|
|
5
|
+
*
|
|
6
|
+
* Pine Script Formula:
|
|
7
|
+
* sum = sum(source, length)
|
|
8
|
+
* num = 0.0
|
|
9
|
+
* for i = 0 to length - 1
|
|
10
|
+
* price = source[i]
|
|
11
|
+
* num = num + price * (i + 1)
|
|
12
|
+
* cog = -num / sum
|
|
13
|
+
*
|
|
14
|
+
* @param source - Source series (typically close)
|
|
15
|
+
* @param length - Number of bars (lookback period)
|
|
16
|
+
* @returns Center of Gravity value
|
|
17
|
+
*/
|
|
18
|
+
export declare function cog(context: any): (source: any, _length: any, _callId?: string) => any;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Correlation Coefficient
|
|
3
|
+
*
|
|
4
|
+
* Describes the degree to which two series tend to deviate from their ta.sma() values.
|
|
5
|
+
* r = cov(X, Y) / (stdev(X) * stdev(Y))
|
|
6
|
+
*/
|
|
7
|
+
export declare function correlation(context: any): (source1: any, source2: any, _length: any, _callId?: string) => any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects when two series cross each other (either direction).
|
|
5
|
+
* Returns true if series1 crosses series2 (either above or below).
|
|
6
|
+
*
|
|
7
|
+
* Formula:
|
|
8
|
+
* cross = (source1[0] > source2[0] && source1[1] <= source2[1]) ||
|
|
9
|
+
* (source1[0] < source2[0] && source1[1] >= source2[1])
|
|
10
|
+
*
|
|
11
|
+
* @param source1 - First data series
|
|
12
|
+
* @param source2 - Second data series
|
|
13
|
+
* @returns true if the series have crossed, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function cross(context: any): (source1: any, source2: any, _callId?: string) => boolean;
|
|
@@ -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,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,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,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,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 @@
|
|
|
1
|
+
export declare function tr(context: any): (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;
|