Skip to content

initVar issue? #154

@dcaoyuan

Description

@dcaoyuan

Test case:

//@version=6
indicator("initVar issue", overlay=true)

var ph_time = time[15]
log.info("{0}", ph_time)

ph_time will be NaN instead of time of bar at previous 15.

It seems some logic wrong at:

PineTS/src/Context.class.ts

Lines 543 to 549 in ad26f8d

initVar(trg, src: any): Series {
// If target exists (subsequent bars), return it as is.
// PineTS automatically shifts context variables by copying the last value,
// so the previous value is already carried over to the current slot.
if (trg) {
return trg;
}

Where, value will be assigned the first time only, won't be assigned again afterward since trg already inited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions