FDL
FDL

Reputation: 115

Shift pinescript series by one

Suppose I have a pinescript series current that looks like this;

current = [1 0 0 1 0 0 1 0 0 1]

I want to shift this series backward by 1. The shifted variable will look like this;

shifted = [1 0 0 1 0 0 1 0 0 1 0]

The last sample of shifted will always be 0.

I am using pinescript v5

Upvotes: 3

Views: 403

Answers (1)

AnyDozer
AnyDozer

Reputation: 2568

It depends on what you want to do with it next. If you just output a plot like this

plot(barstate.islast ? 0 : current, offset = -1)

Upvotes: 3

Related Questions