Skip to content

Commit fdf97f9

Browse files
authored
Merge pull request #52 from QuantForgeOrg/dev
v0.7.4 Plot styles fix + PineScript transpiler coverage
2 parents 85f8bd0 + 2fe292c commit fdf97f9

File tree

11 files changed

+867
-34
lines changed

11 files changed

+867
-34
lines changed

.github/badges/coverage.svg

Lines changed: 9 additions & 9 deletions
Loading

CHANGELOG.md

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

3+
## [0.7.4] - 2025-12-27 - Plot styles fix + PineScript transpiler coverage
4+
5+
### Added
6+
7+
- Unit-tests for PineToJS transpiler branch bringing the total coverage back to > 80%
8+
9+
### Fixed
10+
11+
- plot styles were missing in the generated code (e.g plot.style_columns ...etc )
12+
313
## [0.7.3] - 2025-12-24 - Plot Functions & PineScript Types Enhancement
414

515
### Added

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.7.3",
3+
"version": "0.7.4",
44
"description": "",
55
"main": "dist/pinets.min.cjs",
66
"module": "dist/pinets.min.es.js",

src/Context.class.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,30 @@ export class Context {
166166

167167
const plotHelper = new PlotHelper(this);
168168
const hlineHelper = new HlineHelper(this);
169-
this.bindContextObject(plotHelper, ['plot', 'plotchar', 'plotshape', 'plotarrow']);
169+
this.bindContextObject(plotHelper, ['plotchar', 'plotshape', 'plotarrow']);
170+
this.bindContextObject(
171+
plotHelper,
172+
[
173+
'any',
174+
'param',
175+
'linestyle_dashed',
176+
'linestyle_dotted',
177+
'linestyle_solid',
178+
'style_area',
179+
'style_areabr',
180+
'style_circles',
181+
'style_columns',
182+
'style_cross',
183+
'style_histogram',
184+
'style_line',
185+
'style_linebr',
186+
'style_stepline',
187+
'style_stepline_diamond',
188+
'style_steplinebr',
189+
],
190+
'plot'
191+
);
192+
170193
this.bindContextObject(hlineHelper, ['any', 'style_dashed', 'style_solid', 'style_dotted', 'param'], 'hline');
171194
}
172195

src/namespaces/Plots.ts

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,53 @@ export class PlotHelper {
5353
return _options;
5454
}
5555

56+
public get linestyle_dashed() {
57+
return 'linestyle_dashed';
58+
}
59+
public get linestyle_dotted() {
60+
return 'linestyle_dotted';
61+
}
62+
public get linestyle_solid() {
63+
return 'linestyle_solid';
64+
}
65+
public get style_area() {
66+
return 'style_area';
67+
}
68+
public get style_areabr() {
69+
return 'style_areabr';
70+
}
71+
public get style_circles() {
72+
return 'style_circles';
73+
}
74+
public get style_columns() {
75+
return 'style_columns';
76+
}
77+
public get style_cross() {
78+
return 'style_cross';
79+
}
80+
public get style_histogram() {
81+
return 'style_histogram';
82+
}
83+
public get style_line() {
84+
return 'style_line';
85+
}
86+
public get style_linebr() {
87+
return 'style_linebr';
88+
}
89+
public get style_stepline() {
90+
return 'style_stepline';
91+
}
92+
public get style_stepline_diamond() {
93+
return 'style_stepline_diamond';
94+
}
95+
public get style_steplinebr() {
96+
return 'style_steplinebr';
97+
}
98+
99+
param(source: any, index: number = 0, name?: string) {
100+
return Series.from(source).get(index);
101+
}
102+
56103
//in the current implementation, plot functions are only used to collect data for the plots array and map it to the market data
57104
plotchar(...args) {
58105
// if (!this.context.plots[title]) {
@@ -64,10 +111,12 @@ export class PlotHelper {
64111
// value: value,
65112
// options: { ...this.extractPlotOptions(options), style: 'char' },
66113
// });
67-
this.plot(...args);
114+
this.any(...args);
68115
}
69116

70-
plot(...args) {
117+
//this will map to plot() - see README.md for more details
118+
119+
any(...args) {
71120
const _parsed = parseArgsForPineParams<PlotOptions>(args, PLOT_SIGNATURE, PLOT_ARGS_TYPES);
72121
const { series, title, ...others } = _parsed;
73122
const options = this.extractPlotOptions(others);
@@ -156,6 +205,7 @@ export class HlineHelper {
156205

157206
//this will map to hline()
158207
any(price, title, color, linestyle, linewidth, editable, display) {
159-
return this.context.pine.plot(price, { title, color, linestyle, linewidth, editable, display });
208+
//plot.any is mapped to plot() at runtime
209+
return this.context.pine.plot.any(price, { title, color, linestyle, linewidth, editable, display });
160210
}
161211
}

src/namespaces/Types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ const types = {
146146
location,
147147
size,
148148
format,
149-
plot,
150149
};
151150

152151
export default types;

src/namespaces/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Series } from '../Series';
22

33
const TYPE_CHECK = {
4-
series: (arg) => arg instanceof Series || typeof arg === 'number',
4+
series: (arg) => arg instanceof Series || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'boolean',
55
string: (arg) => typeof arg === 'string',
66
number: (arg) => typeof arg === 'number',
77
boolean: (arg) => typeof arg === 'boolean',

src/transpiler/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export const KNOWN_NAMESPACES = ['ta', 'math', 'request', 'array', 'input'];
33

44
// This is used to transform ns() calls to ns.any() calls
5-
export const NAMESPACES_LIKE = ['hline'];
5+
export const NAMESPACES_LIKE = ['hline', 'plot'];
66

77
// Async methods that require await keyword (format: 'namespace.method')
88
export const ASYNC_METHODS = ['request.security', 'request.security_lower_tf'];

tests/indicators/pine_supertrend.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('Indicators', () => {
1111
const ta = context.ta;
1212

1313
const { close, hl2 } = context.data;
14-
const { na, nz, plot } = context.core;
14+
const { na, nz, plot } = context.pine;
1515

1616
function pine_supertrend(factor, atrPeriod) {
1717
const src = hl2;

0 commit comments

Comments
 (0)