Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [0.7.4] - 2025-12-27 - Plot styles fix + PineScript transpiler coverage

### Added

- Unit-tests for PineToJS transpiler branch bringing the total coverage back to > 80%

### Fixed

- plot styles were missing in the generated code (e.g plot.style_columns ...etc )

## [0.7.3] - 2025-12-24 - Plot Functions & PineScript Types Enhancement

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinets",
"version": "0.7.3",
"version": "0.7.4",
"description": "",
"main": "dist/pinets.min.cjs",
"module": "dist/pinets.min.es.js",
Expand Down
25 changes: 24 additions & 1 deletion src/Context.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,30 @@ export class Context {

const plotHelper = new PlotHelper(this);
const hlineHelper = new HlineHelper(this);
this.bindContextObject(plotHelper, ['plot', 'plotchar', 'plotshape', 'plotarrow']);
this.bindContextObject(plotHelper, ['plotchar', 'plotshape', 'plotarrow']);
this.bindContextObject(
plotHelper,
[
'any',
'param',
'linestyle_dashed',
'linestyle_dotted',
'linestyle_solid',
'style_area',
'style_areabr',
'style_circles',
'style_columns',
'style_cross',
'style_histogram',
'style_line',
'style_linebr',
'style_stepline',
'style_stepline_diamond',
'style_steplinebr',
],
'plot'
);

this.bindContextObject(hlineHelper, ['any', 'style_dashed', 'style_solid', 'style_dotted', 'param'], 'hline');
}

Expand Down
56 changes: 53 additions & 3 deletions src/namespaces/Plots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,53 @@ export class PlotHelper {
return _options;
}

public get linestyle_dashed() {
return 'linestyle_dashed';
}
public get linestyle_dotted() {
return 'linestyle_dotted';
}
public get linestyle_solid() {
return 'linestyle_solid';
}
public get style_area() {
return 'style_area';
}
public get style_areabr() {
return 'style_areabr';
}
public get style_circles() {
return 'style_circles';
}
public get style_columns() {
return 'style_columns';
}
public get style_cross() {
return 'style_cross';
}
public get style_histogram() {
return 'style_histogram';
}
public get style_line() {
return 'style_line';
}
public get style_linebr() {
return 'style_linebr';
}
public get style_stepline() {
return 'style_stepline';
}
public get style_stepline_diamond() {
return 'style_stepline_diamond';
}
public get style_steplinebr() {
return 'style_steplinebr';
}

param(source: any, index: number = 0, name?: string) {
return Series.from(source).get(index);
}

//in the current implementation, plot functions are only used to collect data for the plots array and map it to the market data
plotchar(...args) {
// if (!this.context.plots[title]) {
Expand All @@ -64,10 +111,12 @@ export class PlotHelper {
// value: value,
// options: { ...this.extractPlotOptions(options), style: 'char' },
// });
this.plot(...args);
this.any(...args);
}

plot(...args) {
//this will map to plot() - see README.md for more details

any(...args) {
const _parsed = parseArgsForPineParams<PlotOptions>(args, PLOT_SIGNATURE, PLOT_ARGS_TYPES);
const { series, title, ...others } = _parsed;
const options = this.extractPlotOptions(others);
Expand Down Expand Up @@ -156,6 +205,7 @@ export class HlineHelper {

//this will map to hline()
any(price, title, color, linestyle, linewidth, editable, display) {
return this.context.pine.plot(price, { title, color, linestyle, linewidth, editable, display });
//plot.any is mapped to plot() at runtime
return this.context.pine.plot.any(price, { title, color, linestyle, linewidth, editable, display });
}
}
1 change: 0 additions & 1 deletion src/namespaces/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ const types = {
location,
size,
format,
plot,
};

export default types;
2 changes: 1 addition & 1 deletion src/namespaces/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Series } from '../Series';

const TYPE_CHECK = {
series: (arg) => arg instanceof Series || typeof arg === 'number',
series: (arg) => arg instanceof Series || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'boolean',
string: (arg) => typeof arg === 'string',
number: (arg) => typeof arg === 'number',
boolean: (arg) => typeof arg === 'boolean',
Expand Down
2 changes: 1 addition & 1 deletion src/transpiler/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export const KNOWN_NAMESPACES = ['ta', 'math', 'request', 'array', 'input'];

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

// Async methods that require await keyword (format: 'namespace.method')
export const ASYNC_METHODS = ['request.security', 'request.security_lower_tf'];
Expand Down
2 changes: 1 addition & 1 deletion tests/indicators/pine_supertrend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Indicators', () => {
const ta = context.ta;

const { close, hl2 } = context.data;
const { na, nz, plot } = context.core;
const { na, nz, plot } = context.pine;

function pine_supertrend(factor, atrPeriod) {
const src = hl2;
Expand Down
Loading