Cumulative Line in Pine Script

421 Views Asked by At

I am new to Pine Script. I am trying to make a cumulative line starting at 10000 using the value obtained by subtracting to the value of the Open of a Daily candle the value of the previous Daily Close.

study("Cumulative Line", overlay=false)

apertura = open[0]
cierre = close[1]

suma = 10000.0
suma := suma + (open[0] - close[1]) + 10000.0

plot(suma)

I have tried making a SMA with a length of 1. Nevertheless, this is the error I got:

Script could not be translated from: |B|suma := suma + (open

I have tried without making the cumulative line and just ploting a SMA with the values of the difference between the daily candle's open minus the previous daily candle's close and it works. Basically, I do not know how to make a cumulative line of those values, can anybody help me? Thank you anyway for your time

1

There are 1 best solutions below

0
On

:= operator doesn't work in pinescript version 1 (default if not explicitly mentioned in the script)

Add //@version=4 at the beginning of the script:

//@version=4
study("Cumulative Line", overlay=false)

apertura = open[0]
cierre = close[1]

suma = 10000.0
suma := suma + (open[0] - close[1]) + 10000.0

plot(suma)