Skip to content

Commit 8db7baa

Browse files
committed
Fix for math.avg function
update Readme file
1 parent 20343ac commit 8db7baa

File tree

9 files changed

+10636
-8
lines changed

9 files changed

+10636
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [0.1.31] - 2025-02-12 -
4+
5+
### Added
6+
7+
- Fix for math.avg function
8+
39
## [0.1.3] - 2025-02-10 -
410

511
### Added

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ PineTS is an independent project and is not affiliated with, endorsed by, or ass
1111

1212
PineTS enables seamless conversion of Pine Script indicators to JavaScript/TypeScript code. It preserves the original functionality and behavior while providing robust handling of time-series data processing, technical analysis calculations, and Pine Script's distinctive scoping mechanisms.
1313

14+
## See it in action
15+
16+
Bellow are two ports of Pine Script indicators running in the browser.
17+
PineTS is used to generate plot data, and tradingview light weight chart is used to display the plot.
18+
19+
- [Williams Vix Fix](https://alaa-eddine.github.io/PineTS/indicators/willvixfix/)
20+
- [Squeeze Momentum](https://alaa-eddine.github.io/PineTS/indicators/sqzmom/)
21+
1422
## Key Features
1523

1624
- **Pine Script Compatibility**: Supports Pine Script v5+ syntax and functionality

docs/indicators/sqzmom/chart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
async function loadChartData() {
22
try {
33
const data = await PineTS.Provider.Binance.getMarketData('BTCUSDT', 'W', 500);
4+
console.log('data', data);
45
return data;
56
} catch (error) {
67
console.error('Error loading chart data:', error);
@@ -11,7 +12,7 @@ async function loadChartData() {
1112
async function loadIndicatorData() {
1213
try {
1314
const data = await SQZMOM('BTCUSDT', 'W', 500);
14-
console.log(data);
15+
console.log('indicator data', data);
1516
return data;
1617
} catch (error) {
1718
console.error('Error loading indicator data:', error);

docs/indicators/sqzmom/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ <h2>Usage</h2>
335335
console.log(plots);
336336
</code></pre>
337337

338-
<script src="../../js/pinets.min.browser.js"></script>
338+
<script src="../../js/pinets.dev.browser.js"></script>
339339
<script src="./SQZMOM.js"></script>
340340
<script src="./chart.js"></script>
341341
</div>

docs/indicators/willvixfix/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ <h2>Usage</h2>
319319
console.log(plots);
320320
</code></pre>
321321

322-
<script src="../../js/pinets.min.browser.js"></script>
322+
<script src="../../js/pinets.dev.browser.js"></script>
323323
<script src="./WillVixFix.js"></script>
324324
<script src="./chart.js"></script>
325325
</div>

docs/js/pinets.dev.browser.js

Lines changed: 10612 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pinets",
3-
"version": "0.1.3",
3+
"version": "0.1.31",
44
"description": "",
55
"main": "dist/pinets.dev.es.js",
66
"types": "dist/types/index.d.ts",

src/marketData/Binance/BinanceProvider.class.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const timeframe_to_binance = {
1212
'120': '2h', // 2 hours
1313
'180': null, // 3 hours (not directly supported by Binance, needs custom handling)
1414
'240': '4h', // 4 hours
15+
'4H': '4h', // 4 hours
1516
'1D': '1d', // 1 day
1617
D: '1d', // 1 day
1718
'1W': '1w', // 1 week

src/namespaces/PineMath.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export class PineMath {
5151
return Math.random();
5252
}
5353
max(...source: number[]) {
54-
const arg = source.map((e) => e[0]);
54+
const arg = source.map((e) => (Array.isArray(e) ? e[0] : e));
5555
return Math.max(...arg);
5656
}
5757
min(...source: number[]) {
58-
const arg = source.map((e) => e[0]);
58+
const arg = source.map((e) => (Array.isArray(e) ? e[0] : e));
5959
return Math.min(...arg);
6060
}
6161

@@ -88,8 +88,8 @@ export class PineMath {
8888
return Math.atan(source[0]);
8989
}
9090

91-
avg(source: number[]) {
92-
const args = source.map((e) => e[0]);
91+
avg(...sources: number[][]) {
92+
const args = sources.map((e) => (Array.isArray(e) ? e[0] : e));
9393

9494
return (
9595
args.reduce((a, b) => {

0 commit comments

Comments
 (0)